29#include <SDL_opengl.h>
35class OpenGLGraphics final :
public Graphics
38 static std::unique_ptr<OpenGLGraphics> create(SDL_Window *window,
41 OpenGLGraphics(SDL_Window *window, SDL_GLContext glContext);
43 ~OpenGLGraphics()
override;
54 void setReduceInputLag(
bool reduceInputLag);
55 bool getReduceInputLag()
const {
return mReduceInputLag; }
57 void updateSize(
int windowWidth,
int windowHeight,
float scale)
override;
64 int width,
int height,
65 int desiredWidth,
int desiredHeight,
66 bool useColor)
override;
70 float dstX,
float dstY,
71 int width,
int height,
72 float desiredWidth,
float desiredHeight,
73 bool useColor)
override;
77 int w,
int h)
override;
87 int scaledWidth,
int scaledHeight)
override;
92 float &logicalX,
float &logicalY)
const override;
94 bool pushClipArea(gcn::Rectangle area)
override;
95 void popClipArea()
override;
97 void setColor(
const gcn::Color &color)
override;
99 void drawPoint(
int x,
int y)
override;
101 void drawLine(
int x1,
int y1,
int x2,
int y2)
override;
103 void drawRectangle(
const gcn::Rectangle &rect,
bool filled);
105 void drawRectangle(
const gcn::Rectangle &rect)
override;
107 void fillRectangle(
const gcn::Rectangle &rect)
override;
114 static void bindTexture(GLenum target, GLuint texture);
116 static GLuint mLastImage;
119 void setTexturingAndBlending(
bool enable);
124 void drawQuadArrayfi(
int size);
126 void drawQuadArrayii(
int size);
128 SDL_Window *mWindow =
nullptr;
129 SDL_GLContext mContext =
nullptr;
130 GLfloat *mFloatTexArray;
132 GLint *mIntVertArray;
133 float mUserScale = 1.0f;
134 float mScaleX = 1.0f;
135 float mScaleY = 1.0f;
137 bool mTexture =
false;
138 bool mColorAlpha =
false;
139 bool mReduceInputLag =
true;
A central point of control for graphics.
virtual void updateScreen()=0
Updates the screen.
virtual void drawImagePattern(const Image *image, int x, int y, int w, int h)
bool drawRescaledImage(const Image *image, int x, int y, int width, int height)
Draws a rescaled version of the image.
virtual SDL_Surface * getScreenshot()=0
Takes a screenshot and returns it as SDL surface.
void drawRescaledImagePattern(const Image *image, int x, int y, int w, int h, int scaledWidth, int scaledHeight)
Draw a pattern based on a rescaled version of the given image.
void setColor(const gcn::Color &color) override
virtual void updateClipRect()=0
virtual void windowToLogical(int windowX, int windowY, float &logicalX, float &logicalY) const =0
Converts a window coordinate to a logical coordinate.
virtual void updateSize(int width, int height, float scale)
Called when the window size or scale has changed.
virtual void setVSync(bool sync)=0
Sets whether vertical refresh syncing is enabled.
virtual bool drawRescaledImageF(const Image *image, int srcX, int srcY, float dstX, float dstY, int width, int height, float desiredWidth, float desiredHeight, bool useColor=false)
Draws a rescaled version of the image.
Defines a class for loading and storing images.