# HG changeset patch # User prock@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1286469884 0 # Node ID 685d250f2c2dea77d9eae2823579196f5ef4d5c4 # Parent 980c02db2f56920d02073c3274da9d1b9d182e26 * Improvements for DeviceCaps. It now stores a list of valid SDL drivers. Currently in windows we are limited to the windows GDI (which is slow). This could mean that SDL users could benifit from hardware acceleration with directx (a valid SDL driver). diff -r 980c02db2f56 -r 685d250f2c2d engine/core/controller/engine.i --- a/engine/core/controller/engine.i Thu Oct 07 16:15:09 2010 +0000 +++ b/engine/core/controller/engine.i Thu Oct 07 16:44:44 2010 +0000 @@ -21,7 +21,6 @@ %module fife %{ #include "controller/engine.h" -#include "video/devicecaps.h" %} namespace FIFE { diff -r 980c02db2f56 -r 685d250f2c2d engine/core/video/devicecaps.cpp --- a/engine/core/video/devicecaps.cpp Thu Oct 07 16:15:09 2010 +0000 +++ b/engine/core/video/devicecaps.cpp Thu Oct 07 16:44:44 2010 +0000 @@ -50,6 +50,7 @@ } DeviceCaps::DeviceCaps() : + m_driverName("Invalid"), m_hwAvailable(false), m_wmAvailable(false), m_hwBlitAccel(false), @@ -60,12 +61,54 @@ m_swToHwAlphaBlitAccel(false), m_BlitFillAccel(false), m_videoMem(0) { + + fillAvailableDrivers(); } DeviceCaps::~DeviceCaps() { } + void DeviceCaps::reset() { + m_screenModes.clear(); + m_driverName = "Invalid"; + m_hwAvailable = false; + m_wmAvailable = false; + m_hwBlitAccel = false; + m_hwCCBlitAccel = false; + m_hwToHwAlphaBlitAccel = false; + m_swToHwBlitAccel = false; + m_swToHwCCBlistAccel = false; + m_swToHwAlphaBlitAccel = false; + m_BlitFillAccel = false; + m_videoMem = 0; + } + + + void DeviceCaps::fillAvailableDrivers() { + m_availableDrivers.clear(); +#if defined( __unix__ ) + m_availableDrivers.push_back("x11"); + m_availableDrivers.push_back("nanox"); + m_availableDrivers.push_back("qtopia"); + m_availableDrivers.push_back("fbcon"); + m_availableDrivers.push_back("directfb"); + m_availableDrivers.push_back("svgalib"); +#endif + +// Win32 +#if defined( WIN32 ) + m_availableDrivers.push_back("directx"); + m_availableDrivers.push_back("windib"); +#endif + +// Macintosh +#if defined( __APPLE_CC__ ) + m_availableDrivers.push_back("Quartz"); + m_availableDrivers.push_back("x11"); +#endif + } + void DeviceCaps::fillDeviceCaps() { int bufferSize = 256; char buffer[bufferSize]; @@ -75,6 +118,9 @@ SDL_Rect **modes; + //clear in case this is called twice + reset(); + //FLAGS #ifdef HAVE_OPENGL int numFlags = 4; @@ -105,6 +151,11 @@ for (int j = 0; j < numFlags; ++j) { modes = SDL_ListModes(NULL, flags[j]); + if (modes == (SDL_Rect**)0) { + //no modes found + break; + } + if (modes == (SDL_Rect**)-1) { //All screen modes are available with the specified flags (a windowed mode most likely) ScreenMode mode = ScreenMode(0, 0, bpps[i], flags[j]); @@ -119,6 +170,7 @@ m_screenModes.push_back(mode); } } + modes = (SDL_Rect**)0; } } diff -r 980c02db2f56 -r 685d250f2c2d engine/core/video/devicecaps.h --- a/engine/core/video/devicecaps.h Thu Oct 07 16:15:09 2010 +0000 +++ b/engine/core/video/devicecaps.h Thu Oct 07 16:44:44 2010 +0000 @@ -98,7 +98,20 @@ */ ~DeviceCaps(); + /** Should be called AFTER SDL_Init() has been called + */ void fillDeviceCaps(); + + /** Clears all information gathered for the device + */ + void reset(); + + /** Gets the available graphics drivers for your operating system + */ + std::vector getAvailableDrivers() const { return m_availableDrivers; }; + + /** Returns a vector containing screen modes. + */ std::vector getSupportedScreenModes() const { return m_screenModes; }; /** Returns the name of the current video driver. @@ -148,6 +161,7 @@ private: std::vector m_screenModes; std::string m_driverName; + std::vector m_availableDrivers; bool m_hwAvailable; bool m_wmAvailable; @@ -161,6 +175,9 @@ uint32_t m_videoMem; + /** Called in the constructor. No need for anyone to call this + */ + void fillAvailableDrivers(); }; //DeviceCaps } diff -r 980c02db2f56 -r 685d250f2c2d engine/core/video/video.i --- a/engine/core/video/video.i Thu Oct 07 16:15:09 2010 +0000 +++ b/engine/core/video/video.i Thu Oct 07 16:44:44 2010 +0000 @@ -249,7 +249,7 @@ void fillDeviceCaps(); std::vector getSupportedScreenModes() const; std::string getDriverName() const; - + std::vector getAvailableDrivers() const; bool isHwSurfaceAvail() const; bool isWindowManagerAvail() const; bool isHwBlitAccel() const;