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_MOBILEOPENGLGRAPHICS_H
24
#define RENDER_MOBILEOPENGLGRAPHICS_H
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 MobileOpenGLGraphics final : public Graphics
53
MobileOpenGLGraphics();
55
A_DELETE_COPY(MobileOpenGLGraphics)
57
~MobileOpenGLGraphics();
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 drawTile(const ImageCollection *const vertCol);
110
void calcTile(ImageCollection *const vertCol,
111
const Image *const image, int x, int y) 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);
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 drawTriangleArrayfs(const GLshort *const shortVertArray,
157
const GLfloat *const floatTexArray,
160
inline void drawTriangleArrayfs(const int size);
162
inline void drawLineArrays(const int size);
164
inline void drawVertexes(const NormalOpenGLGraphicsVertexes &ogl);
166
void initArrays() override;
168
static void dumpSettings();
171
* Takes a screenshot and returns it as SDL surface.
173
SDL_Surface *getScreenshot() override A_WARN_UNUSED;
175
void prepareScreenshot() override;
177
bool drawNet(const int x1, const int y1, const int x2, const int y2,
178
const int width, const int height) override;
180
int getMemoryUsage();
182
void updateTextureFormat();
184
#ifdef DEBUG_DRAW_CALLS
185
virtual unsigned int getDrawCalls() const
186
{ return mLastDrawCalls; }
188
static unsigned int mDrawCalls;
190
static unsigned int mLastDrawCalls;
193
static void bindTexture(const GLenum target, const GLuint texture);
195
static GLuint mLastImage;
198
bool drawImage2(const Image *const image,
201
const int width, const int height,
202
const bool useColor) override;
204
void setTexturingAndBlending(const bool enable);
206
void debugBindTexture(const Image *image);
209
void inline setColorAlpha(float alpha);
211
void inline restoreColor();
213
GLfloat *mFloatTexArray;
215
GLint *mIntVertArray;
216
GLshort *mShortVertArray;
220
gcn::Color mByteColor;
224
#ifdef DEBUG_BIND_TEXTURE
225
std::string mOldTexture;
226
unsigned mOldTextureId;
232
#endif // RENDER_MOBILEOPENGLGRAPHICS_H