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

grim/gfx_opengl.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_OPENGL_H
00024 #define GRIM_GFX_OPENGL_H
00025 
00026 #include "engines/grim/gfx_base.h"
00027 
00028 #ifdef USE_OPENGL
00029 
00030 #ifdef USE_GLEW
00031 #include <GL/glew.h>
00032 #elif defined (SDL_BACKEND) && !defined(__amigaos4__)
00033 #include <SDL_opengl.h>
00034 #undef ARRAYSIZE
00035 #else
00036 #include <GL/gl.h>
00037 #endif
00038 
00039 namespace Grim {
00040 
00041 class ModelNode;
00042 class Mesh;
00043 class MeshFace;
00044 
00045 class GfxOpenGL : public GfxBase {
00046 public:
00047     GfxOpenGL();
00048     virtual ~GfxOpenGL();
00049 
00050     byte *setupScreen(int screenW, int screenH, bool fullscreen) override;
00051 
00052     const char *getVideoDeviceName() override;
00053 
00054     void setupCameraFrustum(float fov, float nclip, float fclip) override;
00055     void positionCamera(const Math::Vector3d &pos, const Math::Vector3d &interest, float roll) override;
00056     void positionCamera(const Math::Vector3d &pos, const Math::Matrix4 &rot) override;
00057 
00058     Math::Matrix4 getModelView() override;
00059     Math::Matrix4 getProjection() override;
00060 
00061     void clearScreen() override;
00062     void clearDepthBuffer() override;
00063     void flipBuffer() override;
00064 
00065     bool isHardwareAccelerated() override;
00066     bool supportsShaders() override;
00067 
00068     void getScreenBoundingBox(const Mesh *model, int *x1, int *y1, int *x2, int *y2) override;
00069     void getScreenBoundingBox(const EMIModel *model, int *x1, int *y1, int *x2, int *y2) override;
00070     void getActorScreenBBox(const Actor *actor, Common::Point &p1, Common::Point &p2) override;
00071 
00072     void startActorDraw(const Actor *actor) override;
00073     void finishActorDraw() override;
00074     void setShadow(Shadow *shadow) override;
00075     void drawShadowPlanes() override;
00076     void setShadowMode() override;
00077     void clearShadowMode() override;
00078     void setShadowColor(byte r, byte g, byte b) override;
00079     void getShadowColor(byte *r, byte *g, byte *b) override;
00080 
00081     void set3DMode() override;
00082 
00083     void translateViewpointStart() override;
00084     void translateViewpoint(const Math::Vector3d &vec) override;
00085     void rotateViewpoint(const Math::Angle &angle, const Math::Vector3d &axis) override;
00086     void rotateViewpoint(const Math::Matrix4 &rot) override;
00087     void translateViewpointFinish() override;
00088 
00089     void drawEMIModelFace(const EMIModel *model, const EMIMeshFace *face) override;
00090     void drawModelFace(const Mesh *mesh, const MeshFace *face) override;
00091     void drawSprite(const Sprite *sprite) override;
00092 
00093     void enableLights() override;
00094     void disableLights() override;
00095     void setupLight(Light *light, int lightId) override;
00096     void turnOffLight(int lightId) override;
00097 
00098     void createTexture(Texture *texture, const uint8 *data, const CMap *cmap, bool clamp) override;
00099     void selectTexture(const Texture *texture) override;
00100     void destroyTexture(Texture *texture) override;
00101 
00102     void createBitmap(BitmapData *bitmap) override;
00103     void drawBitmap(const Bitmap *bitmap, int x, int y, uint32 layer) override;
00104     void destroyBitmap(BitmapData *bitmap) override;
00105 
00106     void createFont(Font *font) override;
00107     void destroyFont(Font *font) override;
00108 
00109     void createTextObject(TextObject *text) override;
00110     void drawTextObject(const TextObject *text) override;
00111     void destroyTextObject(TextObject *text) override;
00112 
00113     Bitmap *getScreenshot(int w, int h, bool useStored) override;
00114     void storeDisplay() override;
00115     void copyStoredToDisplay() override;
00116     void dimScreen() override;
00117     void dimRegion(int x, int y, int w, int h, float level) override;
00118     void irisAroundRegion(int x1, int y1, int x2, int y2) override;
00119 
00120     void drawEmergString(int x, int y, const char *text, const Color &fgColor) override;
00121     void loadEmergFont() override;
00122 
00123     void drawRectangle(const PrimitiveObject *primitive) override;
00124     void drawLine(const PrimitiveObject *primitive) override;
00125     void drawPolygon(const PrimitiveObject *primitive) override;
00126     void drawDimPlane() override;
00127 
00128     void prepareMovieFrame(Graphics::Surface *frame) override;
00129     void drawMovieFrame(int offsetX, int offsetY) override;
00130     void releaseMovieFrame() override;
00131 
00132     void setBlendMode(bool additive) override;
00133 
00134 protected:
00135     void createSpecialtyTextureFromScreen(uint id, uint8 *data, int x, int y, int width, int height) override;
00136     void drawDepthBitmap(int x, int y, int w, int h, char *data);
00137     void initExtensions();
00138 private:
00139     GLuint _emergFont;
00140     int _smushNumTex;
00141     GLuint *_smushTexIds;
00142     int _smushWidth;
00143     int _smushHeight;
00144     byte *_storedDisplay;
00145     bool _useDepthShader;
00146     GLuint _fragmentProgram;
00147     bool _useDimShader;
00148     GLuint _dimFragProgram;
00149     GLint _maxLights;
00150     float _alpha;
00151     const Actor *_currentActor;
00152     GLenum _depthFunc;
00153 
00154     void readPixels(int x, int y, int width, int height, uint8 *buffer);
00155 };
00156 
00157 } // end of namespace Grim
00158 
00159 #endif
00160 
00161 #endif


Generated on Sat Apr 20 2019 05:02:43 for ResidualVM by doxygen 1.7.1
curved edge   curved edge