Mercurial > fife-parpg
diff engine/core/video/devicecaps.cpp @ 639:685d250f2c2d
* 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).
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 07 Oct 2010 16:44:44 +0000 |
parents | 3822b30fd98c |
children | 6e2151325017 |
line wrap: on
line diff
--- 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; } }