22#ifndef BACKENDS_GRAPHICS_OPENGL_OPENGL_GRAPHICS_H
23#define BACKENDS_GRAPHICS_OPENGL_OPENGL_GRAPHICS_H
25#include "backends/graphics/opengl/framebuffer.h"
26#include "backends/graphics/windowed.h"
28#include "base/plugins.h"
30#include "common/frac.h"
31#include "common/mutex.h"
32#include "common/ustr.h"
34#include "graphics/surface.h"
50class LibRetroPipeline;
52#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
71 int getDefaultGraphicsMode()
const override;
73 int getGraphicsMode()
const override;
81 int getDefaultStretchMode()
const override;
82 bool setStretchMode(
int mode)
override;
83 int getStretchMode()
const override;
86 uint getDefaultScaler()
const override;
87 uint getDefaultScaleFactor()
const override;
88 bool setScaler(uint mode,
int factor)
override;
89 uint getScaler()
const override;
90 uint getScaleFactor()
const override;
97 void beginGFXTransaction()
override;
100 int getScreenChangeID()
const override;
104 int16 getWidth()
const override;
105 int16 getHeight()
const override;
107 void copyRectToScreen(
const void *buf,
int pitch,
int x,
int y,
int w,
int h)
override;
108 void fillScreen(uint32 col)
override;
109 void fillScreen(
const Common::Rect &r, uint32 col)
override;
111 void updateScreen()
override;
112 void presentBuffer()
override;
115 void unlockScreen()
override;
117 void setFocusRectangle(
const Common::Rect& rect)
override;
118 void clearFocusRectangle()
override;
120 int16 getOverlayWidth()
const override;
121 int16 getOverlayHeight()
const override;
122 void showOverlay(
bool inGUI)
override;
123 void hideOverlay()
override;
127 void copyRectToOverlay(
const void *buf,
int pitch,
int x,
int y,
int w,
int h)
override;
128 void clearOverlay()
override;
131 void setMouseCursor(
const void *buf, uint w, uint h,
int hotspotX,
int hotspotY, uint32 keycolor,
const Graphics::PixelFormat *format,
const byte *mask,
frac_t scaleX,
frac_t scaleY)
override;
132 void setCursorPalette(
const byte *colors, uint start, uint num)
override;
138 void setPalette(
const byte *colors, uint start, uint num)
override;
139 void grabPalette(
byte *colors, uint start, uint num)
const override;
147 bool isGLESContext()
const {
return OpenGLContext.type == kContextGLES || OpenGLContext.type == kContextGLES2; }
189 VideoState() : valid(
false), gameWidth(0), gameHeight(0),
193 aspectRatioCorrection(
false), graphicsMode(GFX_OPENGL), flags(0),
194 filtering(
true), scalerIndex(0), scaleFactor(1), shader() {
199 uint gameWidth, gameHeight;
203 bool aspectRatioCorrection;
214 return gameWidth == right.gameWidth && gameHeight == right.gameHeight
216 && gameFormat == right.gameFormat
218 && aspectRatioCorrection == right.aspectRatioCorrection
219 && graphicsMode == right.graphicsMode
220 && flags == right.flags
221 && filtering == right.filtering
222 && shader == right.shader;
226 return !(*
this == right);
241 enum TransactionMode {
242 kTransactionNone = 0,
243 kTransactionActive = 1,
244 kTransactionRollback = 2
247 TransactionMode getTransactionMode()
const {
return _transactionMode; }
253 TransactionMode _transactionMode;
285 virtual bool loadVideoMode(uint requestedWidth, uint requestedHeight,
bool resizable,
int antialiasing) = 0;
303 using WindowedGraphicsManager::saveScreenshot;
313 void initializeGLContext();
340 void updateTextureSettings();
342 Pipeline *getPipeline()
const {
return _pipeline; }
364#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
368 Renderer3D *_renderer3d;
493 bool _osdMessageChangeRequest;
506 void osdMessageUpdateSurface();
516 uint8 _osdMessageAlpha;
521 uint32 _osdMessageFadeStartTime;
524 kOSDMessageFadeOutDelay = 2 * 1000,
525 kOSDMessageFadeOutDuration = 500,
526 kOSDMessageInitialAlpha = 80
535 kOSDIconTopMargin = 10,
536 kOSDIconRightMargin = 10
Definition: framebuffer.h:38
Definition: libretro.h:50
Definition: opengl-graphics.h:60
virtual const Graphics::Font * getFontOSD() const
void recalculateCursorScaling()
void notifyContextCreate(ContextType type, Framebuffer *target, const Graphics::PixelFormat &defaultFormat, const Graphics::PixelFormat &defaultFormatAlpha)
VideoState _oldState
Definition: opengl-graphics.h:238
bool isGLESContext() const
Definition: opengl-graphics.h:147
Surface * _gameScreen
Definition: opengl-graphics.h:362
Graphics::PixelFormat _defaultFormatAlpha
Definition: opengl-graphics.h:352
Surface * _cursor
Definition: opengl-graphics.h:397
Graphics::PixelFormat _defaultFormat
Definition: opengl-graphics.h:347
void updateCursorPalette()
Surface * _overlay
Definition: opengl-graphics.h:383
int _cursorHotspotYScaled
Definition: opengl-graphics.h:430
void notifyContextDestroy()
int _cursorHotspotXScaled
Definition: opengl-graphics.h:424
byte _gamePalette[3 *256]
Definition: opengl-graphics.h:374
int _cursorHotspotY
Definition: opengl-graphics.h:412
float _cursorScaleX
Definition: opengl-graphics.h:455
virtual void refreshScreen()=0
Framebuffer * _targetBuffer
Definition: opengl-graphics.h:357
float _cursorHeightScaled
Definition: opengl-graphics.h:440
uint32 _cursorKeyColor
Definition: opengl-graphics.h:445
byte _cursorPalette[3 *256]
Definition: opengl-graphics.h:470
bool getGLPixelFormat(const Graphics::PixelFormat &pixelFormat, GLenum &glIntFormat, GLenum &glFormat, GLenum &glType) const
bool _cursorUseKey
Definition: opengl-graphics.h:450
bool _cursorPaletteEnabled
Definition: opengl-graphics.h:465
int getGameRenderScale() const override
Surface * createSurface(const Graphics::PixelFormat &format, bool wantAlpha=false, bool wantScaler=false, bool wantMask=false)
void setPalette(const byte *colors, uint start, uint num) override
Surface * _cursorMask
Definition: opengl-graphics.h:402
bool gameNeedsAspectRatioCorrection() const override
void grabPalette(byte *colors, uint start, uint num) const override
void recalculateDisplayAreas() override
VideoState _currentState
Definition: opengl-graphics.h:233
virtual bool loadVideoMode(uint requestedWidth, uint requestedHeight, bool resizable, int antialiasing)=0
int _cursorHotspotX
Definition: opengl-graphics.h:407
float _cursorWidthScaled
Definition: opengl-graphics.h:435
void handleResizeImpl(const int width, const int height) override
float _cursorScaleY
Definition: opengl-graphics.h:460
bool saveScreenshot(const Common::Path &filename) const
Definition: pipeline.h:40
Definition: windowed.h:52
int32 frac_t
Definition: frac.h:52
Feature
Definition: system.h:415
TransactionError
Definition: system.h:1188
@ kGfxModeNoFlags
Definition: system.h:790
Definition: formatinfo.h:28
Definition: opengl-graphics.h:188