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

openglsdl-graphics.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 BACKENDS_GRAPHICS_OPENGLSDL_GRAPHICS_H
00024 #define BACKENDS_GRAPHICS_OPENGLSDL_GRAPHICS_H
00025 
00026 #include "backends/graphics/sdl/resvm-sdl-graphics.h"
00027 
00028 namespace OpenGL {
00029     class FrameBuffer;
00030     class SurfaceRenderer;
00031     class Texture;
00032     class TiledSurface;
00033 }
00034 
00040 class OpenGLSdlGraphicsManager : public ResVmSdlGraphicsManager {
00041 public:
00042     OpenGLSdlGraphicsManager(SdlEventSource *sdlEventSource, SdlWindow *window, const Capabilities &capabilities);
00043     virtual ~OpenGLSdlGraphicsManager();
00044 
00045     // GraphicsManager API - Features
00046     virtual bool hasFeature(OSystem::Feature f) const override;
00047     virtual bool getFeatureState(OSystem::Feature f) const override;
00048     virtual void setFeatureState(OSystem::Feature f, bool enable) override;
00049 
00050     // GraphicsManager API - Graphics mode
00051     virtual void setupScreen(uint gameWidth, uint gameHeight, bool fullscreen, bool accel3d) override;
00052     virtual Graphics::PixelBuffer getScreenPixelBuffer() override;
00053     virtual int16 getHeight() const override;
00054     virtual int16 getWidth() const override;
00055 
00056     // GraphicsManager API - Draw methods
00057     virtual void updateScreen();
00058 
00059     // GraphicsManager API - Overlay
00060     virtual void showOverlay() override;
00061     virtual void hideOverlay() override;
00062     virtual void clearOverlay() override;
00063     virtual void grabOverlay(void *buf, int pitch) const override;
00064     virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) override;
00065     int16 getOverlayWidth() const override;
00066     int16 getOverlayHeight() const override;
00067 
00068     /* Render the passed Surfaces besides the game texture.
00069      * This is used for widescreen support in the Grim engine.
00070      * Note: we must copy the Surfaces, as they are free()d after this call.
00071      */
00072     virtual void suggestSideTextures(Graphics::Surface *left, Graphics::Surface *right) override;
00073 
00074     // GraphicsManager API - Mouse
00075     virtual void warpMouse(int x, int y) override;
00076 
00077     // SdlGraphicsManager API
00078     virtual void transformMouseCoordinates(Common::Point &point) override;
00079 
00080     void notifyResize(const uint width, const uint height) override;
00081 
00082 protected:
00083 #if SDL_VERSION_ATLEAST(2, 0, 0)
00084     SDL_GLContext _glContext;
00085     void deinitializeRenderer();
00086 #endif
00087 
00088     Math::Rect2d _gameRect;
00089 
00090     struct OpenGLPixelFormat {
00091         uint bytesPerPixel;
00092         uint redSize;
00093         uint blueSize;
00094         uint greenSize;
00095         uint alphaSize;
00096         int multisampleSamples;
00097 
00098         OpenGLPixelFormat(uint screenBytesPerPixel, uint red, uint blue, uint green, uint alpha, int samples);
00099     };
00100 
00107     bool createOrUpdateGLContext(uint gameWidth, uint gameHeight, uint effectiveWidth, uint effectiveHeight, bool renderToFramebuffer);
00108 
00109     void createOrUpdateScreen();
00110 
00112     Math::Rect2d computeGameRect(bool renderToFrameBuffer, uint gameWidth, uint gameHeight,
00113                                  uint screenWidth, uint screenHeight);
00114 
00115     int _antialiasing;
00116     bool _vsync;
00117 
00118     OpenGL::TiledSurface *_overlayScreen;
00119     OpenGL::TiledSurface *_overlayBackground;
00120     OpenGL::Texture *_sideTextures[2];
00121     OpenGL::SurfaceRenderer *_surfaceRenderer;
00122 
00123     void initializeOpenGLContext() const;
00124     void drawOverlay();
00125     void drawSideTextures();
00126     void closeOverlay();
00127 
00128     OpenGL::FrameBuffer *_frameBuffer;
00129     OpenGL::FrameBuffer *createFramebuffer(uint width, uint height);
00130 
00131     bool isVSyncEnabled() const;
00132 };
00133 
00134 #endif


Generated on Sat Feb 16 2019 05:01:00 for ResidualVM by doxygen 1.7.1
curved edge   curved edge