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" 50 class 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,
bool dontScale,
const Graphics::PixelFormat *format,
const byte *mask)
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; }
159 void notifyContextCreate(
171 void notifyContextDestroy();
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;
292 virtual void refreshScreen() = 0;
300 bool saveScreenshot(
const Common::Path &filename)
const;
303 using WindowedGraphicsManager::saveScreenshot;
313 void initializeGLContext();
333 bool getGLPixelFormat(
const Graphics::PixelFormat &pixelFormat, GLenum &glIntFormat, GLenum &glFormat, GLenum &glType)
const;
335 bool gameNeedsAspectRatioCorrection()
const override;
336 int getGameRenderScale()
const override;
337 void recalculateDisplayAreas()
override;
338 void handleResizeImpl(
const int width,
const int height)
override;
340 void updateTextureSettings();
342 Pipeline *getPipeline()
const {
return _pipeline; }
364 #if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS) 368 Renderer3D *_renderer3d;
374 byte _gamePalette[3 * 256];
392 void updateCursorPalette();
418 void recalculateCursorScaling();
465 byte _cursorPalette[3 * 256];
488 bool _osdMessageChangeRequest;
501 void osdMessageUpdateSurface();
511 uint8 _osdMessageAlpha;
516 uint32 _osdMessageFadeStartTime;
519 kOSDMessageFadeOutDelay = 2 * 1000,
520 kOSDMessageFadeOutDuration = 500,
521 kOSDMessageInitialAlpha = 80
530 kOSDIconTopMargin = 10,
531 kOSDIconRightMargin = 10
Definition: libretro.h:50
VideoState _oldState
Definition: opengl-graphics.h:238
bool _cursorPaletteEnabled
Definition: opengl-graphics.h:460
Feature
Definition: system.h:405
Definition: framebuffer.h:38
int _cursorHotspotY
Definition: opengl-graphics.h:412
bool _cursorDontScale
Definition: opengl-graphics.h:455
Surface * _overlay
Definition: opengl-graphics.h:383
Surface * _cursorMask
Definition: opengl-graphics.h:402
float _cursorWidthScaled
Definition: opengl-graphics.h:435
Definition: windowed.h:52
Surface * _cursor
Definition: opengl-graphics.h:397
int _cursorHotspotXScaled
Definition: opengl-graphics.h:424
TransactionError
Definition: system.h:1168
Framebuffer * _targetBuffer
Definition: opengl-graphics.h:357
uint32 _cursorKeyColor
Definition: opengl-graphics.h:445
Definition: opengl-graphics.h:60
Definition: formatinfo.h:28
Definition: renderbuffer.h:27
VideoState _currentState
Definition: opengl-graphics.h:233
bool isGLESContext() const
Definition: opengl-graphics.h:147
Graphics::PixelFormat _defaultFormat
Definition: opengl-graphics.h:347
float _cursorHeightScaled
Definition: opengl-graphics.h:440
int _cursorHotspotYScaled
Definition: opengl-graphics.h:430
int _cursorHotspotX
Definition: opengl-graphics.h:407
bool _cursorUseKey
Definition: opengl-graphics.h:450
Surface * _gameScreen
Definition: opengl-graphics.h:362
Definition: opengl-graphics.h:188
Graphics::PixelFormat _defaultFormatAlpha
Definition: opengl-graphics.h:352
Definition: pipeline.h:40