diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2010-10-22 12:52:35 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2010-10-22 12:52:35 +0200 |
commit | dbac793645654ac6715e6adecfd9d4a4a1fd8551 (patch) | |
tree | 52550aeeb8caec936897a792236300f86aad3884 /src/resources/image.h | |
parent | a9bcae9f81d97f67ab21cd26a099449cf0746137 (diff) | |
download | mana-dbac793645654ac6715e6adecfd9d4a4a1fd8551.tar.gz mana-dbac793645654ac6715e6adecfd9d4a4a1fd8551.tar.bz2 mana-dbac793645654ac6715e6adecfd9d4a4a1fd8551.tar.xz mana-dbac793645654ac6715e6adecfd9d4a4a1fd8551.zip |
Turned the OpenGL and disable transparency options as static members.
- Now OpenGL and the transparency disabling are set at startup and
not read again for displaying graphics, preventing graphic errors
before startup.
- We also agreed long time ago that SDL specific functions
should have a SDL prefix. The header has been rearranged a bit
to do so.
- Also fixed a possible discrepancy in the hasAlphaChannel() function.
Reviewed-by: CodyMartin.
Resolves: Mana-Mantis: #260.
Diffstat (limited to 'src/resources/image.h')
-rw-r--r-- | src/resources/image.h | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/src/resources/image.h b/src/resources/image.h index 815b7764..1db52ca0 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -113,16 +113,10 @@ class Image : public Resource { return mBounds.h; } /** - * Tells if the image was loaded using OpenGL or SDL + * Tells if the system is using OpenGL or SDL * @return true if OpenGL, false if SDL. */ - bool isAnOpenGLOne() const; - - /** - * Tells if the image has got an alpha channel - * @return true if it's true, false otherwise. - */ - bool hasAlphaChannel(); + static bool useOpenGL(); /** * Sets the alpha value of this image. @@ -143,10 +137,24 @@ class Image : public Resource */ virtual Image *getSubImage(int x, int y, int width, int height); + /** + * Tells if the image has got an alpha channel + * @return true if it's true, false otherwise. + */ + bool hasAlphaChannel(); // SDL only public functions /** + * Disable the transparency handling (for low CPUs in SDL Mode) + */ + static void SDLdisableTransparency() + { mDisableTransparency = true; } + + static bool SDLisTransparencyDisabled() + { return mDisableTransparency; } + + /** * Gets an scaled instance of an image. * * @param width The desired width of the scaled image. @@ -171,13 +179,13 @@ class Image : public Resource Uint8 *SDLgetAlphaChannel() const { return mAlphaChannel; } - SDL_Surface* duplicateSurface(SDL_Surface* tmpImage); + SDL_Surface* SDLduplicateSurface(SDL_Surface* tmpImage); - void cleanCache(); + void SDLcleanCache(); - void terminateAlphaCache(); + void SDLterminateAlphaCache(); - static void setEnableAlphaCache(bool n) + static void SDLsetEnableAlphaCache(bool n) { mEnableAlphaCache = n; } #ifdef USE_OPENGL @@ -199,18 +207,17 @@ class Image : public Resource protected: - // ----------------------- - // Generic protected members - // ----------------------- + // ----------------------- + // Generic protected members + // ----------------------- SDL_Rect mBounds; bool mLoaded; float mAlpha; - bool mHasAlphaChannel; - // ----------------------- - // SDL protected members - // ----------------------- + // ----------------------- + // SDL protected members + // ----------------------- /** SDL Constructor */ Image(SDL_Surface *image, bool hasAlphaChannel = false, @@ -225,13 +232,18 @@ class Image : public Resource /** Alpha Channel pointer used for 32bit based SDL surfaces */ Uint8 *mAlphaChannel; + bool mHasAlphaChannel; + /** Alpha cache: The cache stores a copy of the image + for specific requested opacities, hence, increasing + the image disply speed */ std::map<float, SDL_Surface*> mAlphaCache; - bool mUseAlphaCache; - static bool mEnableAlphaCache; + /** Stores whether the transparency is disabled */ + static bool mDisableTransparency; + // ----------------------- // OpenGL protected members // ----------------------- |