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 /src/graphics.cpp | |
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.
Diffstat (limited to 'src/graphics.cpp')
-rw-r--r-- | src/graphics.cpp | 49 |
1 files changed, 28 insertions, 21 deletions
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); } |