summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2005-07-16 14:29:42 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2005-07-16 14:29:42 +0000
commit51224bed60d5bed45b53e99b44bc1123a2a9cb68 (patch)
tree2acbf76139b6ef76d21aaf98ee09e326a59c4467 /src/resources
parent96e61ed3ff7e41976ac8788363d6df8719037962 (diff)
downloadmana-51224bed60d5bed45b53e99b44bc1123a2a9cb68.tar.gz
mana-51224bed60d5bed45b53e99b44bc1123a2a9cb68.tar.bz2
mana-51224bed60d5bed45b53e99b44bc1123a2a9cb68.tar.xz
mana-51224bed60d5bed45b53e99b44bc1123a2a9cb68.zip
Made Image/SubImage being drawn by Graphics. Removed some redundant code.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/image.cpp86
-rw-r--r--src/resources/image.h21
2 files changed, 9 insertions, 98 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 2a0482d9..bb8d7c9a 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -287,7 +287,7 @@ Image *Image::getSubImage(int x, int y, int width, int height)
#endif
}
-bool Image::draw(SDL_Surface *screen, int srcX, int srcY, int dstX, int dstY,
+bool Image::draw_deprecated(SDL_Surface *screen, int srcX, int srcY, int dstX, int dstY,
int width, int height)
{
#ifndef USE_OPENGL
@@ -341,30 +341,9 @@ bool Image::draw(SDL_Surface *screen, int srcX, int srcY, int dstX, int dstY,
return true;
}
-bool Image::draw(SDL_Surface *screen, int x, int y)
+bool Image::draw_deprecated(SDL_Surface *screen, int x, int y)
{
- return draw(screen, 0, 0, x, y, getWidth(), getHeight());
-}
-
-void Image::drawPattern(SDL_Surface *screen, int x, int y, int w, int h)
-{
- int iw = getWidth(); // Width of image
- int ih = getHeight(); // Height of image
- if (iw == 0 || ih == 0) return;
-
- int px = 0; // X position on pattern plane
- int py = 0; // Y position on pattern plane
-
- while (py < h) {
- while (px < w) {
- int dw = (px + iw >= w) ? w - px : iw;
- int dh = (py + ih >= h) ? h - py : ih;
- draw(screen, 0, 0, x + px, y + py, dw, dh);
- px += iw;
- }
- py += ih;
- px = 0;
- }
+ return draw_deprecated(screen, 0, 0, x, y, getWidth(), getHeight());
}
void Image::setAlpha(float a)
@@ -429,62 +408,9 @@ Image *SubImage::getSubImage(int x, int y, int w, int h)
return NULL;
}
-bool SubImage::draw(SDL_Surface *screen, int srcX, int srcY,
+bool SubImage::draw_deprecated(SDL_Surface *screen, int srcX, int srcY,
int dstX, int dstY, int width, int height)
{
-#ifndef USE_OPENGL
- // Check that preconditions for blitting are met.
- if (screen == NULL || image == NULL) return false;
-
- SDL_Rect dstRect;
- SDL_Rect srcRect;
- dstRect.x = dstX; dstRect.y = dstY;
- srcRect.x = rect.x + srcX;
- srcRect.y = rect.y + srcY;
- srcRect.w = width;
- srcRect.h = height;
-
- if (SDL_BlitSurface(image, &srcRect, screen, &dstRect) < 0) {
- return false;
- }
-
-#else
-
- // Find OpenGL texture coordinates
- float texX1 = (rect.x + srcX) / (float)texWidth;
- float texY1 = (rect.y + srcY) / (float)texHeight;
- float texX2 = (rect.x + srcX + width) / (float)texWidth;
- float texY2 = (rect.y + srcY + height) / (float)texHeight;
-
- glColor4f(1.0f, 1.0f, 1.0f, alpha);
- 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(dstX, dstY, 0);
-
- glTexCoord2f(texX2, texY1);
- glVertex3i(dstX + width, dstY, 0);
-
- glTexCoord2f(texX2, texY2);
- glVertex3i(dstX + width, dstY + height, 0);
-
- glTexCoord2f(texX1, texY2);
- glVertex3i(dstX, dstY + height, 0);
- glEnd();
-
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_BLEND);
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-
-#endif
- return true;
-}
-
-bool SubImage::draw(SDL_Surface *screen, int x, int y)
-{
- return draw(screen, 0, 0, x, y, getWidth(), getHeight());
+ return Image::draw_deprecated(screen, rect.x + srcX, rect.y + srcY,
+ dstX, dstY, width, height);
}
diff --git a/src/resources/image.h b/src/resources/image.h
index 7fe83a66..9151a869 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -89,7 +89,7 @@ class Image : public Resource
* <code>false</code> otherwise.
*/
virtual bool
- draw(SDL_Surface *screen,
+ draw_deprecated(SDL_Surface *screen,
int srcX, int srcY,
int dstX, int dstY,
int width, int height);
@@ -101,13 +101,7 @@ class Image : public Resource
* <code>false</code> otherwise.
*/
virtual bool
- draw(SDL_Surface *screen, int x, int y);
-
- /**
- * Does a pattern fill on the given area.
- */
- virtual void
- drawPattern(SDL_Surface *screen, int x, int y, int w, int h);
+ draw_deprecated(SDL_Surface *screen, int x, int y);
/**
* Sets the alpha value of this image.
@@ -193,20 +187,11 @@ class SubImage : public Image
* Draws this image.
*/
bool
- draw(SDL_Surface *screen,
+ draw_deprecated(SDL_Surface *screen,
int srcX, int srcY,
int dstX, int dstY,
int width, int height);
- /**
- * Draws the clipped image onto the screen.
- *
- * @return <code>true</code> if drawing was succesful
- * <code>false</code> otherwise.
- */
- bool
- draw(SDL_Surface *screen, int x, int y);
-
private:
Image *parent;
SDL_Rect rect;