ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

gfx_base.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GRIM_GFX_BASE_H
00024 #define GRIM_GFX_BASE_H
00025 
00026 #include "math/vector3d.h"
00027 #include "math/quat.h"
00028 
00029 #include "graphics/pixelbuffer.h"
00030 #include "common/str.h"
00031 #include "common/rect.h"
00032 
00033 #include "engines/grim/material.h"
00034 
00035 namespace Graphics {
00036     struct Surface;
00037 }
00038 
00039 namespace Grim {
00040 
00041 struct Shadow;
00042 struct Light;
00043 class Actor;
00044 class SaveGame;
00045 class BitmapData;
00046 class Bitmap;
00047 class CMap;
00048 class Color;
00049 class PrimitiveObject;
00050 class Font;
00051 class TextObject;
00052 class EMIModel;
00053 class EMIMeshFace;
00054 class ModelNode;
00055 class Mesh;
00056 class MeshFace;
00057 class Sprite;
00058 class Texture;
00059 
00063 enum colorFormat {
00064     BM_RGB565 = 1,    // Grim Fandango
00065     BM_RGB1555 = 2,   // EMI-PS2
00066     BM_RGBA = 3,      // EMI-PC (Also internal Material-format for Grim)
00067     BM_BGR888 = 4,    // EMI-TGA-materials (888)
00068     BM_BGRA = 5       // EMI-TGA-materials with alpha
00069 };
00070 class GfxBase {
00071 public:
00072     GfxBase();
00073     virtual ~GfxBase() { ; }
00074 
00082     virtual byte *setupScreen(int screenW, int screenH, bool fullscreen) = 0;
00083 
00089     virtual bool isHardwareAccelerated() = 0;
00095     virtual bool supportsShaders() = 0;
00096 
00097     virtual uint getScreenWidth() { return _screenWidth; }
00098     virtual uint getScreenHeight() { return _screenHeight; }
00099 
00100     virtual void setupCameraFrustum(float fov, float nclip, float fclip) = 0;
00101     virtual void positionCamera(const Math::Vector3d &pos, const Math::Vector3d &interest, float roll) = 0;
00102     virtual void positionCamera(const Math::Vector3d &pos, const Math::Matrix4 &rot) = 0;
00103 
00104     virtual Math::Matrix4 getModelView() = 0;
00105     virtual Math::Matrix4 getProjection() = 0;
00106 
00107     virtual void clearScreen() = 0;
00108     virtual void clearDepthBuffer() = 0;
00109 
00113     virtual void flipBuffer() = 0;
00114 
00119     virtual void getScreenBoundingBox(const Mesh *mesh, int *x1, int *y1, int *x2, int *y2) = 0;
00120     virtual void getScreenBoundingBox(const EMIModel *mesh, int *x1, int *y1, int *x2, int *y2) = 0;
00121     virtual void getActorScreenBBox(const Actor *actor, Common::Point &p1, Common::Point &p2) = 0;
00122     virtual void startActorDraw(const Actor *act) = 0;
00123     virtual void finishActorDraw() = 0;
00124     virtual void setShadow(Shadow *shadow) = 0;
00125     virtual void drawShadowPlanes() = 0;
00126     virtual void setShadowMode();
00127     virtual void clearShadowMode();
00128     virtual bool isShadowModeActive();
00129     virtual void setShadowColor(byte r, byte g, byte b) = 0;
00130     virtual void getShadowColor(byte *r, byte *g, byte *b) = 0;
00131     virtual void destroyShadow(Shadow *shadow) {}
00132 
00133     virtual void set3DMode() = 0;
00134 
00135     virtual void translateViewpointStart() = 0;
00136     virtual void translateViewpoint(const Math::Vector3d &vec) = 0;
00137     virtual void rotateViewpoint(const Math::Angle &angle, const Math::Vector3d &axis) = 0;
00138     virtual void rotateViewpoint(const Math::Matrix4 &rot) = 0;
00139     virtual void translateViewpointFinish() = 0;
00140 
00141     virtual void drawEMIModelFace(const EMIModel *model, const EMIMeshFace *face) = 0;
00142     virtual void drawModelFace(const Mesh *mesh, const MeshFace *face) = 0;
00143     virtual void drawSprite(const Sprite *sprite) = 0;
00144     virtual void drawMesh(const Mesh *mesh);
00145 
00146     virtual void enableLights() = 0;
00147     virtual void disableLights() = 0;
00148     virtual void setupLight(Light *light, int lightId) = 0;
00149     virtual void turnOffLight(int lightId) = 0;
00150 
00151     virtual void createTexture(Texture *texture, const uint8 *data, const CMap *cmap, bool clamp) = 0;
00152     virtual void selectTexture(const Texture *texture) = 0;
00153     virtual void destroyTexture(Texture *texture) = 0;
00154 
00168     virtual void createBitmap(BitmapData *bitmap) = 0;
00169 
00178     virtual void drawBitmap(const Bitmap *bitmap, int x, int y, uint32 layer = 0) = 0;
00179 
00189     virtual void destroyBitmap(BitmapData *bitmap) = 0;
00190 
00191     virtual void createFont(Font *font) = 0;
00192     virtual void destroyFont(Font *font) = 0;
00193 
00194     virtual void createTextObject(TextObject *text) = 0;
00195     virtual void drawTextObject(const TextObject *text) = 0;
00196     virtual void destroyTextObject(TextObject *text) = 0;
00197 
00198     virtual Bitmap *getScreenshot(int w, int h, bool useStored) = 0;
00199     virtual void storeDisplay() = 0;
00200     virtual void copyStoredToDisplay() = 0;
00201 
00207     virtual void dimScreen() = 0;
00208     virtual void dimRegion(int x, int y, int w, int h, float level) = 0;
00209     virtual void setDimLevel(float dimLevel) { _dimLevel = dimLevel; }
00210 
00219     virtual void irisAroundRegion(int x1, int y1, int x2, int y2) = 0;
00220 
00221     virtual void drawEmergString(int x, int y, const char *text, const Color &fgColor) = 0;
00222     virtual void loadEmergFont() = 0;
00223 
00224     virtual void drawRectangle(const PrimitiveObject *primitive) = 0;
00225     virtual void drawLine(const PrimitiveObject *primitive) = 0;
00226     virtual void drawPolygon(const PrimitiveObject *primitive) = 0;
00227     virtual void drawDimPlane() {};
00228 
00239     virtual void prepareMovieFrame(Graphics::Surface *frame) = 0;
00240     virtual void drawMovieFrame(int offsetX, int offsetY) = 0;
00241 
00248     virtual void releaseMovieFrame() = 0;
00249 
00250     virtual const char *getVideoDeviceName() = 0;
00251 
00252     virtual void saveState(SaveGame *state);
00253     virtual void restoreState(SaveGame *state);
00254 
00255     virtual void renderBitmaps(bool render);
00256     virtual void renderZBitmaps(bool render);
00257 
00258     virtual void makeScreenTextures();
00259 
00260     virtual void createMesh(Mesh *mesh) {}
00261     virtual void destroyMesh(const Mesh *mesh) {}
00262     virtual void createEMIModel(EMIModel *model) {}
00263     virtual void updateEMIModel(const EMIModel *model) {}
00264     virtual void destroyEMIModel(EMIModel *model) {}
00265 
00266     virtual void createSpecialtyTexture(uint id, const uint8 *data, int width, int height);
00267     virtual void createSpecialtyTextureFromScreen(uint id, uint8 *data, int x, int y, int width, int height) = 0;
00268 
00269     static Math::Matrix4 makeLookMatrix(const Math::Vector3d& pos, const Math::Vector3d& interest, const Math::Vector3d& up);
00270     static Math::Matrix4 makeProjMatrix(float fov, float nclip, float fclip);
00271     Texture *getSpecialtyTexturePtr(uint id) { if (id >= _numSpecialtyTextures) return nullptr; return &_specialtyTextures[id]; };
00272     Texture *getSpecialtyTexturePtr(Common::String name);
00273 
00274     virtual void setBlendMode(bool additive) = 0;
00275 protected:
00276     Bitmap *createScreenshotBitmap(const Graphics::PixelBuffer src, int w, int h, bool flipOrientation);
00277     static const unsigned int _numSpecialtyTextures = 22;
00278     Texture _specialtyTextures[_numSpecialtyTextures];
00279     static const int _gameHeight = 480;
00280     static const int _gameWidth = 640;
00281     float _scaleW, _scaleH;
00282     int _screenWidth, _screenHeight;
00283     Shadow *_currentShadowArray;
00284     unsigned char _shadowColorR;
00285     unsigned char _shadowColorG;
00286     unsigned char _shadowColorB;
00287     bool _renderBitmaps;
00288     bool _renderZBitmaps;
00289     bool _shadowModeActive;
00290     Math::Vector3d _currentPos;
00291     Math::Matrix4 _currentRot;
00292     float _dimLevel;
00293 };
00294 
00295 // Factory-like functions:
00296 
00297 GfxBase *CreateGfxOpenGL();
00298 GfxBase *CreateGfxOpenGLShader();
00299 GfxBase *CreateGfxTinyGL();
00300 
00301 extern GfxBase *g_driver;
00302 
00303 } // end of namespace Grim
00304 
00305 #endif


Generated on Sat Oct 12 2019 05:00:49 for ResidualVM by doxygen 1.7.1
curved edge   curved edge