28 #include <fifechan/opengl.hpp>
29 #include <fifechan/font.hpp>
49 SDL_Surface* target = SDL_GetVideoSurface();
51 setTargetPlane(target->w, target->h);
52 mColor = fcn::Color(255, 255, 255, 255);
56 void OpenGLGuiGraphics::drawImage(
const fcn::Image* image, int32_t srcX, int32_t srcY, int32_t dstX, int32_t dstY, int32_t width, int32_t height) {
61 const fcn::ClipRectangle& clip = mClipStack.top();
62 fifeimg->
render(
Rect(dstX + clip.xOffset, dstY + clip.yOffset,
70 throw GuiException(
"OpenGLGuiGraphics::drawText() - No font set!");
76 mFont->drawString(
this, text, x, y);
79 mFont->drawString(
this, text, x - mFont->getWidth(text) / 2, y);
82 mFont->drawString(
this, text, x - mFont->getWidth(text), y);
85 FL_WARN(
_log,
LMsg(
"OpenGLGuiGraphics::drawText() - ") <<
"Unknown alignment: " << alignment);
86 mFont->drawString(
this, text, x, y);
91 const fcn::ClipRectangle& top = mClipStack.top();
93 mColor.r, mColor.g, mColor.b, mColor.a);
97 const fcn::ClipRectangle& top = mClipStack.top();
103 Point pbegin(static_cast<int32_t>(ceil(x1 + 0.375f)), static_cast<int32_t>(ceil(y1 + 0.375f)));
104 Point pend(static_cast<int32_t>(ceil(x2 + 0.625f)), static_cast<int32_t>(ceil(y2 + 0.625f)));
107 mColor.r, mColor.g, mColor.b, mColor.a);
109 mColor.r, mColor.g, mColor.b, mColor.a);
111 mColor.r, mColor.g, mColor.b, mColor.a);
115 const fcn::ClipRectangle& top = mClipStack.top();
117 Point(rectangle.x + top.xOffset, rectangle.y + top.yOffset),
118 rectangle.width, rectangle.height,
119 mColor.r, mColor.g, mColor.b, mColor.a);
123 const fcn::ClipRectangle& top = mClipStack.top();
125 Point(rectangle.x + top.xOffset, rectangle.y + top.yOffset),
126 rectangle.width, rectangle.height,
127 mColor.r, mColor.g, mColor.b, mColor.a);
131 fcn::Rectangle area(0, 0, mWidth, mHeight);
132 fcn::Graphics::pushClipArea(area);
140 fcn::Graphics::popClipArea();
147 fcn::Graphics::pushClipArea(area);
152 const fcn::ClipRectangle& top = mClipStack.top();
155 Rect(top.x, top.y, top.width, top.height),
false);
163 fcn::Graphics::popClipArea();
#define FL_WARN(logger, msg)
virtual void fillRectangle(const Point &p, uint16_t w, uint16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Draws a filled axis parallel rectangle.
Helper class to create log strings out from separate parts Usage: LMsg("some text") << variable << "...
virtual void setColor(const fcn::Color &color)
virtual void fillRectangle(const fcn::Rectangle &rectangle)
virtual void renderVertexArrays()
Render the Vertex Arrays, only for primitives (points, lines,...)
virtual void drawRectangle(const fcn::Rectangle &rectangle)
virtual void drawImage(const fcn::Image *image, int32_t srcX, int32_t srcY, int32_t dstX, int32_t dstY, int32_t width, int32_t height)
virtual void _beginDraw()
virtual bool putPixel(int32_t x, int32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Writes pixel to given position.
static Logger _log(LM_AUDIO)
virtual void drawLine(const Point &p1, const Point &p2, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Draws line between given points with given RGBA.
static RenderBackend * instance()
virtual void drawLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
PointType2D< int32_t > Point
void pushClipArea(const Rect &cliparea, bool clear=true)
Pushes clip area to clip stack Clip areas define which area is drawn on screen.
void popClipArea()
Pops clip area from clip stack.
virtual void popClipArea()
virtual void render(const Rect &rect, uint8_t alpha=255, uint8_t const *rgb=0)=0
Renders itself to the current render target (main screen or attached destination image) at the rectan...
RenderBackendOpenGL * m_renderbackend
virtual void drawText(const std::string &text, int32_t x, int32_t y, uint32_t alignment)
virtual bool pushClipArea(fcn::Rectangle area)
ImagePtr getFIFEImage() const
virtual void drawRectangle(const Point &p, uint16_t w, uint16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Draws an axis parallel rectangle.
virtual void drawPoint(int32_t x, int32_t y)
The main class of the OpenGL-based renderer.
OpenGLGuiGraphics()
Constructor.