3
* Copyright (C) 2004-2009 The Mana World Development Team
4
* Copyright (C) 2009-2010 The Mana Developers
5
* Copyright (C) 2011-2013 The ManaPlus Developers
7
* This file is part of The ManaPlus Client.
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
#ifndef RENDER_SAFEOPENGLGRAPHICS_H
24
#define RENDER_SAFEOPENGLGRAPHICS_H
27
#if defined USE_OPENGL && !defined ANDROID
29
#include "render/graphics.h"
31
#include "resources/fboinfo.h"
35
#include <GLES/glext.h>
38
#define GL_GLEXT_PROTOTYPES 1
40
#include <SDL_opengl.h>
44
class SafeOpenGLGraphics final : public Graphics
49
A_DELETE_COPY(SafeOpenGLGraphics)
51
~SafeOpenGLGraphics();
53
bool setVideoMode(const int w, const int h, const int bpp,
54
const bool fs, const bool hwaccel,
55
const bool resize, const bool noFrame) override;
58
* Draws a resclaled version of the image
60
bool drawRescaledImage(const Image *const image, int srcX, int srcY,
62
const int width, const int height,
63
const int desiredWidth, const int desiredHeight,
64
const bool useColor) override;
67
* Used to get the smooth rescale option over the standard function.
69
bool drawRescaledImage(const Image *const image, int srcX, int srcY,
71
const int width, const int height,
72
const int desiredWidth, const int desiredHeight,
73
const bool useColor, bool smooth);
75
void drawImagePattern(const Image *const image,
76
const int x, const int y,
77
const int w, const int h) override;
80
* Draw a pattern based on a rescaled version of the given image...
82
void drawRescaledImagePattern(const Image *const image,
83
const int x, const int y,
84
const int w, const int h,
85
const int scaledWidth,
86
const int scaledHeight) override;
88
void calcTile(ImageVertexes *const vert, const Image *const image,
89
int x, int y) const override;
91
void calcTile(ImageCollection *const vertCol,
92
const Image *const image, int x, int y) override;
94
void calcImagePattern(ImageVertexes *const vert,
95
const Image *const image,
96
const int x, const int y,
97
const int w, const int h) const;
99
void calcImagePattern(ImageCollection *const vert,
100
const Image *const image,
101
const int x, const int y,
102
const int w, const int h) const;
104
void drawTile(const ImageVertexes *const vert) override;
106
void drawTile(const ImageCollection *const vertCol) override;
108
void updateScreen() override;
110
bool calcWindow(ImageCollection *const vertCol,
111
const int x, const int y,
112
const int w, const int h,
113
const ImageRect &imgRect);
119
bool pushClipArea(gcn::Rectangle area);
123
void setColor(const gcn::Color &color)
127
mColorAlpha = (color.a != 255);
130
void setColorAll(const gcn::Color &color, const gcn::Color &color2)
134
mColorAlpha = (color.a != 255);
137
void drawPoint(int x, int y);
139
void drawLine(int x1, int y1, int x2, int y2);
141
void drawRectangle(const gcn::Rectangle &rect, const bool filled);
143
void drawRectangle(const gcn::Rectangle &rect);
145
void fillRectangle(const gcn::Rectangle &rect) override;
147
void setTargetPlane(int width, int height);
150
* Takes a screenshot and returns it as SDL surface.
152
SDL_Surface *getScreenshot() override A_WARN_UNUSED;
154
void prepareScreenshot() override;
156
static void bindTexture(const GLenum target, const GLuint texture);
158
static GLuint mLastImage;
161
bool drawImage2(const Image *const image,
164
const int width, const int height,
165
const bool useColor);
167
void setTexturingAndBlending(const bool enable);
170
void inline setColorAlpha(float alpha);
172
void inline restoreColor();
176
gcn::Color mByteColor;
183
#endif // RENDER_SAFEOPENGLGRAPHICS_H