FifeGUI 0.2.0
A C++ GUI library designed for games.
backends/opengl/graphics.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later OR BSD-3-Clause
2// SPDX-FileCopyrightText: 2004 - 2008 Olof Naessén and Per Larsson
3// SPDX-FileCopyrightText: 2013 - 2026 Fifengine contributors
4
5#ifndef INCLUDE_FIFECHAN_BACKENDS_OPENGL_GRAPHICS_HPP_
6#define INCLUDE_FIFECHAN_BACKENDS_OPENGL_GRAPHICS_HPP_
7
8#include "fifechan/backends/opengl/image.hpp"
9#include "fifechan/color.hpp"
10#include "fifechan/graphics.hpp"
11#include "fifechan/platform.hpp"
12
13namespace fcn::opengl
14{
20 class FIFEGUI_EXT_API Graphics : public fcn::Graphics
21 {
22 public:
24
28 Graphics();
29
39 Graphics(int width, int height);
40
41 ~Graphics() override;
42
43 Graphics(Graphics const &) = delete;
44 Graphics& operator=(Graphics const &) = delete;
45 Graphics(Graphics&&) = delete;
46 Graphics& operator=(Graphics&&) = delete;
47
56 virtual void setTargetPlane(int width, int height);
57
63 virtual int getTargetPlaneWidth() const;
64
70 virtual int getTargetPlaneHeight() const;
71
72 // Inherited from Graphics
73
74 void _beginDraw() override;
75
76 void _endDraw() override;
77
78 bool pushClipArea(Rectangle area) override;
79
80 void popClipArea() override;
81
82 void drawImage(
83 fcn::Image const * image, int srcX, int srcY, int dstX, int dstY, int width, int height) override;
84
96 void drawImage(fcn::opengl::Image const * image, int srcX, int srcY, int dstX, int dstY, int width, int height);
97
98 void drawPoint(int x, int y) override;
99
100 void drawLine(int x1, int y1, int x2, int y2) override;
101
102 void drawLine(int x1, int y1, int x2, int y2, unsigned int width) override;
103
104 void drawPolyLine(PointVector const & points, unsigned int width) override;
105
106 void drawBezier(PointVector const & points, int steps, unsigned int width) override;
107
108 void drawRectangle(Rectangle const & rectangle) override;
109
110 void fillRectangle(Rectangle const & rectangle) override;
111
112 void drawCircle(Point const & p, unsigned int radius) override;
113
114 void drawFillCircle(Point const & p, unsigned int radius) override;
115
116 void drawCircleSegment(Point const & p, unsigned int radius, int sangle, int eangle) override;
117
118 void drawFillCircleSegment(Point const & p, unsigned int radius, int sangle, int eangle) override;
119
120 void setColor(Color const & color) override;
121
122 Color const & getColor() const override;
123
124 protected:
126 int mWidth{};
127
129 int mHeight{};
130
132 bool mAlpha{};
133
136 };
137} // namespace fcn::opengl
138
139namespace fcn
140{
141 using OpenGLGraphics = fcn::opengl::Graphics;
142}
143
144#endif // INCLUDE_FIFECHAN_BACKENDS_OPENGL_GRAPHICS_HPP_
Color.
Definition color.hpp:56
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
Definition graphics.hpp:57
virtual void drawImage(Image const *image, int srcX, int srcY, int dstX, int dstY, int width, int height)=0
Draws a part of an image.
Abstract holder for image data.
Definition image.hpp:32
Represents a 2D coordinate (X, Y).
Definition point.hpp:29
Represents a rectangular area (X, Y, Width, Height).
Definition rectangle.hpp:20
OpenGL-specific implementation of the Graphics interface.
void setColor(Color const &color) override
Sets the color to use when drawing.
void drawFillCircle(Point const &p, unsigned int radius) override
Draws a filled circle.
void drawCircleSegment(Point const &p, unsigned int radius, int sangle, int eangle) override
Draws a simple, non-filled circle segment with a one pixel width.
void _beginDraw() override
Initializes drawing.
void drawLine(int x1, int y1, int x2, int y2) override
Draws a line.
void drawCircle(Point const &p, unsigned int radius) override
Draws a simple, non-filled circle with a one pixel width.
bool mAlpha
Whether alpha blending is enabled.
void drawBezier(PointVector const &points, int steps, unsigned int width) override
Draws a bezier curve.
void drawRectangle(Rectangle const &rectangle) override
Draws a simple, non-filled rectangle with a one pixel width.
void drawFillCircleSegment(Point const &p, unsigned int radius, int sangle, int eangle) override
Draws a filled circle segment.
void drawImage(fcn::opengl::Image const *image, int srcX, int srcY, int dstX, int dstY, int width, int height)
Draws an OpenGL-specific image.
void popClipArea() override
Removes the top most clip area from the stack.
void drawPoint(int x, int y) override
Draws a single point/pixel.
Color mColor
Current drawing color.
void _endDraw() override
Deinitializes the drawing process.
void fillRectangle(Rectangle const &rectangle) override
Draws a filled rectangle.
void drawImage(fcn::Image const *image, int srcX, int srcY, int dstX, int dstY, int width, int height) override
Draws a part of an image.
int mWidth
Width of the logical target plane.
void drawPolyLine(PointVector const &points, unsigned int width) override
Draws lines between points with given width.
virtual void setTargetPlane(int width, int height)
Sets the target plane on where to draw.
virtual int getTargetPlaneWidth() const
Gets the target plane width.
int mHeight
Height of the logical target plane.
virtual int getTargetPlaneHeight() const
Gets the target plane height.
Color const & getColor() const override
Gets the color to use when drawing.
bool pushClipArea(Rectangle area) override
Pushes a clip area onto the stack.
OpenGL-specific implementation of Image.