~ubuntu-branches/ubuntu/trusty/manaplus/trusty-proposed

« back to all changes in this revision

Viewing changes to src/normalopenglgraphics.h

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-09-17 10:35:51 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20130917103551-az7p3nz9jgxwqjfn
Tags: 1.3.9.15-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  The ManaPlus Client
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
6
 
 *
7
 
 *  This file is part of The ManaPlus Client.
8
 
 *
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
12
 
 *  any later version.
13
 
 *
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.
18
 
 *
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/>.
21
 
 */
22
 
 
23
 
#ifndef NORMALOPENGLGRAPHICS_H
24
 
#define NORMALOPENGLGRAPHICS_H
25
 
 
26
 
#include "main.h"
27
 
#if defined USE_OPENGL && !defined ANDROID
28
 
 
29
 
#include "localconsts.h"
30
 
#include "graphics.h"
31
 
 
32
 
#include "resources/fboinfo.h"
33
 
 
34
 
#ifdef ANDROID
35
 
#include <GLES/gl.h>
36
 
#include <GLES/glext.h>
37
 
#include <GLES2/gl2.h>
38
 
#else
39
 
#ifndef USE_SDL2
40
 
#define GL_GLEXT_PROTOTYPES 1
41
 
#endif
42
 
#include <SDL_opengl.h>
43
 
#include <GL/glext.h>
44
 
#endif
45
 
 
46
 
#include <set>
47
 
 
48
 
class NormalOpenGLGraphicsVertexes;
49
 
 
50
 
class NormalOpenGLGraphics final : public Graphics
51
 
{
52
 
    public:
53
 
        NormalOpenGLGraphics();
54
 
 
55
 
        A_DELETE_COPY(NormalOpenGLGraphics)
56
 
 
57
 
        ~NormalOpenGLGraphics();
58
 
 
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;
62
 
 
63
 
 
64
 
        /**
65
 
         * Draws a resclaled version of the image
66
 
         */
67
 
        bool drawRescaledImage(const Image *const image, int srcX, int srcY,
68
 
                               int dstX, int dstY,
69
 
                               const int width, const int height,
70
 
                               const int desiredWidth, const int desiredHeight,
71
 
                               const bool useColor) override;
72
 
 
73
 
        /**
74
 
         * Used to get the smooth rescale option over the standard function.
75
 
         */
76
 
        bool drawRescaledImage(const Image *const image, int srcX, int srcY,
77
 
                               int dstX, int dstY,
78
 
                               const int width, const int height,
79
 
                               const int desiredWidth, const int desiredHeight,
80
 
                               const bool useColor, bool smooth);
81
 
 
82
 
        void drawImagePattern(const Image *const image,
83
 
                              const int x, const int y,
84
 
                              const int w, const int h) override;
85
 
 
86
 
        /**
87
 
         * Draw a pattern based on a rescaled version of the given image...
88
 
         */
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;
94
 
 
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;
99
 
 
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;
104
 
 
105
 
        void calcTile(ImageVertexes *const vert, const Image *const image,
106
 
                      int x, int y) const override;
107
 
 
108
 
        void calcTile(ImageCollection *const vertCol,
109
 
                      const Image *const image, int x, int y) override;
110
 
 
111
 
        void drawTile(const ImageCollection *const vertCol) override;
112
 
 
113
 
        void drawTile(const ImageVertexes *const vert) override;
114
 
 
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;
119
 
 
120
 
        void updateScreen() override;
121
 
 
122
 
        void _beginDraw();
123
 
 
124
 
        void _endDraw();
125
 
 
126
 
        bool pushClipArea(gcn::Rectangle area);
127
 
 
128
 
        void popClipArea();
129
 
 
130
 
        void setColor(const gcn::Color &color)
131
 
        {
132
 
            mColor = color;
133
 
            mColor2 = color;
134
 
            mColorAlpha = (color.a != 255);
135
 
        }
136
 
 
137
 
        void setColorAll(const gcn::Color &color, const gcn::Color &color2)
138
 
        {
139
 
            mColor = color;
140
 
            mColor2 = color2;
141
 
            mColorAlpha = (color.a != 255);
142
 
        }
143
 
 
144
 
        void drawPoint(int x, int y);
145
 
 
146
 
        void drawLine(int x1, int y1, int x2, int y2);
147
 
 
148
 
        void drawRectangle(const gcn::Rectangle &rect, const bool filled);
149
 
 
150
 
        void drawRectangle(const gcn::Rectangle &rect);
151
 
 
152
 
        void fillRectangle(const gcn::Rectangle &rect);
153
 
 
154
 
        void setTargetPlane(int width, int height);
155
 
 
156
 
        inline void drawQuadArrayfi(const int size);
157
 
 
158
 
        inline void drawQuadArrayfi(const GLint *const intVertArray,
159
 
                                    const GLfloat *const floatTexArray,
160
 
                                    const int size);
161
 
 
162
 
        inline void drawQuadArrayii(const int size);
163
 
 
164
 
        inline void drawQuadArrayii(const GLint *const intVertArray,
165
 
                                    const GLint *const intTexArray,
166
 
                                    const int size);
167
 
 
168
 
        inline void drawLineArrayi(const int size);
169
 
 
170
 
        inline void drawLineArrayf(const int size);
171
 
 
172
 
        inline void drawVertexes(const NormalOpenGLGraphicsVertexes &ogl);
173
 
 
174
 
        void initArrays() override;
175
 
 
176
 
        static void dumpSettings();
177
 
 
178
 
        /**
179
 
         * Takes a screenshot and returns it as SDL surface.
180
 
         */
181
 
        SDL_Surface *getScreenshot() override A_WARN_UNUSED;
182
 
 
183
 
        void prepareScreenshot() override;
184
 
 
185
 
        bool drawNet(const int x1, const int y1, const int x2, const int y2,
186
 
                     const int width, const int height) override;
187
 
 
188
 
        int getMemoryUsage() A_WARN_UNUSED;
189
 
 
190
 
        void updateTextureFormat();
191
 
 
192
 
#ifdef DEBUG_DRAW_CALLS
193
 
        virtual unsigned int getDrawCalls() const
194
 
        { return mLastDrawCalls; }
195
 
 
196
 
        static unsigned int mDrawCalls;
197
 
 
198
 
        static unsigned int mLastDrawCalls;
199
 
#endif
200
 
#ifdef DEBUG_BIND_TEXTURE
201
 
        virtual unsigned int getBinds() const
202
 
        { return mLastBinds; }
203
 
#endif
204
 
        static void bindTexture(const GLenum target, const GLuint texture);
205
 
 
206
 
        static GLuint mLastImage;
207
 
 
208
 
    protected:
209
 
        bool drawImage2(const Image *const image,
210
 
                        int srcX, int srcY,
211
 
                        int dstX, int dstY,
212
 
                        const int width, const int height,
213
 
                        const bool useColor) override;
214
 
 
215
 
        void setTexturingAndBlending(const bool enable);
216
 
 
217
 
        void debugBindTexture(const Image *const image);
218
 
 
219
 
    private:
220
 
        void inline setColorAlpha(float alpha);
221
 
 
222
 
        void inline restoreColor();
223
 
 
224
 
        GLfloat *mFloatTexArray;
225
 
        GLint *mIntTexArray;
226
 
        GLint *mIntVertArray;
227
 
        bool mTexture;
228
 
 
229
 
        bool mIsByteColor;
230
 
        gcn::Color mByteColor;
231
 
        float mFloatColor;
232
 
        int mMaxVertices;
233
 
        bool mColorAlpha;
234
 
#ifdef DEBUG_BIND_TEXTURE
235
 
        std::string mOldTexture;
236
 
        unsigned int mOldTextureId;
237
 
        static unsigned int mBinds;
238
 
        static unsigned int mLastBinds;
239
 
#endif
240
 
        FBOInfo mFbo;
241
 
};
242
 
#endif
243
 
 
244
 
#endif  // NORMALOPENGLGRAPHICS_H