summaryrefslogtreecommitdiff
path: root/src/resources/image.h
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-06-23 23:33:34 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-06-23 23:33:34 +0000
commit4b0172d1f666a12cffbdd6bd331e95a92d8f652f (patch)
treedde7ab71fd5d02200be35e041b00e5649f9cd3a8 /src/resources/image.h
parent33587089cf7d87bbc2104e80746fdddc7a5498e1 (diff)
downloadmana-client-4b0172d1f666a12cffbdd6bd331e95a92d8f652f.tar.gz
mana-client-4b0172d1f666a12cffbdd6bd331e95a92d8f652f.tar.bz2
mana-client-4b0172d1f666a12cffbdd6bd331e95a92d8f652f.tar.xz
mana-client-4b0172d1f666a12cffbdd6bd331e95a92d8f652f.zip
Finishing resource manager ability to clean up resources. Still work to do on
resources other than images.
Diffstat (limited to 'src/resources/image.h')
-rw-r--r--src/resources/image.h79
1 files changed, 48 insertions, 31 deletions
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 <string>
-// 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 <code>NULL</code> 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 <code>NULL</code> 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 <code>true</code> if the image was blitted properly
* <code>false</code> 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 <code>true</code> if the image was blitted properly
* <code>false</code> 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 <code>NULL</code> 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 <code>true</code> if drawing was succesful
- * <code>false</code> otherwise.
+ * <code>false</code> otherwise.
*/
- bool draw(SDL_Surface *screen, int x, int y);
+ bool
+ draw(SDL_Surface *screen, int x, int y);
private:
Image *parent;