1 /* ResidualVM - A 3D game interpreter 2 * 3 * ResidualVM 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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef GRIM_GFX_TINYGL_H 24 #define GRIM_GFX_TINYGL_H 25 26 #include "engines/grim/gfx_base.h" 27 28 #include "graphics/tinygl/zgl.h" 29 30 namespace Grim { 31 32 class ModelNode; 33 class Mesh; 34 class MeshFace; 35 class BlitImage; 36 37 class GfxTinyGL : public GfxBase { 38 public: 39 GfxTinyGL(); 40 virtual ~GfxTinyGL(); 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() 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 &matrix) 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 enableLights() override; 86 void disableLights() override; 87 void setupLight(Light *light, int lightId) override; 88 void turnOffLight(int lightId) override; 89 90 void createTexture(Texture *texture, const uint8 *data, const CMap *cmap, bool clamp) override; 91 void selectTexture(const Texture *texture) override; 92 void destroyTexture(Texture *texture) override; 93 94 void createBitmap(BitmapData *bitmap) override; 95 void drawBitmap(const Bitmap *bitmap, int x, int y, uint32 layer) override; 96 void destroyBitmap(BitmapData *bitmap) override; 97 98 void createFont(Font *font) override; 99 void destroyFont(Font *font) override; 100 101 void drawTextObject(const TextObject *text) override; 102 void createTextObject(TextObject *text) override; 103 void destroyTextObject(TextObject *text) override; 104 105 void dimScreen() override; 106 void dimRegion(int x, int y, int w, int h, float level) override; 107 void irisAroundRegion(int x1, int y1, int x2, int y2) override; 108 109 Bitmap *getScreenshot(int w, int h, bool useStored) override; 110 void storeDisplay() override; 111 void copyStoredToDisplay() override; 112 113 void drawEmergString(int x, int y, const char *text, const Color &fgColor) override; 114 void loadEmergFont() override; 115 116 void drawRectangle(const PrimitiveObject *primitive) override; 117 void drawLine(const PrimitiveObject *primitive) override; 118 void drawPolygon(const PrimitiveObject *primitive) override; 119 void drawDimPlane() override; 120 121 void prepareMovieFrame(Graphics::Surface *frame) override; 122 void drawMovieFrame(int offsetX, int offsetY) override; 123 void releaseMovieFrame() override; 124 125 void setBlendMode(bool additive) override; 126 127 protected: 128 void createSpecialtyTextureFromScreen(uint id, uint8 *data, int x, int y, int width, int height) override; 129 130 private: 131 TinyGL::FrameBuffer *_zb; 132 Graphics::PixelFormat _pixelFormat; 133 Graphics::BlitImage *_emergFont[96]; 134 Graphics::BlitImage *_smushImage; 135 Graphics::PixelBuffer _storedDisplay; 136 float _alpha; 137 const Actor *_currentActor; 138 TGLenum _depthFunc; 139 140 void readPixels(int x, int y, int width, int height, uint8 *buffer); 141 }; 142 143 } // end of namespace Grim 144 145 #endif 146