ScummVM API documentation
OpenGL::OpenGLGraphicsManager Class Referenceabstract
Inheritance diagram for OpenGL::OpenGLGraphicsManager:
WindowedGraphicsManager GraphicsManager PaletteManager Common::NonCopyable AndroidGraphicsManager iOSGraphicsManager OpenGLSdlGraphicsManager

Classes

struct  VideoState
 

Public Member Functions

bool hasFeature (OSystem::Feature f) const override
 
void setFeatureState (OSystem::Feature f, bool enable) override
 
bool getFeatureState (OSystem::Feature f) const override
 
const OSystem::GraphicsModegetSupportedGraphicsModes () const override
 
int getDefaultGraphicsMode () const override
 
bool setGraphicsMode (int mode, uint flags=OSystem::kGfxModeNoFlags) override
 
int getGraphicsMode () const override
 
const OSystem::GraphicsModegetSupportedStretchModes () const override
 
int getDefaultStretchMode () const override
 
bool setStretchMode (int mode) override
 
int getStretchMode () const override
 
bool setShader (const Common::Path &fileNode) override
 
void beginGFXTransaction () override
 
OSystem::TransactionError endGFXTransaction () override
 
int getScreenChangeID () const override
 
void initSize (uint width, uint height, const Graphics::PixelFormat *format) override
 
int16 getWidth () const override
 
int16 getHeight () const override
 
void copyRectToScreen (const void *buf, int pitch, int x, int y, int w, int h) override
 
void fillScreen (uint32 col) override
 
void fillScreen (const Common::Rect &r, uint32 col) override
 
void updateScreen () override
 
Graphics::SurfacelockScreen () override
 
void unlockScreen () override
 
void setFocusRectangle (const Common::Rect &rect) override
 
void clearFocusRectangle () override
 
int16 getOverlayWidth () const override
 
int16 getOverlayHeight () const override
 
Graphics::PixelFormat getOverlayFormat () const override
 
void copyRectToOverlay (const void *buf, int pitch, int x, int y, int w, int h) override
 
void clearOverlay () override
 
void grabOverlay (Graphics::Surface &surface) const override
 
void setMouseCursor (const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format, const byte *mask) override
 
void setCursorPalette (const byte *colors, uint start, uint num) override
 
void displayMessageOnOSD (const Common::U32String &msg) override
 
void displayActivityIconOnOSD (const Graphics::Surface *icon) override
 
void setPalette (const byte *colors, uint start, uint num) override
 
void grabPalette (byte *colors, uint start, uint num) const override
 
- Public Member Functions inherited from WindowedGraphicsManager
void showOverlay (bool inGUI) override
 
void hideOverlay () override
 
bool isOverlayVisible () const override
 
void setShakePos (int shakeXOffset, int shakeYOffset) override
 
int getWindowWidth () const
 
int getWindowHeight () const
 
- Public Member Functions inherited from GraphicsManager
virtual uint getDefaultScaler () const
 
virtual uint getDefaultScaleFactor () const
 
virtual bool setScaler (uint mode, int factor)
 
virtual uint getScaler () const
 
virtual uint getScaleFactor () const
 
virtual void initSizeHint (const Graphics::ModeList &modes)
 
virtual float getHiDPIScreenFactor () const
 
virtual void saveScreenshot ()
 
virtual bool lockMouse (bool lock)
 

Protected Types

enum  TransactionMode { kTransactionNone = 0, kTransactionActive = 1, kTransactionRollback = 2 }
 

Protected Member Functions

void renderCursor ()
 
bool isGLESContext () const
 
void notifyContextCreate (ContextType type, Framebuffer *target, const Graphics::PixelFormat &defaultFormat, const Graphics::PixelFormat &defaultFormatAlpha)
 
void notifyContextDestroy ()
 
SurfacecreateSurface (const Graphics::PixelFormat &format, bool wantAlpha=false, bool wantScaler=false, bool wantMask=false)
 
TransactionMode getTransactionMode () const
 
virtual bool loadVideoMode (uint requestedWidth, uint requestedHeight, const Graphics::PixelFormat &format)=0
 
bool loadShader (const Common::Path &fileName)
 
virtual void refreshScreen ()=0
 
bool saveScreenshot (const Common::Path &filename) const
 
bool getGLPixelFormat (const Graphics::PixelFormat &pixelFormat, GLenum &glIntFormat, GLenum &glFormat, GLenum &glType) const
 
bool gameNeedsAspectRatioCorrection () const override
 
int getGameRenderScale () const override
 
void recalculateDisplayAreas () override
 
void handleResizeImpl (const int width, const int height) override
 
void updateLinearFiltering ()
 
PipelinegetPipeline () const
 
void updateCursorPalette ()
 
void recalculateCursorScaling ()
 
virtual const Graphics::FontgetFontOSD () const
 
- Protected Member Functions inherited from WindowedGraphicsManager
Common::Point convertVirtualToWindow (const int x, const int y) const
 
Common::Point convertWindowToVirtual (int x, int y) const
 
frac_t getDesiredGameAspectRatio () const
 
void handleResize (const int width, const int height)
 
virtual void setSystemMousePosition (const int x, const int y)=0
 
virtual void notifyActiveAreaChanged ()
 
bool showMouse (bool visible) override
 
void warpMouse (int x, int y) override
 
void setMousePosition (int x, int y)
 

Protected Attributes

VideoState _currentState
 
VideoState _oldState
 
Graphics::PixelFormat _defaultFormat
 
Graphics::PixelFormat _defaultFormatAlpha
 
Framebuffer_targetBuffer
 
Surface_gameScreen
 
byte _gamePalette [3 *256]
 
Surface_overlay
 
Surface_cursor
 
Surface_cursorMask
 
int _cursorHotspotX
 
int _cursorHotspotY
 
int _cursorHotspotXScaled
 
int _cursorHotspotYScaled
 
float _cursorWidthScaled
 
float _cursorHeightScaled
 
uint32 _cursorKeyColor
 
bool _cursorUseKey
 
bool _cursorDontScale
 
bool _cursorPaletteEnabled
 
byte _cursorPalette [3 *256]
 
- Protected Attributes inherited from WindowedGraphicsManager
int _windowWidth
 
int _windowHeight
 
int _screenAlign
 
bool _overlayVisible
 
bool _overlayInGUI
 
int _gameScreenShakeXOffset
 
int _gameScreenShakeYOffset
 
Common::Rect _gameDrawRect
 
Common::Rect _overlayDrawRect
 
DisplayArea _activeArea
 
bool _forceRedraw
 
bool _cursorVisible
 
bool _cursorNeedsRedraw
 
bool _cursorLastInActiveArea
 
int _cursorX
 
int _cursorY
 

Member Function Documentation

◆ setPalette()

void OpenGL::OpenGLGraphicsManager::setPalette ( const byte *  colors,
uint  start,
uint  num 
)
overridevirtual

Replace the specified range of the palette with new colors. The palette entries from 'start' till (start+num-1) will be replaced - so a full palette update is accomplished via start=0, num=256.

The palette data is specified in interleaved RGB format. That is, the first byte of the memory block 'colors' points at is the red component of the first new color; the second byte the green component of the first new color; the third byte the blue component, the last byte to the alpha (transparency) value. Then the second color starts, and so on. So memory looks like this: R1-G1-B1-R2-G2-B2-R3-...

Parameters
colorsthe new palette data, in interleaved RGB format
startthe first palette entry to be updated
numthe number of palette entries to be updated
Note
It is an error if start+num exceeds 256, behavior is undefined in that case (the backend may ignore it silently or assert).
It is an error if this function gets called when the pixel format in use (the return value of getScreenFormat) has more than one byte per pixel.
See also
getScreenFormat

Implements GraphicsManager.

◆ grabPalette()

void OpenGL::OpenGLGraphicsManager::grabPalette ( byte *  colors,
uint  start,
uint  num 
) const
overridevirtual

Grabs a specified part of the currently active palette. The format is the same as for setPalette.

This should return exactly the same RGB data as was setup via previous setPalette calls.

For example, for every valid value of start and num of the following code:

byte origPal[num*3]; // Setup origPal's data however you like g_system->setPalette(origPal, start, num); byte obtainedPal[num*3]; g_system->grabPalette(obtainedPal, start, num);

the following should be true:

memcmp(origPal, obtainedPal, num*3) == 0

See also
setPalette
Parameters
colorsthe palette data, in interleaved RGB format
startthe first platte entry to be read
numthe number of palette entries to be read
Note
It is an error if this function gets called when the pixel format in use (the return value of getScreenFormat) has more than one byte per pixel.
See also
getScreenFormat

Implements GraphicsManager.

◆ isGLESContext()

bool OpenGL::OpenGLGraphicsManager::isGLESContext ( ) const
inlineprotected

Whether a GLES or GLES2 context is active.

◆ notifyContextCreate()

void OpenGL::OpenGLGraphicsManager::notifyContextCreate ( ContextType  type,
Framebuffer target,
const Graphics::PixelFormat defaultFormat,
const Graphics::PixelFormat defaultFormatAlpha 
)
protected

Notify the manager of a OpenGL context change. This should be the first thing to call after you created an OpenGL (ES) context!

Parameters
typeType of the OpenGL (ES) contexts created.
defaultFormatThe new default format for the game screen (this is used for the CLUT8 game screens).
defaultFormatAlphaThe new default format with an alpha channel (this is used for the overlay and cursor).

◆ notifyContextDestroy()

void OpenGL::OpenGLGraphicsManager::notifyContextDestroy ( )
protected

Notify the manager that the OpenGL context is about to be destroyed. This will free up/reset internal OpenGL related state and must be called whenever a context might be created again after destroying a context.

◆ createSurface()

Surface* OpenGL::OpenGLGraphicsManager::createSurface ( const Graphics::PixelFormat format,
bool  wantAlpha = false,
bool  wantScaler = false,
bool  wantMask = false 
)
protected

Create a surface with the specified pixel format.

Parameters
formatThe pixel format the Surface object should accept as input.
wantAlphaFor CLUT8 surfaces this marks whether an alpha channel should be used.
wantScalerWhether or not a software scaler should be used.
Returns
A pointer to the surface or nullptr on failure.

◆ loadVideoMode()

virtual bool OpenGL::OpenGLGraphicsManager::loadVideoMode ( uint  requestedWidth,
uint  requestedHeight,
const Graphics::PixelFormat format 
)
protectedpure virtual

Set up the requested video mode. This takes parameters which describe what resolution the game screen requests (this is possibly aspect ratio corrected!).

A sub-class should take these parameters as hints. It might very well set up a mode which it thinks suites the situation best.

requestedWidth This is the requested actual game screen width.

Parameters
requestedHeightThis is the requested actual game screen height.
formatThis is the requested pixel format of the virtual game screen.
Returns
true on success, false otherwise

Implemented in AndroidGraphicsManager, iOSGraphicsManager, and OpenGLSdlGraphicsManager.

◆ refreshScreen()

virtual void OpenGL::OpenGLGraphicsManager::refreshScreen ( )
protectedpure virtual

Refresh the screen contents.

Implemented in AndroidGraphicsManager, iOSGraphicsManager, and OpenGLSdlGraphicsManager.

◆ saveScreenshot()

bool OpenGL::OpenGLGraphicsManager::saveScreenshot ( const Common::Path filename) const
protected

Saves a screenshot of the entire window, excluding window decorations.

Parameters
filenameThe output filename.
Returns
true on success, false otherwise

◆ getGLPixelFormat()

bool OpenGL::OpenGLGraphicsManager::getGLPixelFormat ( const Graphics::PixelFormat pixelFormat,
GLenum &  glIntFormat,
GLenum &  glFormat,
GLenum &  glType 
) const
protected

Try to determine the internal parameters for a given pixel format.

Returns
true when the format can be used, false otherwise.

◆ gameNeedsAspectRatioCorrection()

bool OpenGL::OpenGLGraphicsManager::gameNeedsAspectRatioCorrection ( ) const
overrideprotectedvirtual
Returns
whether or not the game screen must have aspect ratio correction applied for correct rendering.

Implements WindowedGraphicsManager.

◆ getGameRenderScale()

int OpenGL::OpenGLGraphicsManager::getGameRenderScale ( ) const
overrideprotectedvirtual
Returns
the scale used between the game size and the surface on which it is rendered.

Reimplemented from WindowedGraphicsManager.

◆ recalculateDisplayAreas()

void OpenGL::OpenGLGraphicsManager::recalculateDisplayAreas ( )
overrideprotectedvirtual

Recalculates the display areas for the game and overlay surfaces within the window.

Reimplemented from WindowedGraphicsManager.

◆ handleResizeImpl()

void OpenGL::OpenGLGraphicsManager::handleResizeImpl ( const int  width,
const int  height 
)
overrideprotectedvirtual

Backend-specific implementation for updating internal surfaces that need to reflect the new window size.

Implements WindowedGraphicsManager.

Reimplemented in OpenGLSdlGraphicsManager.

◆ updateCursorPalette()

void OpenGL::OpenGLGraphicsManager::updateCursorPalette ( )
protected

Set up the correct cursor palette.

◆ recalculateCursorScaling()

void OpenGL::OpenGLGraphicsManager::recalculateCursorScaling ( )
protected

Recalculate the cursor scaling. Scaling is always done according to the game screen.

◆ getFontOSD()

virtual const Graphics::Font* OpenGL::OpenGLGraphicsManager::getFontOSD ( ) const
protectedvirtual

Returns the font used for on screen display

Member Data Documentation

◆ _currentState

VideoState OpenGL::OpenGLGraphicsManager::_currentState
protected

The currently set up video state.

◆ _oldState

VideoState OpenGL::OpenGLGraphicsManager::_oldState
protected

The old video state used when doing a transaction rollback.

◆ _defaultFormat

Graphics::PixelFormat OpenGL::OpenGLGraphicsManager::_defaultFormat
protected

The default pixel format of the backend.

◆ _defaultFormatAlpha

Graphics::PixelFormat OpenGL::OpenGLGraphicsManager::_defaultFormatAlpha
protected

The default pixel format with an alpha channel.

◆ _targetBuffer

Framebuffer* OpenGL::OpenGLGraphicsManager::_targetBuffer
protected

Render target.

◆ _gameScreen

Surface* OpenGL::OpenGLGraphicsManager::_gameScreen
protected

The rendering surface for the virtual game screen.

◆ _gamePalette

byte OpenGL::OpenGLGraphicsManager::_gamePalette[3 *256]
protected

The game palette if in CLUT8 mode.

◆ _overlay

Surface* OpenGL::OpenGLGraphicsManager::_overlay
protected

The rendering surface for the overlay.

◆ _cursor

Surface* OpenGL::OpenGLGraphicsManager::_cursor
protected

The rendering surface for the mouse cursor.

◆ _cursorMask

Surface* OpenGL::OpenGLGraphicsManager::_cursorMask
protected

The rendering surface for the opacity and inversion mask (if any)

◆ _cursorHotspotX

int OpenGL::OpenGLGraphicsManager::_cursorHotspotX
protected

The X offset for the cursor hotspot in unscaled game coordinates.

◆ _cursorHotspotY

int OpenGL::OpenGLGraphicsManager::_cursorHotspotY
protected

The Y offset for the cursor hotspot in unscaled game coordinates.

◆ _cursorHotspotXScaled

int OpenGL::OpenGLGraphicsManager::_cursorHotspotXScaled
protected

The X offset for the cursor hotspot in scaled game display area coordinates.

◆ _cursorHotspotYScaled

int OpenGL::OpenGLGraphicsManager::_cursorHotspotYScaled
protected

The Y offset for the cursor hotspot in scaled game display area coordinates.

◆ _cursorWidthScaled

float OpenGL::OpenGLGraphicsManager::_cursorWidthScaled
protected

The width of the cursor in scaled game display area coordinates.

◆ _cursorHeightScaled

float OpenGL::OpenGLGraphicsManager::_cursorHeightScaled
protected

The height of the cursor in scaled game display area coordinates.

◆ _cursorKeyColor

uint32 OpenGL::OpenGLGraphicsManager::_cursorKeyColor
protected

The key color.

◆ _cursorUseKey

bool OpenGL::OpenGLGraphicsManager::_cursorUseKey
protected

If true, use key color.

◆ _cursorDontScale

bool OpenGL::OpenGLGraphicsManager::_cursorDontScale
protected

Whether no cursor scaling should be applied.

◆ _cursorPaletteEnabled

bool OpenGL::OpenGLGraphicsManager::_cursorPaletteEnabled
protected

Whether the special cursor palette is enabled.

◆ _cursorPalette

byte OpenGL::OpenGLGraphicsManager::_cursorPalette[3 *256]
protected

The special cursor palette in case enabled.


The documentation for this class was generated from the following file: