ScummVM API documentation
opengl_renderer.h
1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21 
22 #ifndef WATCHMAKER_OPENGL_RENDERER_H
23 #define WATCHMAKER_OPENGL_RENDERER_H
24 
25 
26 #include "watchmaker/3d/math/Matrix4x4.h"
27 #include "watchmaker/utils.h"
28 #include "watchmaker/render.h"
29 #include "watchmaker/3d/render/opengl_3d.h"
30 
31 namespace Watchmaker {
32 
33 enum class TransformMatrix {
34  PROJECTION,
35  VIEW
36 };
37 
38 enum class RenderState {
39  LIGHT,
40  CLIP,
41  EXTENT,
42  ALPHABLEND,
43  ALPHAREF, // TODO
44  ZENABLE, // TODO
45  ZWRITE_ENABLE, // TODO
46  TEXTUREFACTOR // TODO
47 };
48 
49 enum class BlendFactor {
50  ONE,
51  ZERO,
52  SRCALPHA,
53  INVSRCALPHA,
54  INVSRCCOLOR,
55  SRCCOLOR,
56  DESTCOLOR,
57  INVDESTCOLOR
58 };
59 
60 enum class TextureWrapMode {
61  WRAP,
62  CLAMP
63 };
64 
65 enum class PrimitiveType {
66  LINE,
67  TRIANGLE
68 };
69 
70 Common::SharedPtr<TextureData> createTextureFromSurface(Graphics::Surface &surface, int texFormat);
71 Texture *createGLTexture();
72 
74 public:
75  void enter2Dmode();
76  void exit2Dmode();
77 
78  void pushModelView();
79  void popModelView();
80  void setTransformMatrix(TransformMatrix which, const Matrix4x4 &matrix);
81  // TODO: This should be split.
82  void setRenderState(RenderState state, int value);
83  void setBlendFunc(BlendFactor src, BlendFactor dst);
84  bool error() const {
85  //warning("TODO: Implement error");
86  return false;
87  }
88  Common::String getErrorString() {
89  warning("TODO: Implement getErrorString");
90  return "";
91  }
92  // TODO: This just maps to the D3D way to setting textures
93  void setTexture(int stage, void *texture);
94  void setTexture(int stage, const gTexture &texture);
95  void setTextureWrapMode(int index, TextureWrapMode mode);
96 
97  void drawPrimitives(PrimitiveType primitiveType, Vertex *vertices, int numPrimitives);
98  void drawIndexedPrimitivesVBO(PrimitiveType primitiveType, int VBO, int firstVertex, int numVertices, uint16 *faces, uint32 numFaces);
99  void drawIndexedPrimitivesVBO(PrimitiveType primitiveType, Common::SharedPtr<VertexBuffer> VBO, int firstVertex, int numVertices, Common::Array<uint16> faces, uint32 numFaces);
100  void drawIndexedPrimitivesVBO(PrimitiveType primitiveType, gBatchBlock &bb);
101  bool supportsMultiTexturing() const { // TODO
102  return false;
103  }
104 };
105 
106 extern OpenGLRenderer *g_renderer;
107 
108 } // End of namespace Watchmaker
109 
110 #endif // WATCHMAKER_OPENGL_RENDERER_H
Definition: 2d_stuff.h:30
Definition: str.h:59
Definition: surface.h:67
void warning(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: opengl_renderer.h:73
Definition: opengl_3d.h:40
Definition: texture.h:36
Definition: render.h:112
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: Matrix4x4.h:30
Definition: ptr.h:159