From 3f21f53869044e5928ed2407a48ac28835da1cb1 Mon Sep 17 00:00:00 2001 From: Bertram Date: Thu, 13 Aug 2009 19:53:56 +0200 Subject: Cleaned up the image code a bit... --- src/resources/image.h | 90 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 32 deletions(-) (limited to 'src/resources/image.h') diff --git a/src/resources/image.h b/src/resources/image.h index f497f608..824881a3 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -87,16 +87,6 @@ class Image : public Resource */ static Image *load(SDL_Surface *); - /** - * Gets an scaled instance of an image. - * - * @param width The desired width of the scaled image. - * @param height The desired height of the scaled image. - * - * @return A new Image* object. - */ - Image* SDLgetScaledImage(int width, int height); - /** * Frees the resources created by SDL. */ @@ -120,6 +110,17 @@ class Image : public Resource */ bool isAnOpenGLOne() const; + /** + * Sets the alpha value of this image. + */ + virtual void setAlpha(float alpha); + + /** + * Returns the alpha value of this image. + */ + float getAlpha() const + { return mAlpha; } + /** * Creates a new image with the desired clipping rectangle. * @@ -128,17 +129,32 @@ class Image : public Resource */ virtual Image *getSubImage(int x, int y, int width, int height); + + // SDL only public functions + /** - * Sets the alpha value of this image. + * Gets an scaled instance of an image. + * + * @param width The desired width of the scaled image. + * @param height The desired height of the scaled image. + * + * @return A new Image* object. */ - virtual void setAlpha(float alpha); + Image* SDLgetScaledImage(int width, int height); /** - * Returns the alpha value of this image. + * Merges two image SDL_Surfaces together. This is for SDL use only, as + * reducing the number of surfaces that SDL has to render can cut down + * on the number of blit operations necessary, which in turn can help + * improve overall framerates. Don't use unless you are using it to + * reduce the number of overall layers that need to be drawn through SDL. */ - float getAlpha() const; + Image *SDLmerge(Image *image, int x, int y); #ifdef USE_OPENGL + + // OpenGL only public functions + /** * Sets the target image format. Use false for SDL and * true for OpenGL. @@ -150,20 +166,36 @@ class Image : public Resource static int getTextureType() { return mTextureType; } #endif - /** - * Merges two image SDL_Surfaces together. This is for SDL use only, as - * reducing the number of surfaces that SDL has to render can cut down - * on the number of blit operations necessary, which in turn can help - * improve overall framerates. Don't use unless you are using it to - * reduce the number of overall layers that need to be drawn through SDL. - */ - Image *merge(Image *image, int x, int y); - protected: + + // ----------------------- + // Generic protected members + // ----------------------- + + SDL_Rect mBounds; + bool mLoaded; + float mAlpha; + + // ----------------------- + // SDL protected members + // ----------------------- + + /** SDL Constructor */ + Image(SDL_Surface *image); + + static Image *_SDLload(SDL_Surface *tmpImage); + + + SDL_Surface *mImage; + + + // ----------------------- + // OpenGL protected members + // ----------------------- +#ifdef USE_OPENGL /** - * Constructor. + * OpenGL Constructor. */ -#ifdef USE_OPENGL Image(GLuint glimage, int width, int height, int texWidth, int texHeight); @@ -171,13 +203,9 @@ class Image : public Resource * Returns the first power of two equal or bigger than the input. */ static int powerOfTwo(int input); -#endif - Image(SDL_Surface *image); - SDL_Rect mBounds; - bool mLoaded; + static Image *_GLload(SDL_Surface *tmpImage); -#ifdef USE_OPENGL GLuint mGLImage; int mTexWidth, mTexHeight; @@ -185,8 +213,6 @@ class Image : public Resource static int mTextureType; static int mTextureSize; #endif - SDL_Surface *mImage; - float mAlpha; }; /** -- cgit v1.2.3-70-g09d2