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_NULLOPENGLGRAPHICS_H
24
#define RENDER_NULLOPENGLGRAPHICS_H
27
#if defined USE_OPENGL
29
#include "localconsts.h"
30
#include "render/graphics.h"
32
#include "resources/fboinfo.h"
36
#include <GLES/glext.h>
37
#include <GLES2/gl2.h>
40
#define GL_GLEXT_PROTOTYPES 1
42
#include <SDL_opengl.h>
48
class NormalOpenGLGraphicsVertexes;
50
class NullOpenGLGraphics final : public Graphics
55
A_DELETE_COPY(NullOpenGLGraphics)
57
~NullOpenGLGraphics();
59
bool setVideoMode(const int w, const int h, const int bpp,
60
const bool fs, const bool hwaccel,
61
const bool resize, const bool noFrame) override;
65
* Draws a resclaled version of the image
67
bool drawRescaledImage(const Image *const image, int srcX, int srcY,
69
const int width, const int height,
70
const int desiredWidth, const int desiredHeight,
71
const bool useColor) override;
74
* Used to get the smooth rescale option over the standard function.
76
bool drawRescaledImage(const Image *const image, int srcX, int srcY,
78
const int width, const int height,
79
const int desiredWidth, const int desiredHeight,
80
const bool useColor, bool smooth);
82
void drawImagePattern(const Image *const image,
83
const int x, const int y,
84
const int w, const int h) override;
87
* Draw a pattern based on a rescaled version of the given image...
89
void drawRescaledImagePattern(const Image *const image,
90
const int x, const int y,
91
const int w, const int h,
92
const int scaledWidth,
93
const int scaledHeight) override;
95
void calcImagePattern(ImageVertexes* const vert,
96
const Image *const image,
97
const int x, const int y,
98
const int w, const int h) const override;
100
void calcImagePattern(ImageCollection* const vert,
101
const Image *const image,
102
const int x, const int y,
103
const int w, const int h) const override;
105
void calcTile(ImageVertexes *const vert, const Image *const image,
106
int x, int y) const override;
108
void calcTile(ImageCollection *const vertCol,
109
const Image *const image, int x, int y) override;
111
void drawTile(const ImageCollection *const vertCol) override;
113
void drawTile(const ImageVertexes *const vert) override;
115
bool calcWindow(ImageCollection *const vertCol,
116
const int x, const int y,
117
const int w, const int h,
118
const ImageRect &imgRect) override;
120
void updateScreen() override;
126
bool pushClipArea(gcn::Rectangle area);
130
void setColor(const gcn::Color &color)
134
mColorAlpha = (color.a != 255);
137
void setColorAll(const gcn::Color &color, const gcn::Color &color2)
141
mColorAlpha = (color.a != 255);
144
void drawPoint(int x, int y);
146
void drawLine(int x1, int y1, int x2, int y2);
148
void drawRectangle(const gcn::Rectangle &rect, const bool filled);
150
void drawRectangle(const gcn::Rectangle &rect);
152
void fillRectangle(const gcn::Rectangle &rect);
154
void setTargetPlane(int width, int height);
156
inline void drawQuadArrayfi(const int size);
158
inline void drawQuadArrayfi(const GLint *const intVertArray,
159
const GLfloat *const floatTexArray,
162
inline void drawQuadArrayii(const int size);
164
inline void drawQuadArrayii(const GLint *const intVertArray,
165
const GLint *const intTexArray,
168
inline void drawLineArrayi(const int size);
170
inline void drawLineArrayf(const int size);
172
inline void drawVertexes(const NormalOpenGLGraphicsVertexes &ogl);
174
void initArrays() override;
176
static void dumpSettings();
179
* Takes a screenshot and returns it as SDL surface.
181
SDL_Surface *getScreenshot() override A_WARN_UNUSED;
183
void prepareScreenshot() override;
185
bool drawNet(const int x1, const int y1, const int x2, const int y2,
186
const int width, const int height) override;
188
int getMemoryUsage() A_WARN_UNUSED;
190
void updateTextureFormat();
192
#ifdef DEBUG_DRAW_CALLS
193
virtual unsigned int getDrawCalls() const
194
{ return mLastDrawCalls; }
196
static unsigned int mDrawCalls;
198
static unsigned int mLastDrawCalls;
201
static void bindTexture(const GLenum target, const GLuint texture);
203
static GLuint mLastImage;
206
bool drawImage2(const Image *const image,
209
const int width, const int height,
210
const bool useColor) override;
212
void setTexturingAndBlending(const bool enable);
214
void debugBindTexture(const Image *const image);
217
void inline setColorAlpha(float alpha);
219
void inline restoreColor();
221
GLfloat *mFloatTexArray;
223
GLint *mIntVertArray;
227
gcn::Color mByteColor;
231
#ifdef DEBUG_BIND_TEXTURE
232
std::string mOldTexture;
233
unsigned mOldTextureId;
239
#endif // RENDER_NULLOPENGLGRAPHICS_H