ScummVM API documentation
gfx_opengl.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 GRIM_GFX_OPENGL_H
23#define GRIM_GFX_OPENGL_H
24
25#include "engines/grim/gfx_base.h"
26
27#ifdef USE_OPENGL_GAME
28
29#include "graphics/opengl/system_headers.h"
30
31namespace Grim {
32
33class ModelNode;
34class Mesh;
35class MeshFace;
36
37class GfxOpenGL : public GfxBase {
38public:
39 GfxOpenGL();
40 virtual ~GfxOpenGL();
41
42 void setupScreen(int screenW, int screenH) override;
43
44 const char *getVideoDeviceName() override;
45
46 void setupCameraFrustum(float fov, float nclip, float fclip) override;
47 void positionCamera(const Math::Vector3d &pos, const Math::Vector3d &interest, float roll) override;
48 void positionCamera(const Math::Vector3d &pos, const Math::Matrix4 &rot) override;
49
50 Math::Matrix4 getModelView() override;
51 Math::Matrix4 getProjection() override;
52
53 void clearScreen() override;
54 void clearDepthBuffer() override;
55 void flipBuffer(bool opportunistic = false) override;
56
57 bool isHardwareAccelerated() override;
58 bool supportsShaders() override;
59
60 void getScreenBoundingBox(const Mesh *model, int *x1, int *y1, int *x2, int *y2) override;
61 void getScreenBoundingBox(const EMIModel *model, int *x1, int *y1, int *x2, int *y2) override;
62 void getActorScreenBBox(const Actor *actor, Common::Point &p1, Common::Point &p2) override;
63
64 void startActorDraw(const Actor *actor) override;
65 void finishActorDraw() override;
66 void setShadow(Shadow *shadow) override;
67 void drawShadowPlanes() override;
68 void setShadowMode() override;
69 void clearShadowMode() override;
70 void setShadowColor(byte r, byte g, byte b) override;
71 void getShadowColor(byte *r, byte *g, byte *b) override;
72
73 void set3DMode() override;
74
75 void translateViewpointStart() override;
76 void translateViewpoint(const Math::Vector3d &vec) override;
77 void rotateViewpoint(const Math::Angle &angle, const Math::Vector3d &axis) override;
78 void rotateViewpoint(const Math::Matrix4 &rot) override;
79 void translateViewpointFinish() override;
80
81 void drawEMIModelFace(const EMIModel *model, const EMIMeshFace *face) override;
82 void drawModelFace(const Mesh *mesh, const MeshFace *face) override;
83 void drawSprite(const Sprite *sprite) override;
84
85 void drawOverlay(const Overlay *overlay) override;
86
87 void enableLights() override;
88 void disableLights() override;
89 void setupLight(Light *light, int lightId) override;
90 void turnOffLight(int lightId) override;
91
92 void createTexture(Texture *texture, const uint8 *data, const CMap *cmap, bool clamp) override;
93 void selectTexture(const Texture *texture) override;
94 void destroyTexture(Texture *texture) override;
95
96 void createBitmap(BitmapData *bitmap) override;
97 void drawBitmap(const Bitmap *bitmap, int x, int y, uint32 layer) override;
98 void destroyBitmap(BitmapData *bitmap) override;
99
100 void createFont(Font *font) override;
101 void destroyFont(Font *font) override;
102
103 void createTextObject(TextObject *text) override;
104 void drawTextObject(const TextObject *text) override;
105 void destroyTextObject(TextObject *text) override;
106
107 Bitmap *getScreenshot(int w, int h, bool useStored) override;
108 void storeDisplay() override;
109 void copyStoredToDisplay() override;
110 void dimScreen() override;
111 void dimRegion(int x, int y, int w, int h, float level) override;
112 void irisAroundRegion(int x1, int y1, int x2, int y2) override;
113
114 void drawEmergString(int x, int y, const char *text, const Color &fgColor) override;
115 void loadEmergFont() override;
116
117 void drawRectangle(const PrimitiveObject *primitive) override;
118 void drawLine(const PrimitiveObject *primitive) override;
119 void drawPolygon(const PrimitiveObject *primitive) override;
120 void drawDimPlane() override;
121
122 const Graphics::PixelFormat getMovieFormat() const override;
123 void prepareMovieFrame(Graphics::Surface *frame) override;
124 void drawMovieFrame(int offsetX, int offsetY) override;
125 void releaseMovieFrame() override;
126
127 void setBlendMode(bool additive) override;
128
129protected:
130 void createSpecialtyTextureFromScreen(uint id, uint8 *data, int x, int y, int width, int height) override;
131 void drawDepthBitmap(int x, int y, int w, int h, const char *data);
132 void initExtensions();
133private:
134 GLuint _emergFont;
135 int _smushNumTex;
136 GLuint *_smushTexIds;
137 int _smushWidth;
138 int _smushHeight;
139 byte *_storedDisplay;
140 bool _useDepthShader;
141#ifdef GL_ARB_fragment_program
142 GLuint _fragmentProgram;
143 GLuint _dimFragProgram;
144#endif
145 bool _useDimShader;
146 GLint _maxLights;
147 float _alpha;
148 const Actor *_currentActor;
149 GLenum _depthFunc;
150
151 void readPixels(int x, int y, int width, int height, uint8 *buffer);
152};
153
154} // end of namespace Grim
155
156#endif
157
158#endif
Definition: default_display_client.h:68
Definition: rect.h:144
Definition: pixelformat.h:138
Definition: surface.h:67