diff options
Diffstat (limited to 'backends/graphics/opengl/opengl-graphics.h')
| -rw-r--r-- | backends/graphics/opengl/opengl-graphics.h | 125 | 
1 files changed, 101 insertions, 24 deletions
| diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index 9578839383..d3f8d792ba 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -24,11 +24,14 @@  #define BACKENDS_GRAPHICS_OPENGL_OPENGL_GRAPHICS_H  #include "backends/graphics/opengl/opengl-sys.h" +#include "backends/graphics/opengl/framebuffer.h"  #include "backends/graphics/graphics.h"  #include "common/frac.h"  #include "common/mutex.h" +#include "graphics/surface.h" +  namespace Graphics {  class Font;  } // End of namespace Graphics @@ -40,11 +43,14 @@ namespace OpenGL {  // SurfaceSDL backend enables it and disabling it can cause issues in sdl.cpp.  #define USE_OSD 1 -class Texture; +class Surface; +class Pipeline; +#if !USE_FORCED_GLES +class Shader; +#endif  enum { -	GFX_LINEAR = 0, -	GFX_NEAREST = 1 +	GFX_OPENGL = 0  };  class OpenGLGraphicsManager : virtual public GraphicsManager { @@ -110,6 +116,7 @@ public:  	virtual void setCursorPalette(const byte *colors, uint start, uint num);  	virtual void displayMessageOnOSD(const char *msg); +	virtual void displayActivityIconOnOSD(const Graphics::Surface *icon);  	// PaletteManager interface  	virtual void setPalette(const byte *colors, uint start, uint num); @@ -117,6 +124,11 @@ public:  protected:  	/** +	 * Whether an GLES or GLES2 context is active. +	 */ +	bool isGLESContext() const { return g_context.type == kContextGLES || g_context.type == kContextGLES2; } + +	/**  	 * Set up the actual screen size available for the OpenGL code to do any  	 * drawing.  	 * @@ -126,6 +138,16 @@ protected:  	void setActualScreenSize(uint width, uint height);  	/** +	 * Sets the OpenGL (ES) type the graphics manager shall work with. +	 * +	 * This needs to be called at least once (and before ever calling +	 * notifyContextCreate). +	 * +	 * @param type Type of the OpenGL (ES) contexts to be created. +	 */ +	void setContextType(ContextType type); + +	/**  	 * Notify the manager of a OpenGL context change. This should be the first  	 * thing to call after you created an OpenGL (ES) context!  	 * @@ -172,15 +194,15 @@ protected:  private:  	/** -	 * Create a texture with the specified pixel format. +	 * Create a surface with the specified pixel format.  	 * -	 * @param format    The pixel format the Texture object should accept as +	 * @param format    The pixel format the Surface object should accept as  	 *                  input. -	 * @param wantAlpha For CLUT8 textures this marks whether an alpha +	 * @param wantAlpha For CLUT8 surfaces this marks whether an alpha  	 *                  channel should be used. -	 * @return A pointer to the texture or nullptr on failure. +	 * @return A pointer to the surface or nullptr on failure.  	 */ -	Texture *createTexture(const Graphics::PixelFormat &format, bool wantAlpha = false); +	Surface *createSurface(const Graphics::PixelFormat &format, bool wantAlpha = false);  	//  	// Transaction support @@ -190,7 +212,7 @@ private:  #ifdef USE_RGB_COLOR  		    gameFormat(),  #endif -		    aspectRatioCorrection(false), graphicsMode(GFX_LINEAR) { +		    aspectRatioCorrection(false), graphicsMode(GFX_OPENGL), filtering(true) {  		}  		bool valid; @@ -201,6 +223,7 @@ private:  #endif  		bool aspectRatioCorrection;  		int graphicsMode; +		bool filtering;  		bool operator==(const VideoState &right) {  			return gameWidth == right.gameWidth && gameHeight == right.gameHeight @@ -208,7 +231,8 @@ private:  			    && gameFormat == right.gameFormat  #endif  			    && aspectRatioCorrection == right.aspectRatioCorrection -			    && graphicsMode == right.graphicsMode; +			    && graphicsMode == right.graphicsMode +				&& filtering == right.filtering;  		}  		bool operator!=(const VideoState &right) { @@ -281,6 +305,36 @@ private:  	//  	/** +	 * Initialize the active context for use. +	 */ +	void initializeGLContext(); + +	/** +	 * Render back buffer. +	 */ +	Backbuffer _backBuffer; + +	/** +	 * OpenGL pipeline used for rendering. +	 */ +	Pipeline *_pipeline; + +protected: +	/** +	 * Query the address of an OpenGL function by name. +	 * +	 * This can only be used after a context has been created. +	 * Please note that this function can return valid addresses even if the +	 * OpenGL context does not support the function. +	 * +	 * @param name The name of the OpenGL function. +	 * @return An function pointer for the requested OpenGL function or +	 *         nullptr in case of failure. +	 */ +	virtual void *getProcAddress(const char *name) const = 0; + +private: +	/**  	 * Try to determine the internal parameters for a given pixel format.  	 *  	 * @return true when the format can be used, false otherwise. @@ -348,7 +402,7 @@ private:  	/**  	 * The virtual game screen.  	 */ -	Texture *_gameScreen; +	Surface *_gameScreen;  	/**  	 * The game palette if in CLUT8 mode. @@ -367,7 +421,7 @@ private:  	/**  	 * The overlay screen.  	 */ -	Texture *_overlay; +	Surface *_overlay;  	/**  	 * Whether the overlay is visible or not. @@ -386,7 +440,7 @@ private:  	/**  	 * The cursor image.  	 */ -	Texture *_cursor; +	Surface *_cursor;  	/**  	 * X coordinate of the cursor in phyiscal coordinates. @@ -495,29 +549,52 @@ protected:  private:  	/** -	 * The OSD's contents. +	 * Request for the OSD icon surface to be updated. +	 */ +	bool _osdMessageChangeRequest; + +	/** +	 * The next OSD message. +	 * +	 * If this value is not empty, the OSD message will be set +	 * to it on the next frame.  	 */ -	Texture *_osd; +	Common::String _osdMessageNextData;  	/** -	 * Current opacity level of the OSD. +	 * Set the OSD message surface with the value of the next OSD message.  	 */ -	uint8 _osdAlpha; +	void osdMessageUpdateSurface();  	/** -	 * When fading the OSD has started. +	 * The OSD message's contents.  	 */ -	uint32 _osdFadeStartTime; +	Surface *_osdMessageSurface; + +	/** +	 * Current opacity level of the OSD message. +	 */ +	uint8 _osdMessageAlpha; + +	/** +	 * When fading the OSD message has started. +	 */ +	uint32 _osdMessageFadeStartTime; + +	enum { +		kOSDMessageFadeOutDelay = 2 * 1000, +		kOSDMessageFadeOutDuration = 500, +		kOSDMessageInitialAlpha = 80 +	};  	/** -	 * Mutex to allow displayMessageOnOSD to be used from the audio thread. +	 * The OSD background activity icon's contents.  	 */ -	Common::Mutex _osdMutex; +	Surface *_osdIconSurface;  	enum { -		kOSDFadeOutDelay = 2 * 1000, -		kOSDFadeOutDuration = 500, -		kOSDInitialAlpha = 80 +		kOSDIconTopMargin = 10, +		kOSDIconRightMargin = 10  	};  #endif  }; | 
