Otclient  14/8/2020
painterogl1.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #ifndef PAINTEROGL1_H
24 #define PAINTEROGL1_H
25 
26 #define PAINTER_OGL1
27 
28 #include "painterogl.h"
29 
36 class PainterOGL1 : public PainterOGL
37 {
38 public:
39  enum MatrixMode {
40  MatrixProjection = 0x1701, //GL_PROJECTION
41  MatrixTexture = 0x1702, //GL_TEXTURE
42  MatrixTransform = 0x1700 // GL_MODELVIEW
43  };
44 
45  PainterOGL1();
46 
47  void bind();
48  void unbind();
49 
50  void refreshState();
51 
52  void drawCoords(CoordsBuffer& coordsBuffer, DrawMode drawMode = Triangles);
53  void drawFillCoords(CoordsBuffer& coordsBuffer);
54  void drawTextureCoords(CoordsBuffer& coordsBuffer, const TexturePtr& texture);
55  void drawTexturedRect(const Rect& dest, const TexturePtr& texture, const Rect& src);
56  void drawUpsideDownTexturedRect(const Rect& dest, const TexturePtr& texture, const Rect& src);
57  void drawRepeatedTexturedRect(const Rect& dest, const TexturePtr& texture, const Rect& src);
58  void drawFilledRect(const Rect& dest);
59  void drawFilledTriangle(const Point& a, const Point& b, const Point& c);
60  void drawBoundingRect(const Rect& dest, int innerLineWidth);
61 
62  void setMatrixMode(MatrixMode matrixMode);
63  void setTransformMatrix(const Matrix3& transformMatrix);
64  void setProjectionMatrix(const Matrix3& projectionMatrix);
65  void setTextureMatrix(const Matrix3& textureMatrix);
66  void setColor(const Color& color);
67  void setOpacity(float opacity);
68 
69  bool hasShaders() { return false; }
70 
71 private:
72  void updateGlColor();
73  void updateGlMatrixMode();
74  void updateGlProjectionMatrix();
75  void updateGlTransformMatrix();
76  void updateGlTextureMatrix();
77  void updateGlTextureState();
78 
79  GLenum m_matrixMode;
80  stdext::boolean<false> m_textureEnabled;
81 };
82 
84 
85 #endif
PainterOGL1::unbind
void unbind()
Definition: painterogl1.cpp:57
PainterOGL1::drawFilledTriangle
void drawFilledTriangle(const Point &a, const Point &b, const Point &c)
Definition: painterogl1.cpp:201
PainterOGL1::drawUpsideDownTexturedRect
void drawUpsideDownTexturedRect(const Rect &dest, const TexturePtr &texture, const Rect &src)
Definition: painterogl1.cpp:165
PainterOGL1::MatrixTransform
@ MatrixTransform
Definition: painterogl1.h:42
painterogl.h
PainterOGL1::hasShaders
bool hasShaders()
Definition: painterogl1.h:69
Color
Definition: color.h:32
g_painterOGL1
PainterOGL1 * g_painterOGL1
Definition: painterogl1.cpp:28
TRect< int >
PainterOGL1::setProjectionMatrix
void setProjectionMatrix(const Matrix3 &projectionMatrix)
Definition: painterogl1.cpp:240
PainterOGL1::setMatrixMode
void setMatrixMode(MatrixMode matrixMode)
Definition: painterogl1.cpp:225
PainterOGL1::drawFilledRect
void drawFilledRect(const Rect &dest)
Definition: painterogl1.cpp:189
Painter::DrawMode
DrawMode
Definition: painter.h:46
stdext::boolean< false >
PainterOGL1::bind
void bind()
Definition: painterogl1.cpp:47
PainterOGL1::PainterOGL1
PainterOGL1()
Definition: painterogl1.cpp:30
PainterOGL1
Definition: painterogl1.h:36
PainterOGL1::setTextureMatrix
void setTextureMatrix(const Matrix3 &textureMatrix)
Definition: painterogl1.cpp:247
Painter::Triangles
@ Triangles
Definition: painter.h:47
PainterOGL1::MatrixMode
MatrixMode
Definition: painterogl1.h:39
PainterOGL1::drawRepeatedTexturedRect
void drawRepeatedTexturedRect(const Rect &dest, const TexturePtr &texture, const Rect &src)
Definition: painterogl1.cpp:177
PainterOGL1::refreshState
void refreshState()
Definition: painterogl1.cpp:36
PainterOGL1::MatrixProjection
@ MatrixProjection
Definition: painterogl1.h:40
stdext::shared_object_ptr< Texture >
CoordsBuffer
Definition: coordsbuffer.h:29
PainterOGL1::drawFillCoords
void drawFillCoords(CoordsBuffer &coordsBuffer)
Definition: painterogl1.cpp:138
PainterOGL1::drawTextureCoords
void drawTextureCoords(CoordsBuffer &coordsBuffer, const TexturePtr &texture)
Definition: painterogl1.cpp:144
PainterOGL1::drawBoundingRect
void drawBoundingRect(const Rect &dest, int innerLineWidth)
Definition: painterogl1.cpp:213
Matrix
Definition: matrix.h:32
TPoint< int >
PainterOGL1::setOpacity
void setOpacity(float opacity)
Definition: painterogl1.cpp:264
PainterOGL1::MatrixTexture
@ MatrixTexture
Definition: painterogl1.h:41
PainterOGL1::setTransformMatrix
void setTransformMatrix(const Matrix3 &transformMatrix)
Definition: painterogl1.cpp:233
PainterOGL1::drawTexturedRect
void drawTexturedRect(const Rect &dest, const TexturePtr &texture, const Rect &src)
Definition: painterogl1.cpp:153
PainterOGL
Definition: painterogl.h:28
PainterOGL1::drawCoords
void drawCoords(CoordsBuffer &coordsBuffer, DrawMode drawMode=Triangles)
Definition: painterogl1.cpp:63
PainterOGL1::setColor
void setColor(const Color &color)
Definition: painterogl1.cpp:256