diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-07-16 14:29:42 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-07-16 14:29:42 +0000 |
commit | 51224bed60d5bed45b53e99b44bc1123a2a9cb68 (patch) | |
tree | 2acbf76139b6ef76d21aaf98ee09e326a59c4467 /src | |
parent | 96e61ed3ff7e41976ac8788363d6df8719037962 (diff) | |
download | mana-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')
-rw-r--r-- | src/engine.cpp | 35 | ||||
-rw-r--r-- | src/graphics.cpp | 45 | ||||
-rw-r--r-- | src/graphics.h | 5 | ||||
-rw-r--r-- | src/gui/char_select.cpp | 2 | ||||
-rw-r--r-- | src/gui/char_server.cpp | 2 | ||||
-rw-r--r-- | src/gui/checkbox.cpp | 2 | ||||
-rw-r--r-- | src/gui/equipment.cpp | 18 | ||||
-rw-r--r-- | src/gui/gui.cpp | 5 | ||||
-rw-r--r-- | src/gui/itemcontainer.cpp | 10 | ||||
-rw-r--r-- | src/gui/login.cpp | 2 | ||||
-rw-r--r-- | src/gui/minimap.cpp | 3 | ||||
-rw-r--r-- | src/gui/playerbox.cpp | 6 | ||||
-rw-r--r-- | src/gui/popupmenu.cpp | 3 | ||||
-rw-r--r-- | src/gui/radiobutton.cpp | 2 | ||||
-rw-r--r-- | src/gui/scrollarea.cpp | 3 | ||||
-rw-r--r-- | src/gui/setup.cpp | 2 | ||||
-rw-r--r-- | src/gui/slider.cpp | 9 | ||||
-rw-r--r-- | src/gui/updatewindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/window.cpp | 3 | ||||
-rw-r--r-- | src/main.cpp | 5 | ||||
-rw-r--r-- | src/map.cpp | 2 | ||||
-rw-r--r-- | src/resources/image.cpp | 86 | ||||
-rw-r--r-- | src/resources/image.h | 21 |
23 files changed, 122 insertions, 151 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index 4e8c218f..91c1eb3a 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -50,6 +50,9 @@ #include "resources/resourcemanager.h" #include "resources/itemmanager.h" +// TODO Check if we can get rid of this +extern SDL_Surface *screen; + extern Being* autoTarget; extern Graphics* graphics; @@ -362,9 +365,10 @@ void Engine::draw() int absx = sx * 32 - offset_x; int absy = sy * 32 - offset_y; if (itemDb->getItemInfo(floorItem->id)->getImage() > 0) { - itemset->spriteset[itemDb->getItemInfo( - floorItem->id)->getImage() - 1]->draw(screen, - absx, absy); + Image *image = itemset->spriteset[itemDb->getItemInfo( + floorItem->id)->getImage() - 1]; + + guiGraphics->drawImage(image, absx, absy); } floorItemIterator++; @@ -390,7 +394,7 @@ void Engine::draw() // Draw a NPC if (being->isNpc()) { - npcset->spriteset[being->job - 100]->draw(screen, + guiGraphics->drawImage(npcset->spriteset[being->job - 100], sx * 32 - 8 - offset_x, sy * 32 - 52 - offset_y); } @@ -412,12 +416,14 @@ void Engine::draw() pf += 4 * (being->weapon - 1); } - playerset->spriteset[pf + 16 * dir]->draw(screen, + guiGraphics->drawImage(playerset->spriteset[pf + 16 * dir], being->text_x - 16, being->text_y - 32); if (being->weapon != 0 && being->action == ATTACK) { - weaponset->spriteset[16 * (being->weapon - 1) + 4 * - being->frame + dir]->draw(screen, + Image *image = weaponset->spriteset[ + 16 * (being->weapon - 1) + 4 * being->frame + dir]; + + guiGraphics->drawImage(image, being->text_x - 64, being->text_y - 80); } @@ -425,13 +431,14 @@ void Engine::draw() int hf = being->getHairColor() - 1 + 10 * (dir + 4 * (being->getHairStyle() - 1)); - hairset->spriteset[hf]->draw(screen, + guiGraphics->drawImage(hairset->spriteset[hf], being->text_x - 2 + 2 * hairtable[pf][dir][0], being->text_y - 50 + 2 * hairtable[pf][dir][1]); } if (being->emotion != 0) { - emotionset->spriteset[being->emotion - 1]->draw(screen, + guiGraphics->drawImage( + emotionset->spriteset[being->emotion - 1], sx * 32 + 5 + get_x_offset(being) - offset_x, sy * 32 - 65 + get_y_offset(being) - offset_y); } @@ -462,7 +469,8 @@ void Engine::draw() int mf = being->frame + being->action; if (being->action == MONSTER_DEAD) { - monsterset[being->job - 1002]->spriteset[dir + 4 * MONSTER_DEAD]->draw(screen, + guiGraphics->drawImage( + monsterset[being->job - 1002]->spriteset[dir + 4 * MONSTER_DEAD], being->text_x + 30, being->text_y + 40); if (autoTarget == being) { @@ -470,12 +478,13 @@ void Engine::draw() } } else { - monsterset[being->job-1002]->spriteset[dir + 4 * mf]->draw( - screen, being->text_x + 30, being->text_y + 40); + guiGraphics->drawImage( + monsterset[being->job-1002]->spriteset[dir + 4 * mf], + being->text_x + 30, being->text_y + 40); if (being->x == mouseTileX && being->y == mouseTileY) { - attackTarget->draw(screen, + guiGraphics->drawImage(attackTarget, being->text_x + 30 + 16, being->text_y + 32); } } diff --git a/src/graphics.cpp b/src/graphics.cpp index 5eae65bf..9f8981e3 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -72,6 +72,32 @@ int Graphics::getHeight() return screen->h; } +void Graphics::drawImage(Image *image, int x, int y) +{ + image->draw_deprecated(screen, x, y); +} + +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; + + 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; + image->draw_deprecated(screen, 0, 0, x + px, y + py, dw, dh); + px += iw; + } + py += ih; + px = 0; + } +} + void Graphics::drawImageRect( int x, int y, int w, int h, Image *topLeft, Image *topRight, @@ -81,33 +107,34 @@ void Graphics::drawImageRect( Image *center) { // Draw the center area - center->drawPattern(screen, + drawImagePattern(center, x + topLeft->getWidth(), y + topLeft->getHeight(), w - topLeft->getWidth() - topRight->getWidth(), h - topLeft->getHeight() - bottomLeft->getHeight()); // Draw the sides - top->drawPattern(screen, + drawImagePattern(top, x + topLeft->getWidth(), y, w - topLeft->getWidth() - topRight->getWidth(), top->getHeight()); - bottom->drawPattern(screen, + drawImagePattern(bottom, x + bottomLeft->getWidth(), y + h - bottom->getHeight(), w - bottomLeft->getWidth() - bottomRight->getWidth(), bottom->getHeight()); - left->drawPattern(screen, + drawImagePattern(left, x, y + topLeft->getHeight(), left->getWidth(), h - topLeft->getHeight() - bottomLeft->getHeight()); - right->drawPattern(screen, + drawImagePattern(right, x + w - right->getWidth(), y + topRight->getHeight(), right->getWidth(), h - topRight->getHeight() - bottomRight->getHeight()); // Draw the corners - topLeft->draw(screen, x, y); - topRight->draw(screen, x + w - topRight->getWidth(), y); - bottomLeft->draw(screen, x, y + h - bottomLeft->getHeight()); - bottomRight->draw(screen, + drawImage(topLeft, x, y); + drawImage(topLeft, x, y); + drawImage(topRight, x + w - topRight->getWidth(), y); + drawImage(bottomLeft, x, y + h - bottomLeft->getHeight()); + drawImage(bottomRight, x + w - bottomRight->getWidth(), y + h - bottomRight->getHeight()); } diff --git a/src/graphics.h b/src/graphics.h index 5b57ff8b..662fc83c 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -32,8 +32,6 @@ #endif #include "resources/image.h" -extern SDL_Surface *screen; - /** * 9 images defining a rectangle. 4 corners, 4 sides and a middle area. The * topology is as follows: @@ -74,6 +72,9 @@ class Graphics : public gcn::SDLGraphics { */ ~Graphics(); + void drawImage(Image *image, int x, int y); + void drawImagePattern(Image *image, int x, int y, int w, int h); + /** * Draws a rectangle using images. 4 corner images, 4 side images and 1 * image for the inside. diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index e4db6fab..c2bba9bc 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -464,7 +464,7 @@ void charSelect() gui->logic(); - login_wallpaper->draw(screen, 0, 0); + guiGraphics->drawImage(login_wallpaper, 0, 0); gui->draw(); guiGraphics->updateScreen(); } diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp index bc53b3d3..01b39135 100644 --- a/src/gui/char_server.cpp +++ b/src/gui/char_server.cpp @@ -146,7 +146,7 @@ void char_server() { gui->logic(); - login_wallpaper->draw(screen, 0, 0); + guiGraphics->drawImage(login_wallpaper, 0, 0); gui->draw(); guiGraphics->updateScreen(); } diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp index 2df7a82b..052957ec 100644 --- a/src/gui/checkbox.cpp +++ b/src/gui/checkbox.cpp @@ -85,6 +85,6 @@ void CheckBox::drawBox(gcn::Graphics* graphics) x += 2; y += 2; if (box != NULL) { - box->draw(screen, x, y); + dynamic_cast<Graphics*>(graphics)->drawImage(box, x, y); } } diff --git a/src/gui/equipment.cpp b/src/gui/equipment.cpp index 33786c36..37623637 100644 --- a/src/gui/equipment.cpp +++ b/src/gui/equipment.cpp @@ -55,15 +55,16 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) { int x, y; getAbsolutePosition(x, y); - + // Draw window graphics Window::draw(graphics); - + for (int i = 0; i < 8; i++) { if (equipments[i].id > 0) { - itemset->spriteset[itemDb->getItemInfo( - equipments[i].id)->getImage() - 1]->draw( - screen, x + 36 * (i % 4) + 10, y + 36 * (i / 4) + 25); + Image *image = itemset->spriteset[itemDb->getItemInfo( + equipments[i].id)->getImage() - 1]; + dynamic_cast<Graphics*>(graphics)->drawImage( + image, x + 36 * (i % 4) + 10, y + 36 * (i / 4) + 25); } graphics->setColor(gcn::Color(0, 0, 0)); graphics->drawRectangle(gcn::Rectangle(10 + 36 * (i % 4), @@ -72,8 +73,11 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) graphics->setColor(gcn::Color(0, 0, 0)); graphics->drawRectangle(gcn::Rectangle(160, 25, 32, 32)); if (arrows) { - itemset->spriteset[itemDb->getItemInfo(arrows)->getImage() - 1]->draw( - screen, x + 160, y + 25); + Image *image = itemset->spriteset[ + itemDb->getItemInfo(arrows)->getImage() - 1]; + + dynamic_cast<Graphics*>(graphics)->drawImage( + image, x + 160, y + 25); std::stringstream n; n << arrowsNumber; graphics->drawText(n.str(), 170, 62, diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index ce8f428b..cf98dde9 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -81,7 +81,8 @@ Gui::Gui(Graphics *graphics): // Initialize top GUI widget guiTop = new WindowContainer(); - guiTop->setDimension(gcn::Rectangle(0, 0, screen->w, screen->h)); + guiTop->setDimension(gcn::Rectangle(0, 0, + graphics->getWidth(), graphics->getHeight())); guiTop->setOpaque(false); guiTop->addMouseListener(this); Window::setWindowContainer(guiTop); @@ -214,7 +215,7 @@ void Gui::draw() if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS || button & SDL_BUTTON(1)) && mCustomCursor) { - mMouseCursor->draw(screen, mouseX - 5, mouseY - 2); + guiGraphics->drawImage(mMouseCursor, mouseX - 5, mouseY - 2); } guiGraphics->popClipArea(); diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 0ccfc3db..534364dc 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -95,15 +95,17 @@ void ItemContainer::draw(gcn::Graphics* graphics) // Draw selection image below selected item if (selectedItem == i) { - selImg->draw(screen, x + itemX, y + itemY); + dynamic_cast<Graphics*>(graphics)->drawImage( + selImg, x + itemX, y + itemY); } // Draw item icon if (itemDb->getItemInfo(items[i].id)->getImage() > 0) { - itemset->spriteset[itemDb->getItemInfo( - items[i].id)->getImage() - 1]->draw( - screen, x + itemX, y + itemY); + Image *image = itemset->spriteset[itemDb->getItemInfo( + items[i].id)->getImage() - 1]; + dynamic_cast<Graphics*>(graphics)->drawImage( + image, x + itemX, y + itemY); } // Draw item caption diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 9f3b230e..38bcf6b3 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -205,7 +205,7 @@ void login() gui->logic(); - login_wallpaper->draw(screen, 0, 0); + guiGraphics->drawImage(login_wallpaper, 0, 0); gui->draw(); guiGraphics->updateScreen(); } diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 8ce7ffd7..98392adf 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -73,7 +73,8 @@ void Minimap::draw(gcn::Graphics *graphics) if (mMapImage != NULL) { - mMapImage->draw(screen, x + getPadding(), y + getTitleBarHeight()); + dynamic_cast<Graphics*>(graphics)->drawImage( + mMapImage, x + getPadding(), y + getTitleBarHeight()); } std::list<Being*>::iterator bi; diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp index c62596fc..a94e7c4b 100644 --- a/src/gui/playerbox.cpp +++ b/src/gui/playerbox.cpp @@ -81,7 +81,8 @@ void PlayerBox::draw(gcn::Graphics *graphics) getAbsolutePosition(x, y); // Draw character - playerset->spriteset[0]->draw(screen, x + 23, y + 23); + dynamic_cast<Graphics*>(graphics)->drawImage( + playerset->spriteset[0], x + 23, y + 23); // Draw his hair if (hairColor >= 0 && hairStyle >= 0 && @@ -89,7 +90,8 @@ void PlayerBox::draw(gcn::Graphics *graphics) { int hf = hairColor + 40 * (hairStyle); if (hf >= 0 && hf < (int)hairset->spriteset.size()) { - hairset->spriteset[hf]->draw(screen, x + 37, y + 5); + dynamic_cast<Graphics*>(graphics)->drawImage( + hairset->spriteset[hf], x + 37, y + 5); } } } diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 5e8294a1..ea8034d8 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -29,6 +29,9 @@ #include "../resources/itemmanager.h" #include <iostream> +// TODO Remove this once setVisible doesn't need it anymore +extern SDL_Surface *screen; + PopupMenu::PopupMenu(): Window() { diff --git a/src/gui/radiobutton.cpp b/src/gui/radiobutton.cpp index 4b3a439e..7eae469f 100644 --- a/src/gui/radiobutton.cpp +++ b/src/gui/radiobutton.cpp @@ -82,6 +82,6 @@ void RadioButton::drawBox(gcn::Graphics* graphics) x += 2; y += 2; if (box != NULL) { - box->draw(screen, x, y); + dynamic_cast<Graphics*>(graphics)->drawImage(box, x, y); } } diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index cfefe898..863f8a85 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -266,7 +266,8 @@ void ScrollArea::drawButton(gcn::Graphics *graphics, BUTTON_DIR dir) break; } - buttons[dir][state]->draw(screen, x + dim.x, y + dim.y); + dynamic_cast<Graphics*>(graphics)->drawImage( + buttons[dir][state], x + dim.x, y + dim.y); } void ScrollArea::drawUpButton(gcn::Graphics *graphics) diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index a9421874..eb9121bc 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -34,6 +34,8 @@ #define SETUP_WIDTH 240 +extern SDL_Surface *screen; + ModeListModel::ModeListModel() { SDL_Rect **modes; diff --git a/src/gui/slider.cpp b/src/gui/slider.cpp index 6bbe1bed..2d4e6c78 100644 --- a/src/gui/slider.cpp +++ b/src/gui/slider.cpp @@ -108,15 +108,16 @@ void Slider::draw(gcn::Graphics *graphics) y += (h - hStart->getHeight()) / 2; - hStart->draw(screen, x, y); + dynamic_cast<Graphics*>(graphics)->drawImage(hStart, x, y); w -= hStart->getWidth() + hEnd->getWidth(); x += hStart->getWidth(); - hMid->drawPattern(screen, x, y, w, hMid->getHeight()); + dynamic_cast<Graphics*>(graphics)->drawImagePattern( + hMid, x, y, w, hMid->getHeight()); x += w; - hEnd->draw(screen, x, y); + dynamic_cast<Graphics*>(graphics)->drawImage(hEnd, x, y); drawMarker(graphics); } @@ -130,5 +131,5 @@ void Slider::drawMarker(gcn::Graphics *graphics) x += getMarkerPosition(); y += (h - hGrip->getHeight()) / 2; - hGrip->draw(screen, x, y); + dynamic_cast<Graphics*>(graphics)->drawImage(hGrip, x, y); } diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index 044a1a5c..0dd34854 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -346,7 +346,7 @@ void updateData() gui->logic(); - login_wallpaper->draw(screen, 0, 0); + guiGraphics->drawImage(login_wallpaper, 0, 0); gui->draw(); guiGraphics->updateScreen(); } diff --git a/src/gui/window.cpp b/src/gui/window.cpp index fdbeb699..e6a55ea0 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -26,6 +26,9 @@ #include "../log.h" #include "../main.h" +// TODO Check if we can get rid of this +extern SDL_Surface *screen; + WindowContainer *Window::windowContainer = NULL; int Window::instances = 0; ImageRect Window::border; diff --git a/src/main.cpp b/src/main.cpp index 2efcc519..1f2ac73f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -58,6 +58,9 @@ #include <errno.h> #endif +// TODO Check if we can get rid of this +extern SDL_Surface *screen; + // Account infos int account_ID, session_ID1, session_ID2; char sex, n_server, n_character; @@ -433,7 +436,7 @@ int main(int argc, char *argv[]) break; case ERROR: // Redraw GUI - login_wallpaper->draw(screen, 0, 0); + graphics->drawImage(login_wallpaper, 0 ,0); gui->logic(); gui->draw(); graphics->updateScreen(); diff --git a/src/map.cpp b/src/map.cpp index 5970d5a9..9e3aedda 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -96,7 +96,7 @@ Map::draw(Graphics *graphics, int scrollX, int scrollY, int layer) { Image *img = getTile(x, y, layer); if (img) { - img->draw(screen, x * 32 - scrollX, y * 32 - scrollY); + graphics->drawImage(img, x * 32 - scrollX, y * 32 - scrollY); } } } 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; |