ScummVM API documentation
gfx_tinygl.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_TINYGL_H
23 #define GRIM_GFX_TINYGL_H
24 
25 #include "engines/grim/gfx_base.h"
26 
27 #include "graphics/tinygl/tinygl.h"
28 
29 namespace Graphics {
30 struct Surface;
31 }
32 
33 namespace Grim {
34 
35 class ModelNode;
36 class Mesh;
37 class MeshFace;
38 
39 class GfxTinyGL : public GfxBase {
40 public:
41  GfxTinyGL();
42  virtual ~GfxTinyGL();
43 
44  void setupScreen(int screenW, int screenH) override;
45 
46  const char *getVideoDeviceName() override;
47 
48  void setupCameraFrustum(float fov, float nclip, float fclip) override;
49  void positionCamera(const Math::Vector3d &pos, const Math::Vector3d &interest, float roll) override;
50  void positionCamera(const Math::Vector3d &pos, const Math::Matrix4 &rot) override;
51 
52  Math::Matrix4 getModelView() override;
53  Math::Matrix4 getProjection() override;
54 
55  void clearScreen() override;
56  void clearDepthBuffer() override;
57  void flipBuffer(bool opportunistic = false) override;
58 
59  bool isHardwareAccelerated() override;
60  bool supportsShaders() override;
61 
62  void getScreenBoundingBox(const Mesh *model, int *x1, int *y1, int *x2, int *y2) override;
63  void getScreenBoundingBox(const EMIModel *model, int *x1, int *y1, int *x2, int *y2) override;
64  void getActorScreenBBox(const Actor *actor, Common::Point &p1, Common::Point &p2) override;
65 
66  void startActorDraw(const Actor *actor) override;
67  void finishActorDraw() override;
68  void setShadow(Shadow *shadow) override;
69  void drawShadowPlanes() override;
70  void setShadowMode() override;
71  void clearShadowMode() override;
72  void setShadowColor(byte r, byte g, byte b) override;
73  void getShadowColor(byte *r, byte *g, byte *b) override;
74 
75  void set3DMode() override;
76 
77  void translateViewpointStart() override;
78  void translateViewpoint(const Math::Vector3d &vec) override;
79  void rotateViewpoint(const Math::Angle &angle, const Math::Vector3d &axis) override;
80  void rotateViewpoint(const Math::Matrix4 &matrix) override;
81  void translateViewpointFinish() override;
82 
83  void drawEMIModelFace(const EMIModel *model, const EMIMeshFace *face) override;
84  void drawModelFace(const Mesh *mesh, const MeshFace *face) override;
85  void drawSprite(const Sprite *sprite) 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 drawTextObject(const TextObject *text) override;
104  void createTextObject(TextObject *text) override;
105  void destroyTextObject(TextObject *text) override;
106 
107  void dimScreen() override;
108  void dimRegion(int x, int y, int w, int h, float level) override;
109  void irisAroundRegion(int x1, int y1, int x2, int y2) override;
110 
111  Bitmap *getScreenshot(int w, int h, bool useStored) override;
112  void storeDisplay() override;
113  void copyStoredToDisplay() override;
114 
115  void drawEmergString(int x, int y, const char *text, const Color &fgColor) override;
116  void loadEmergFont() override;
117 
118  void drawRectangle(const PrimitiveObject *primitive) override;
119  void drawLine(const PrimitiveObject *primitive) override;
120  void drawPolygon(const PrimitiveObject *primitive) override;
121  void drawDimPlane() override;
122 
123  const Graphics::PixelFormat getMovieFormat() const override;
124  void prepareMovieFrame(Graphics::Surface *frame) override;
125  void drawMovieFrame(int offsetX, int offsetY) override;
126  void releaseMovieFrame() override;
127 
128  void setBlendMode(bool additive) override;
129 
130 protected:
131  void createSpecialtyTextureFromScreen(uint id, uint8 *data, int x, int y, int width, int height) override;
132 
133 private:
134  Graphics::PixelFormat _pixelFormat;
135  TinyGL::BlitImage *_emergFont[96];
136  TinyGL::BlitImage *_smushImage;
137  Graphics::Surface *_storedDisplay;
138  float _alpha;
139  const Actor *_currentActor;
140  TGLenum _depthFunc;
141 
142  void readPixels(int x, int y, int width, int height, uint8 *buffer);
143 };
144 
145 } // end of namespace Grim
146 
147 #endif
Definition: set.h:184
Definition: surface.h:67
Definition: actor.h:55
Definition: modelemi.h:82
Definition: pixelformat.h:138
Definition: actor.h:33
Definition: model.h:92
Definition: sprite.h:38
Definition: model.h:124
Definition: bitmap.h:125
Definition: bitmap.h:50
Definition: textobject.h:84
Definition: gfx_base.h:62
Definition: formatinfo.h:28
Definition: modelemi.h:55
Definition: colormap.h:35
Definition: rect.h:45
Definition: primitives.h:34
Definition: font.h:38
Actor represents a 3D character on screen.
Definition: actor.h:72
Definition: gfx_tinygl.h:39
Definition: material.h:31
Definition: color.h:29