25 #include <guichan/opengl.hpp>
26 #include <guichan/font.hpp>
27 #include <guichan/exception.hpp>
33 #include "video/image.h"
34 #include "gui/base/gui_image.h"
35 #include "util/structures/rect.h"
36 #include "video/opengl/fife_opengl.h"
38 #include "opengl_gui_graphics.h"
42 mTarget = SDL_GetVideoSurface();
44 setTargetPlane(mTarget->w, mTarget->h);
48 void OpenGLGuiGraphics::drawImage(
const gcn::Image* image,
int srcX,
int srcY,
int dstX,
int dstY,
int width,
int height) {
49 const GuiImage* g_img =
dynamic_cast<const GuiImage*
>(image);
51 Image& fifeimg = m_pool.getImage(g_img->getPoolId());
52 const gcn::ClipRectangle& clip = getCurrentClipArea();
53 Rect rect(dstX, dstY, width, height);
54 rect.x += clip.xOffset;
55 rect.y += clip.yOffset;
56 GLEnable flag(GL_TEXTURE_2D);
57 fifeimg.
render(rect, mTarget);
60 void OpenGLGuiGraphics::drawText(
const std::string& text,
int x,
int y,
61 unsigned int alignment) {
64 throw GCN_EXCEPTION(
"No font set.");
67 GLEnable flag(GL_TEXTURE_2D);
71 mFont->drawString(
this, text, x, y);
74 mFont->drawString(
this, text, x - mFont->getWidth(text) / 2, y);
77 mFont->drawString(
this, text, x - mFont->getWidth(text), y);
80 throw GCN_EXCEPTION(
"Unknown alignment.");
84 void OpenGLGuiGraphics::drawPoint(
int x,
int y) {
85 GLDisable flag(GL_TEXTURE_2D);
86 gcn::OpenGLGraphics::drawPoint(x, y);
89 void OpenGLGuiGraphics::drawLine(
int x1,
int y1,
int x2,
int y2) {
90 GLDisable flag(GL_TEXTURE_2D);
91 gcn::OpenGLGraphics::drawLine(x1, y1, x2, y2);
94 void OpenGLGuiGraphics::drawRectangle(
const gcn::Rectangle& rectangle) {
95 GLDisable flag(GL_TEXTURE_2D);
96 gcn::OpenGLGraphics::drawRectangle(rectangle);