diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-02-18 11:31:05 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-02-18 11:31:05 +0000 |
commit | 8f28717190dd36f64c8c9d3a155ebdd3af93ea25 (patch) | |
tree | 21237edcd0391b73a7d6d56ebc3ca6a09af547eb | |
parent | 1cc8f5dc5413651d12df2ada51538d46734b0f0f (diff) | |
download | mana-8f28717190dd36f64c8c9d3a155ebdd3af93ea25.tar.gz mana-8f28717190dd36f64c8c9d3a155ebdd3af93ea25.tar.bz2 mana-8f28717190dd36f64c8c9d3a155ebdd3af93ea25.tar.xz mana-8f28717190dd36f64c8c9d3a155ebdd3af93ea25.zip |
Eliminated double draw implementation, only keeping the more complete one.
-rw-r--r-- | src/resources/image.cpp | 106 |
1 files changed, 4 insertions, 102 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 02eb2393..efd126b1 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -253,7 +253,7 @@ bool Image::draw(SDL_Surface *screen, int srcX, int srcY, int dstX, int dstY, if (screen == NULL || image == NULL) return false; // Set the alpha value this image is drawn at - SDL_SetAlpha(image, SDL_SRCALPHA, 255 * alpha); + SDL_SetAlpha(image, SDL_SRCALPHA, (int)(255 * alpha)); SDL_Rect dstRect; SDL_Rect srcRect; @@ -303,55 +303,7 @@ bool Image::draw(SDL_Surface *screen, int srcX, int srcY, int dstX, int dstY, bool Image::draw(SDL_Surface *screen, int x, int y) { -#ifndef USE_OPENGL - - // Check that preconditions for blitting are met. - if (screen == NULL || image == NULL) return false; - - // Set the alpha value this image is drawn at - SDL_SetAlpha(image, SDL_SRCALPHA, 255 * alpha); - - SDL_Rect dstRect; - dstRect.x = x; - dstRect.y = y; - - if (SDL_BlitSurface(image, NULL, screen, &dstRect) < 0) { - return false; - } - -#else - - // Find OpenGL texture coordinates - float texX1 = 0.0f; - float texY1 = 0.0f; - float texX2 = width / (float)texWidth; - float texY2 = height / (float)texHeight; - - glBindTexture(GL_TEXTURE_2D, image); - - glEnable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - - // Draw a textured quad -- the image - glBegin(GL_QUADS); - glTexCoord2f(texX1, texY1); - glVertex3i(x, y, 0); - - glTexCoord2f(texX2, texY1); - glVertex3i(x + width, y, 0); - - glTexCoord2f(texX2, texY2); - glVertex3i(x + width, y + height, 0); - - glTexCoord2f(texX1, texY2); - glVertex3i(x, y + height, 0); - glEnd(); - - glDisable(GL_TEXTURE_2D); - glDisable(GL_BLEND); - -#endif - return true; + return draw(screen, 0, 0, x, y, getWidth(), getHeight()); } void Image::drawPattern(SDL_Surface *screen, int x, int y, int w, int h) @@ -440,7 +392,7 @@ bool SubImage::draw(SDL_Surface *screen, int srcX, int srcY, if (screen == NULL || image == NULL) return false; // Set the alpha value this image is drawn at - SDL_SetAlpha(image, SDL_SRCALPHA, 255 * alpha); + SDL_SetAlpha(image, SDL_SRCALPHA, (int)(255 * alpha)); SDL_Rect dstRect; SDL_Rect srcRect; @@ -491,55 +443,5 @@ bool SubImage::draw(SDL_Surface *screen, int srcX, int srcY, bool SubImage::draw(SDL_Surface *screen, int x, int y) { -#ifndef USE_OPENGL - // Check that drawing preconditions are satisfied. - if (screen == NULL || image == NULL) return false; - - // Set the alpha value this image is drawn at - SDL_SetAlpha(image, SDL_SRCALPHA, 255 * alpha); - - SDL_Rect dstRect; - dstRect.x = x; - dstRect.y = y; - - // Draw subimage part to given location - if (SDL_BlitSurface(image, &rect, screen, &dstRect) < 0) { - return false; - } - -#else - - // Find OpenGL texture coordinates - float texX1 = rect.x / (float)texWidth; - float texY1 = rect.y / (float)texHeight; - float texX2 = (rect.x + rect.w) / (float)texWidth; - float texY2 = (rect.y + rect.h) / (float)texHeight; - - glBindTexture(GL_TEXTURE_2D, image); - - glEnable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - - // Draw a textured quad -- the image - glBegin(GL_QUADS); - - glTexCoord2f(texX1, texY1); - glVertex3i(x, y, 0); - - glTexCoord2f(texX2, texY1); - glVertex3i(x + rect.w, y, 0); - - glTexCoord2f(texX2, texY2); - glVertex3i(x + rect.w, y + rect.h, 0); - - glTexCoord2f(texX1, texY2); - glVertex3i(x, y + rect.h, 0); - - glEnd(); - - glDisable(GL_TEXTURE_2D); - glDisable(GL_BLEND); - -#endif - return true; + return draw(screen, 0, 0, x, y, getWidth(), getHeight()); } |