2010-07-05 03:21:48 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BACKENDS_GRAPHICS_OPENGL_H
|
|
|
|
#define BACKENDS_GRAPHICS_OPENGL_H
|
|
|
|
|
2010-07-10 22:47:29 +00:00
|
|
|
#include "backends/graphics/opengl/gltexture.h"
|
2010-07-05 03:21:48 +00:00
|
|
|
#include "backends/graphics/graphics.h"
|
2010-07-16 23:50:46 +00:00
|
|
|
#include "common/events.h"
|
2010-07-05 03:21:48 +00:00
|
|
|
|
2010-07-26 06:03:55 +00:00
|
|
|
// Uncomment this to enable the 'on screen display' code.
|
|
|
|
#define USE_OSD 1
|
|
|
|
|
2010-07-13 05:38:10 +00:00
|
|
|
namespace OpenGL {
|
|
|
|
|
2010-07-05 03:21:48 +00:00
|
|
|
enum {
|
2010-07-13 05:38:10 +00:00
|
|
|
GFX_NORMAL = 0,
|
|
|
|
GFX_DOUBLESIZE = 1,
|
|
|
|
GFX_TRIPLESIZE = 2
|
2010-07-05 03:21:48 +00:00
|
|
|
};
|
|
|
|
|
2010-07-13 05:38:10 +00:00
|
|
|
}
|
|
|
|
|
2010-07-05 03:21:48 +00:00
|
|
|
/**
|
|
|
|
* Open GL graphics manager
|
|
|
|
*/
|
2010-07-16 23:50:46 +00:00
|
|
|
class OpenGLGraphicsManager : public GraphicsManager, public Common::EventObserver {
|
2010-07-05 03:21:48 +00:00
|
|
|
public:
|
|
|
|
OpenGLGraphicsManager();
|
|
|
|
virtual ~OpenGLGraphicsManager();
|
|
|
|
|
|
|
|
virtual bool hasFeature(OSystem::Feature f);
|
|
|
|
virtual void setFeatureState(OSystem::Feature f, bool enable);
|
|
|
|
virtual bool getFeatureState(OSystem::Feature f);
|
|
|
|
|
2010-07-30 03:31:05 +00:00
|
|
|
static const OSystem::GraphicsMode *supportedGraphicsModes();
|
2010-07-05 03:21:48 +00:00
|
|
|
virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const;
|
|
|
|
virtual int getDefaultGraphicsMode() const;
|
|
|
|
virtual bool setGraphicsMode(int mode);
|
|
|
|
virtual int getGraphicsMode() const;
|
2010-07-30 03:06:57 +00:00
|
|
|
virtual void resetGraphicsScale();
|
2010-07-05 03:21:48 +00:00
|
|
|
#ifdef USE_RGB_COLOR
|
|
|
|
virtual Graphics::PixelFormat getScreenFormat() const;
|
2010-07-13 04:31:15 +00:00
|
|
|
virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const = 0;
|
2010-07-05 03:21:48 +00:00
|
|
|
#endif
|
|
|
|
virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format = NULL);
|
|
|
|
virtual int getScreenChangeID() const;
|
|
|
|
|
|
|
|
virtual void beginGFXTransaction();
|
|
|
|
virtual OSystem::TransactionError endGFXTransaction();
|
|
|
|
|
|
|
|
virtual int16 getHeight();
|
|
|
|
virtual int16 getWidth();
|
|
|
|
virtual void setPalette(const byte *colors, uint start, uint num);
|
|
|
|
virtual void grabPalette(byte *colors, uint start, uint num);
|
|
|
|
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
|
|
|
|
virtual Graphics::Surface *lockScreen();
|
|
|
|
virtual void unlockScreen();
|
|
|
|
virtual void fillScreen(uint32 col);
|
|
|
|
virtual void updateScreen();
|
|
|
|
virtual void setShakePos(int shakeOffset);
|
|
|
|
virtual void setFocusRectangle(const Common::Rect& rect);
|
|
|
|
virtual void clearFocusRectangle();
|
|
|
|
|
|
|
|
virtual void showOverlay();
|
|
|
|
virtual void hideOverlay();
|
|
|
|
virtual Graphics::PixelFormat getOverlayFormat() const;
|
|
|
|
virtual void clearOverlay();
|
|
|
|
virtual void grabOverlay(OverlayColor *buf, int pitch);
|
|
|
|
virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h);
|
|
|
|
virtual int16 getOverlayHeight();
|
|
|
|
virtual int16 getOverlayWidth();
|
|
|
|
|
|
|
|
virtual bool showMouse(bool visible);
|
|
|
|
virtual void warpMouse(int x, int y);
|
|
|
|
virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL);
|
|
|
|
virtual void setCursorPalette(const byte *colors, uint start, uint num);
|
|
|
|
virtual void disableCursorPalette(bool disable);
|
|
|
|
|
|
|
|
virtual void displayMessageOnOSD(const char *msg);
|
|
|
|
|
2010-07-16 23:50:46 +00:00
|
|
|
// Override from Common::EventObserver
|
|
|
|
bool notifyEvent(const Common::Event &event);
|
2010-07-12 06:00:19 +00:00
|
|
|
|
2010-07-05 03:21:48 +00:00
|
|
|
protected:
|
2010-07-19 05:36:10 +00:00
|
|
|
|
|
|
|
virtual void initGL();
|
2010-07-22 15:36:50 +00:00
|
|
|
virtual void loadTextures();
|
2010-07-19 05:36:10 +00:00
|
|
|
|
2010-07-18 03:25:58 +00:00
|
|
|
//
|
|
|
|
// GFX and video
|
|
|
|
//
|
2010-07-11 04:32:24 +00:00
|
|
|
enum {
|
|
|
|
kTransactionNone = 0,
|
|
|
|
kTransactionActive = 1,
|
|
|
|
kTransactionRollback = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TransactionDetails {
|
|
|
|
bool sizeChanged;
|
|
|
|
bool needHotswap;
|
|
|
|
bool needUpdatescreen;
|
2010-07-20 04:32:31 +00:00
|
|
|
bool newContext;
|
2010-07-22 15:36:50 +00:00
|
|
|
bool filterChanged;
|
2010-07-11 04:32:24 +00:00
|
|
|
#ifdef USE_RGB_COLOR
|
|
|
|
bool formatChanged;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
TransactionDetails _transactionDetails;
|
|
|
|
int _transactionMode;
|
|
|
|
|
2010-07-24 05:54:51 +00:00
|
|
|
enum {
|
|
|
|
kAspectRatioNone,
|
|
|
|
kAspectRatioConserve,
|
|
|
|
kAspectRatio4_3,
|
2010-07-27 07:30:56 +00:00
|
|
|
kAspectRatio16_9,
|
2010-07-24 05:54:51 +00:00
|
|
|
kAspectRatio16_10
|
|
|
|
};
|
|
|
|
|
2010-07-11 04:32:24 +00:00
|
|
|
struct VideoState {
|
|
|
|
bool setup;
|
|
|
|
|
|
|
|
bool fullscreen;
|
2010-07-27 07:30:56 +00:00
|
|
|
int activeFullscreenMode;
|
2010-07-24 05:54:51 +00:00
|
|
|
int aspectRatioCorrection;
|
2010-07-11 04:32:24 +00:00
|
|
|
|
|
|
|
int mode;
|
|
|
|
int scaleFactor;
|
2010-07-22 15:36:50 +00:00
|
|
|
bool antialiasing;
|
2010-07-11 04:32:24 +00:00
|
|
|
|
|
|
|
int screenWidth, screenHeight;
|
|
|
|
int overlayWidth, overlayHeight;
|
|
|
|
int hardwareWidth, hardwareHeight;
|
|
|
|
#ifdef USE_RGB_COLOR
|
|
|
|
Graphics::PixelFormat format;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
VideoState _videoMode, _oldVideoMode;
|
2010-07-12 06:00:19 +00:00
|
|
|
|
2010-07-18 03:25:58 +00:00
|
|
|
virtual void getGLPixelFormat(Graphics::PixelFormat pixelFormat, byte &bpp, GLenum &glFormat, GLenum &type);
|
|
|
|
|
|
|
|
virtual void internUpdateScreen();
|
|
|
|
virtual bool loadGFXMode();
|
|
|
|
virtual void unloadGFXMode();
|
|
|
|
|
2010-07-19 05:36:10 +00:00
|
|
|
virtual void setScale(int newScale);
|
2010-07-27 07:30:56 +00:00
|
|
|
|
|
|
|
int _aspectX;
|
|
|
|
int _aspectY;
|
|
|
|
int _aspectWidth;
|
|
|
|
int _aspectHeight;
|
|
|
|
|
2010-07-24 05:54:51 +00:00
|
|
|
virtual void setAspectRatioCorrection(int mode);
|
2010-07-27 07:30:56 +00:00
|
|
|
virtual void refreshAspectRatio();
|
|
|
|
virtual Common::String getAspectRatioName();
|
|
|
|
virtual float getAspectRatio();
|
2010-07-19 05:36:10 +00:00
|
|
|
|
2010-07-26 06:52:58 +00:00
|
|
|
bool _formatBGR;
|
|
|
|
|
2010-07-18 03:25:58 +00:00
|
|
|
//
|
|
|
|
// Game screen
|
|
|
|
//
|
|
|
|
GLTexture* _gameTexture;
|
2010-07-24 05:54:51 +00:00
|
|
|
Graphics::Surface _screenData;
|
2010-07-18 03:25:58 +00:00
|
|
|
int _screenChangeCount;
|
2010-07-24 05:54:51 +00:00
|
|
|
bool _screenNeedsRedraw;
|
|
|
|
Common::Rect _screenDirtyRect;
|
2010-07-18 03:25:58 +00:00
|
|
|
|
|
|
|
#ifdef USE_RGB_COLOR
|
|
|
|
Graphics::PixelFormat _screenFormat;
|
|
|
|
#endif
|
|
|
|
byte *_gamePalette;
|
|
|
|
|
2010-07-24 05:54:51 +00:00
|
|
|
virtual void refreshGameScreen();
|
|
|
|
|
2010-07-18 03:25:58 +00:00
|
|
|
// Shake mode
|
2010-07-27 03:16:10 +00:00
|
|
|
int _shakePos;
|
2010-07-18 03:25:58 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overlay
|
|
|
|
//
|
|
|
|
GLTexture* _overlayTexture;
|
2010-07-24 05:54:51 +00:00
|
|
|
Graphics::Surface _overlayData;
|
2010-07-18 03:25:58 +00:00
|
|
|
Graphics::PixelFormat _overlayFormat;
|
2010-07-24 05:54:51 +00:00
|
|
|
bool _overlayVisible;
|
|
|
|
bool _overlayNeedsRedraw;
|
|
|
|
Common::Rect _overlayDirtyRect;
|
|
|
|
|
|
|
|
virtual void refreshOverlay();
|
2010-07-12 06:00:19 +00:00
|
|
|
|
2010-07-18 03:25:58 +00:00
|
|
|
//
|
|
|
|
// Mouse
|
|
|
|
//
|
2010-07-12 06:00:19 +00:00
|
|
|
struct MousePos {
|
|
|
|
// The mouse position, using either virtual (game) or real
|
|
|
|
// (overlay) coordinates.
|
|
|
|
int16 x, y;
|
|
|
|
|
|
|
|
// The size and hotspot of the original cursor image.
|
|
|
|
int16 w, h;
|
|
|
|
int16 hotX, hotY;
|
|
|
|
|
2010-07-26 04:17:37 +00:00
|
|
|
// The size and hotspot of the scaled cursor, in real
|
2010-07-12 06:00:19 +00:00
|
|
|
// coordinates.
|
2010-07-26 04:17:37 +00:00
|
|
|
int16 rW, rH;
|
|
|
|
int16 rHotX, rHotY;
|
2010-07-12 06:00:19 +00:00
|
|
|
|
2010-07-26 04:17:37 +00:00
|
|
|
// The size and hotspot of the scaled cursor, in game
|
2010-07-12 06:00:19 +00:00
|
|
|
// coordinates.
|
2010-07-26 04:17:37 +00:00
|
|
|
int16 vW, vH;
|
|
|
|
int16 vHotX, vHotY;
|
2010-07-12 06:00:19 +00:00
|
|
|
|
2010-07-26 04:17:37 +00:00
|
|
|
MousePos() : x(0), y(0), w(0), h(0), hotX(0), hotY(0),
|
2010-07-26 06:58:33 +00:00
|
|
|
rW(0), rH(0), rHotX(0), rHotY(0), vW(0), vH(0),
|
|
|
|
vHotX(0), vHotY(0) {}
|
2010-07-12 06:00:19 +00:00
|
|
|
};
|
|
|
|
|
2010-07-18 03:25:58 +00:00
|
|
|
GLTexture* _cursorTexture;
|
2010-07-24 05:54:51 +00:00
|
|
|
Graphics::Surface _cursorData;
|
2010-07-18 03:25:58 +00:00
|
|
|
#ifdef USE_RGB_COLOR
|
|
|
|
Graphics::PixelFormat _cursorFormat;
|
|
|
|
#endif
|
|
|
|
byte *_cursorPalette;
|
2010-07-16 23:50:46 +00:00
|
|
|
bool _cursorPaletteDisabled;
|
2010-07-18 03:25:58 +00:00
|
|
|
MousePos _cursorState;
|
|
|
|
bool _cursorVisible;
|
|
|
|
uint32 _cursorKeyColor;
|
|
|
|
int _cursorTargetScale;
|
|
|
|
bool _cursorNeedsRedraw;
|
|
|
|
|
|
|
|
virtual void refreshCursor();
|
2010-07-26 04:17:37 +00:00
|
|
|
virtual void refreshCursorScale();
|
2010-07-16 23:50:46 +00:00
|
|
|
virtual void adjustMouseEvent(const Common::Event &event);
|
|
|
|
virtual void setMousePos(int x, int y);
|
2010-07-19 05:36:10 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Misc
|
|
|
|
//
|
|
|
|
virtual bool saveScreenshot(const char *filename);
|
2010-07-26 06:03:55 +00:00
|
|
|
|
|
|
|
#ifdef USE_OSD
|
|
|
|
GLTexture *_osdTexture;
|
|
|
|
Graphics::Surface _osdSurface;
|
|
|
|
uint8 _osdAlpha;
|
|
|
|
uint32 _osdFadeStartTime;
|
|
|
|
enum {
|
|
|
|
kOSDFadeOutDelay = 2 * 1000,
|
|
|
|
kOSDFadeOutDuration = 500,
|
|
|
|
kOSDInitialAlpha = 80
|
|
|
|
};
|
|
|
|
#endif
|
2010-07-05 03:21:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|