aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/openglsdl
diff options
context:
space:
mode:
authorAlejandro Marzini2010-07-12 06:00:19 +0000
committerAlejandro Marzini2010-07-12 06:00:19 +0000
commit8b6a670391f1b5103e3761d78eef8f41d64cf8cd (patch)
tree2faf7636191d6e40d4f4aab25e99a708c51a4c9e /backends/graphics/openglsdl
parenta1161feed2e2fcb10ef75d32bdad4df1054e159d (diff)
downloadscummvm-rg350-8b6a670391f1b5103e3761d78eef8f41d64cf8cd.tar.gz
scummvm-rg350-8b6a670391f1b5103e3761d78eef8f41d64cf8cd.tar.bz2
scummvm-rg350-8b6a670391f1b5103e3761d78eef8f41d64cf8cd.zip
OpenGL manager: Implemented PixelFormat functions. Implemented GFX methods. Changed how GLTexture determines its format.
svn-id: r50811
Diffstat (limited to 'backends/graphics/openglsdl')
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.cpp82
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.h7
2 files changed, 82 insertions, 7 deletions
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 589e5aa2c6..6207561c07 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -45,6 +45,81 @@ void OpenGLSdlGraphicsManager::init() {
OpenGLGraphicsManager::init();
}
+#ifdef USE_RGB_COLOR
+
+const Graphics::PixelFormat RGBList[] = {
+#if defined(ENABLE_32BIT)
+ Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), // RGBA8888
+ Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0), // RGB888
+#endif
+ Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), // RGB565
+ Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), // RGB555
+ Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0), // RGBA4444
+};
+
+Common::List<Graphics::PixelFormat> OpenGLSdlGraphicsManager::getSupportedFormats() {
+ static Common::List<Graphics::PixelFormat> list;
+ static bool inited = false;
+
+ if (inited)
+ return list;
+
+ int listLength = ARRAYSIZE(RGBList);
+
+ Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8();
+ if (_hwscreen) {
+ // Get our currently set hardware format
+ format = Graphics::PixelFormat(_hwscreen->format->BytesPerPixel,
+ 8 - _hwscreen->format->Rloss, 8 - _hwscreen->format->Gloss,
+ 8 - _hwscreen->format->Bloss, 8 - _hwscreen->format->Aloss,
+ _hwscreen->format->Rshift, _hwscreen->format->Gshift,
+ _hwscreen->format->Bshift, _hwscreen->format->Ashift);
+
+ // Workaround to MacOSX SDL not providing an accurate Aloss value.
+ if (_hwscreen->format->Amask == 0)
+ format.aLoss = 8;
+
+ // Push it first, as the prefered format.
+ for (int i = 0; i < listLength; i++) {
+ if (RGBList[i] == format) {
+ list.push_back(format);
+ break;
+ }
+ }
+
+ // Mark that we don't need to do this any more.
+ inited = true;
+ }
+
+ for (int i = 0; i < listLength; i++) {
+ if (inited && (RGBList[i].bytesPerPixel > format.bytesPerPixel))
+ continue;
+ if (RGBList[i] != format)
+ list.push_back(RGBList[i]);
+ }
+ //list.push_back(Graphics::PixelFormat::createFormatCLUT8());
+ return list;
+}
+
+#endif
+
+void OpenGLSdlGraphicsManager::warpMouse(int x, int y) {
+ if (_mouseCurState.x != x || _mouseCurState.y != y) {
+ int y1 = y;
+
+ /*if (_videoMode.aspectRatioCorrection && !_overlayVisible)
+ y1 = real2Aspect(y);*/
+
+ if (!_overlayVisible)
+ SDL_WarpMouse(x * _videoMode.scaleFactor, y1 * _videoMode.scaleFactor);
+ else
+ SDL_WarpMouse(x, y1);
+
+ setMousePos(x, y);
+ }
+}
+
+
void OpenGLSdlGraphicsManager::forceFullRedraw() {
}
@@ -61,10 +136,6 @@ void OpenGLSdlGraphicsManager::adjustMouseEvent(Common::Event &event) {
}
-void OpenGLSdlGraphicsManager::setMousePos(int x, int y) {
-
-}
-
void OpenGLSdlGraphicsManager::toggleFullScreen() {
}
@@ -83,7 +154,6 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() {
_videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor;
_videoMode.hardwareHeight = _videoMode.screenHeight * _videoMode.scaleFactor;
-
_hwscreen = SDL_SetVideoMode(_videoMode.hardwareWidth, _videoMode.hardwareHeight, 32,
_videoMode.fullscreen ? (SDL_FULLSCREEN | SDL_OPENGL) : SDL_OPENGL
);
@@ -99,7 +169,7 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() {
}
}
- return true;
+ return OpenGLGraphicsManager::loadGFXMode();
}
void OpenGLSdlGraphicsManager::unloadGFXMode() {
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.h b/backends/graphics/openglsdl/openglsdl-graphics.h
index 9f18489430..0f69793c1b 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.h
+++ b/backends/graphics/openglsdl/openglsdl-graphics.h
@@ -44,11 +44,16 @@ public:
virtual void init();
+#ifdef USE_RGB_COLOR
+ virtual Common::List<Graphics::PixelFormat> getSupportedFormats();
+#endif
+
+ virtual void warpMouse(int x, int y);
+
virtual void forceFullRedraw();
virtual bool handleScalerHotkeys(const SDL_KeyboardEvent &key);
virtual bool isScalerHotkey(const Common::Event &event);
virtual void adjustMouseEvent(Common::Event &event);
- virtual void setMousePos(int x, int y);
virtual void toggleFullScreen();
virtual bool saveScreenshot(const char *filename);