summaryrefslogtreecommitdiff
path: root/src/graphics.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-23 21:59:21 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-23 22:00:09 +0100
commit99e8a3fd77b63a029fe02dcf771b6af1aad252ed (patch)
tree03c296d1f89859aae35336dfe2f58df09d256fd3 /src/graphics.cpp
parentfa8a4bf49100c0a1d5b96e00803f43bbbb861100 (diff)
parent347452b9b69ef3af29c577b7751082822e900c01 (diff)
downloadmana-client-99e8a3fd77b63a029fe02dcf771b6af1aad252ed.tar.gz
mana-client-99e8a3fd77b63a029fe02dcf771b6af1aad252ed.tar.bz2
mana-client-99e8a3fd77b63a029fe02dcf771b6af1aad252ed.tar.xz
mana-client-99e8a3fd77b63a029fe02dcf771b6af1aad252ed.zip
Merge branch 'aethyra/master'
Conflicts: Many files.
Diffstat (limited to 'src/graphics.cpp')
-rw-r--r--src/graphics.cpp60
1 files changed, 33 insertions, 27 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 4af7b723..b9bd9fa6 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -49,30 +49,25 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
mFullscreen = fs;
mHWAccel = hwaccel;
- if (fs) {
+ if (fs)
displayFlags |= SDL_FULLSCREEN;
- }
- if (hwaccel) {
+ if (hwaccel)
displayFlags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
- } else {
+ else
displayFlags |= SDL_SWSURFACE;
- }
mScreen = SDL_SetVideoMode(w, h, bpp, displayFlags);
- if (!mScreen) {
+ if (!mScreen)
return false;
- }
char videoDriverName[64];
- if (SDL_VideoDriverName(videoDriverName, 64)) {
+ if (SDL_VideoDriverName(videoDriverName, 64))
logger->log("Using video driver: %s", videoDriverName);
- }
- else {
+ else
logger->log("Using video driver: unknown");
- }
const SDL_VideoInfo *vi = SDL_GetVideoInfo();
@@ -103,9 +98,8 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
bool Graphics::setFullscreen(bool fs)
{
- if (mFullscreen == fs) {
+ if (mFullscreen == fs)
return true;
- }
return setVideoMode(mScreen->w, mScreen->h,
mScreen->format->BitsPerPixel, fs, mHWAccel);
@@ -127,7 +121,7 @@ bool Graphics::drawImage(Image *image, int x, int y)
}
bool Graphics::drawImage(Image *image, int srcX, int srcY, int dstX, int dstY,
- int width, int height, bool)
+ int width, int height, bool)
{
// Check that preconditions for blitting are met.
if (!mScreen || !image || !image->mImage) return false;
@@ -149,7 +143,7 @@ bool Graphics::drawImage(Image *image, int srcX, int srcY, int dstX, int dstY,
}
void Graphics::drawImage(gcn::Image const *image, int srcX, int srcY,
- int dstX, int dstY, int width, int height)
+ int dstX, int dstY, int width, int height)
{
ProxyImage const *srcImage =
dynamic_cast< ProxyImage const * >(image);
@@ -159,22 +153,34 @@ void Graphics::drawImage(gcn::Image const *image, int srcX, int srcY,
void Graphics::drawImagePattern(Image *image, int x, int y, int w, int h)
{
- int iw = image->getWidth();
- int ih = image->getHeight();
- if (iw == 0 || ih == 0) return;
+ // Check that preconditions for blitting are met.
+ if (!mScreen || !image || !image->mImage) return;
+
+ const int iw = image->getWidth();
+ const int ih = image->getHeight();
+
+ if (iw == 0 || ih == 0) return;
- int px = 0; // X position on pattern plane
- int py = 0; // Y position on pattern plane
+ for (int py = 0; py < h; py += ih) // Y position on pattern plane
+ {
+ int dh = (py + ih >= h) ? h - py : ih;
+ int srcY = image->mBounds.y;
+ int dstY = y + py + mClipStack.top().yOffset;
- while (py < h) {
- while (px < w) {
+ for (int px = 0; px < w; px += iw) // X position on pattern plane
+ {
int dw = (px + iw >= w) ? w - px : iw;
- int dh = (py + ih >= h) ? h - py : ih;
- drawImage(image, 0, 0, x + px, y + py, dw, dh);
- px += iw;
+ int srcX = image->mBounds.x;
+ int dstX = x + px + mClipStack.top().xOffset;
+
+ SDL_Rect dstRect;
+ SDL_Rect srcRect;
+ dstRect.x = dstX; dstRect.y = dstY;
+ srcRect.x = srcX; srcRect.y = srcY;
+ srcRect.w = dw; srcRect.h = dh;
+
+ SDL_BlitSurface(image->mImage, &srcRect, mScreen, &dstRect);
}
- py += ih;
- px = 0;
}
}