diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-08-15 00:15:45 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-08-15 00:15:45 +0000 |
commit | 7f88cac6ff2f8c525bca5dd74e96662005358120 (patch) | |
tree | e4bc0294918103af7968e7ff0b207cbf20a9d3c7 | |
parent | cfaf8b836b21842b5d22ad774f93c2c364d33c0b (diff) | |
download | mana-7f88cac6ff2f8c525bca5dd74e96662005358120.tar.gz mana-7f88cac6ff2f8c525bca5dd74e96662005358120.tar.bz2 mana-7f88cac6ff2f8c525bca5dd74e96662005358120.tar.xz mana-7f88cac6ff2f8c525bca5dd74e96662005358120.zip |
Made the OpenGL related code fully #ifdef'ed.
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | src/graphics.cpp | 49 | ||||
-rw-r--r-- | src/graphics.h | 9 | ||||
-rw-r--r-- | src/main.cpp | 8 |
4 files changed, 44 insertions, 24 deletions
@@ -1,5 +1,7 @@ 2005-08-15 Björn Steinbrink <B.Steinbrink@gmx.de> + * src/graphics.cpp, src/graphics.h, src/main.cpp: Made the OpenGL related + code fully #ifdef'ed. * src/main.cpp, src/gui/browserbox.cpp, src/gui/gui.cpp, src/resources/image.cpp, src/resources/image.h: Fully faded out the useOpenGL global. Image and Graphics keep track of the mode on their own diff --git a/src/graphics.cpp b/src/graphics.cpp index e71052df..98a17b4a 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -35,11 +35,17 @@ extern volatile int framesToDraw; - +#ifdef USE_OPENGL Graphics::Graphics(bool useOpenGL): mScreen(0), useOpenGL(useOpenGL) { } +#else +Graphics::Graphics(): + mScreen(0) +{ +} +#endif Graphics::~Graphics() { @@ -159,23 +165,8 @@ bool Graphics::drawImage(Image *image, int srcX, int srcY, int dstX, int dstY, srcX += image->bounds.x; srcY += image->bounds.y; - if (!useOpenGL) { - // Check that preconditions for blitting are met. - if (!mScreen || !image->image) return false; - - SDL_Rect dstRect; - SDL_Rect srcRect; - dstRect.x = dstX; dstRect.y = dstY; - srcRect.x = srcX; srcRect.y = srcY; - srcRect.w = width; - srcRect.h = height; - - if (SDL_BlitSurface(image->image, &srcRect, mScreen, &dstRect) < 0) { - return false; - } - } #ifdef USE_OPENGL - else { + if (useOpenGL) { // Find OpenGL texture coordinates float texX1 = srcX / (float)image->texWidth; float texY1 = srcY / (float)image->texHeight; @@ -205,8 +196,24 @@ bool Graphics::drawImage(Image *image, int srcX, int srcY, int dstX, int dstY, glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - } + } else #endif + { + // Check that preconditions for blitting are met. + if (!mScreen || !image->image) return false; + + SDL_Rect dstRect; + SDL_Rect srcRect; + dstRect.x = dstX; dstRect.y = dstY; + srcRect.x = srcX; srcRect.y = srcY; + srcRect.w = width; + srcRect.h = height; + + if (SDL_BlitSurface(image->image, &srcRect, mScreen, &dstRect) < 0) { + return false; + } + } + return true; } @@ -284,14 +291,14 @@ void Graphics::drawImageRect( void Graphics::updateScreen() { - if (useOpenGL) { #ifdef USE_OPENGL + if (useOpenGL) { glFlush(); glFinish(); SDL_GL_SwapBuffers(); + } else #endif - } - else { + { SDL_Flip(mScreen); } diff --git a/src/graphics.h b/src/graphics.h index cdbc4104..a3b4aab3 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -48,7 +48,11 @@ public gcn::SDLGraphics { /** * Constructor. */ +#ifdef USE_OPENGL Graphics(bool useOpenGL); +#else + Graphics(); +#endif /** * Destructor. @@ -145,7 +149,10 @@ public gcn::SDLGraphics { private: SDL_Surface *mScreen; - bool mFullscreen, mHWAccel, useOpenGL; + bool mFullscreen, mHWAccel; +#ifdef USE_OPENGL + bool useOpenGL; +#endif }; #endif diff --git a/src/main.cpp b/src/main.cpp index 5d06cf97..a6c07467 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -230,15 +230,19 @@ void init_engine() fullscreen = ((int)config.getValue("screen", 0) == 1); hwaccel = ((int)config.getValue("hwaccel", 0) == 1); +#ifdef USE_OPENGL bool useOpenGL = (config.getValue("opengl", 0) == 1); -#ifdef USE_OPENGL // Setup image loading for the right image format Image::setLoadAsOpenGL(useOpenGL); -#endif // Create the graphics context graphics = new Graphics(useOpenGL); +#else + // Create the graphics context + graphics = new Graphics(); +#endif + // Try to set the desired video mode if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel)) { |