From 4b0172d1f666a12cffbdd6bd331e95a92d8f652f Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Thu, 23 Jun 2005 23:33:34 +0000 Subject: Finishing resource manager ability to clean up resources. Still work to do on resources other than images. --- src/resources/image.h | 79 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 31 deletions(-) (limited to 'src/resources/image.h') diff --git a/src/resources/image.h b/src/resources/image.h index 14aa4550..b41876d2 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -32,10 +32,6 @@ #include -// Forward declarations -class SubImage; -class ScaledImage; - /** * Defines a class for loading and storing images. */ @@ -45,7 +41,8 @@ class Image : public Resource /** * Destructor. */ - virtual ~Image(); + virtual + ~Image(); /** * Loads an image from a buffer in memory. @@ -56,22 +53,26 @@ class Image : public Resource * @return NULL if the an error occurred, a valid pointer * otherwise. */ - static Image *load(void* buffer, unsigned int bufferSize); + static Image* + load(void* buffer, unsigned int bufferSize); /** * Frees the resources created by SDL. */ - virtual void unload(); + virtual void + unload(); /** * Returns the width of the image. */ - virtual int getWidth() const; + virtual int + getWidth() const; /** * Returns the height of the image. */ - virtual int getHeight() const; + virtual int + getHeight() const; /** * Creates a new image with the desired clipping rectangle. @@ -79,7 +80,8 @@ class Image : public Resource * @return NULL if creation failed and a valid * object otherwise. */ - virtual Image* getSubImage(int x, int y, int width, int height); + virtual Image* + getSubImage(int x, int y, int width, int height); /** * Blits the image onto the screen. @@ -87,10 +89,11 @@ class Image : public Resource * @return true if the image was blitted properly * false otherwise. */ - virtual bool draw(SDL_Surface *screen, - int srcX, int srcY, - int dstX, int dstY, - int width, int height); + virtual bool + draw(SDL_Surface *screen, + int srcX, int srcY, + int dstX, int dstY, + int width, int height); /** * Blits the image onto the screen. @@ -98,23 +101,26 @@ class Image : public Resource * @return true if the image was blitted properly * false otherwise. */ - virtual bool draw(SDL_Surface *screen, int x, int y); + virtual bool + draw(SDL_Surface *screen, int x, int y); /** * Does a pattern fill on the given area. */ - virtual void drawPattern( - SDL_Surface *screen, int x, int y, int w, int h); + virtual void + drawPattern(SDL_Surface *screen, int x, int y, int w, int h); /** * Sets the alpha value of this image. */ - void setAlpha(float alpha); + void + setAlpha(float alpha); /** * Returns the alpha value of this image. */ - float getAlpha(); + float + getAlpha(); protected: @@ -123,12 +129,14 @@ class Image : public Resource */ #ifdef USE_OPENGL Image(GLuint image, - int width, int height, - int texWidth, int texHeight); + int width, int height, + int texWidth, int texHeight); #else Image(SDL_Surface *image); #endif + bool loaded; + #ifdef USE_OPENGL GLuint image; int width, height; @@ -150,10 +158,10 @@ class SubImage : public Image */ #ifndef USE_OPENGL SubImage(Image *parent, SDL_Surface *image, - int x, int y, int width, int height); + int x, int y, int width, int height); #else SubImage(Image *parent, GLuint image, int x, int y, - int width, int height, int texWidth, int textHeight); + int width, int height, int texWidth, int textHeight); #endif /** @@ -164,32 +172,41 @@ class SubImage : public Image /** * Returns the width of the image. */ - int getWidth() const; + int + getWidth() const; /** * Returns the height of the image. */ - int getHeight() const; + int + getHeight() const; /** * Creates a new image with the desired clipping rectangle. + * * @return NULL if creation failed and a valid - * object otherwise. + * image otherwise. */ - Image* getSubImage(int x, int y, int width, int height); + Image* + getSubImage(int x, int y, int width, int height); /** * Draws this image. */ - bool draw(SDL_Surface *screen, int srcX, int srcY, - int dstX, int dstY, int width, int height); + bool + draw(SDL_Surface *screen, + int srcX, int srcY, + int dstX, int dstY, + int width, int height); /** * Draws the clipped image onto the screen. + * * @return true if drawing was succesful - * false otherwise. + * false otherwise. */ - bool draw(SDL_Surface *screen, int x, int y); + bool + draw(SDL_Surface *screen, int x, int y); private: Image *parent; -- cgit v1.2.3-70-g09d2