1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Still try to fix opengl backend

- no success
+ make backend selection configurable
This commit is contained in:
AlexVinS
2014-05-24 16:14:37 +04:00
committed by AlexVinS
parent d289c6a34a
commit 3db7fb4f63
3 changed files with 22 additions and 14 deletions

View File

@@ -70,7 +70,7 @@ CGuiHandler GH;
static CClient *client=nullptr; static CClient *client=nullptr;
#ifndef VCMI_SDL1 #ifndef VCMI_SDL1
int preferedDriverIndex = -1; int preferredDriverIndex = -1;
SDL_Window * mainWindow = nullptr; SDL_Window * mainWindow = nullptr;
SDL_Renderer * mainRenderer = nullptr; SDL_Renderer * mainRenderer = nullptr;
SDL_Texture * screenTexture = nullptr; SDL_Texture * screenTexture = nullptr;
@@ -361,6 +361,7 @@ int main(int argc, char** argv)
#ifndef VCMI_SDL1 #ifndef VCMI_SDL1
int driversCount = SDL_GetNumRenderDrivers(); int driversCount = SDL_GetNumRenderDrivers();
std::string preferredDriverName = video["driver"].String();
logGlobal->infoStream() << "Found " << driversCount << " render drivers"; logGlobal->infoStream() << "Found " << driversCount << " render drivers";
@@ -371,11 +372,12 @@ int main(int argc, char** argv)
std::string driverName(info.name); std::string driverName(info.name);
logGlobal->infoStream() << "\t" << driverName; logGlobal->infoStream() << "\t" << driverName;
if(driverName == "opengl") if(!preferredDriverName.empty() && driverName == preferredDriverName)
{ {
preferedDriverIndex = it; preferredDriverIndex = it;
logGlobal->infoStream() << "\t\twill select this"; logGlobal->infoStream() << "\t\twill select this";
} }
} }
@@ -874,11 +876,12 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen)
if(fullscreen) if(fullscreen)
{ {
//in full-screen mode always use desktop resolution //in full-screen mode always use desktop resolution
mainWindow = SDL_CreateWindow(NAME.c_str(), SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED, 0, 0, SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_OPENGL); mainWindow = SDL_CreateWindow(NAME.c_str(), SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED, 0, 0, SDL_WINDOW_FULLSCREEN_DESKTOP);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
} }
else else
{ {
mainWindow = SDL_CreateWindow(NAME.c_str(), SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED, w, h, SDL_WINDOW_OPENGL); mainWindow = SDL_CreateWindow(NAME.c_str(), SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED, w, h, 0);
} }
@@ -889,8 +892,8 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen)
} }
//create first available renderer if "opengl" not found. Use no flags, so HW accelerated will be preferred but SW renderer also will possible //create first available renderer if preferred not set. Use no flags, so HW accelerated will be preferred but SW renderer also will possible
mainRenderer = SDL_CreateRenderer(mainWindow,preferedDriverIndex,0); mainRenderer = SDL_CreateRenderer(mainWindow,preferredDriverIndex,0);
if(nullptr == mainRenderer) if(nullptr == mainRenderer)
{ {

View File

@@ -490,12 +490,12 @@ Uint32 CSDL_Ext::colorToUint32(const SDL_Color * color)
void CSDL_Ext::update(SDL_Surface * what) void CSDL_Ext::update(SDL_Surface * what)
{ {
#ifdef VCMI_SDL1 // #ifdef VCMI_SDL1
if(what) // if(what)
SDL_UpdateRect(what, 0, 0, what->w, what->h); SDL_UpdateRect(what, 0, 0, what->w, what->h);
#else // #else
SDL_UpdateTexture(screenTexture, NULL, what->pixels, what->pitch); // SDL_UpdateTexture(screenTexture, NULL, what->pixels, what->pitch);
#endif // #endif
} }
void CSDL_Ext::drawBorder(SDL_Surface * sur, int x, int y, int w, int h, const int3 &color) void CSDL_Ext::drawBorder(SDL_Surface * sur, int x, int y, int w, int h, const int3 &color)
{ {

View File

@@ -49,7 +49,7 @@
"type" : "object", "type" : "object",
"additionalProperties" : false, "additionalProperties" : false,
"default": {}, "default": {},
"required" : [ "screenRes", "bitsPerPixel", "fullscreen", "spellbookAnimation" ], "required" : [ "screenRes", "bitsPerPixel", "fullscreen", "spellbookAnimation","driver"],
"properties" : { "properties" : {
"screenRes" : { "screenRes" : {
"type" : "object", "type" : "object",
@@ -73,6 +73,11 @@
"type" : "boolean", "type" : "boolean",
"default" : true "default" : true
}, },
"driver":{
"type" : "string",
"default" : "opengl",
"description" : "preferred graphics backend driver name for SDL2"
}
} }
}, },
"adventure" : { "adventure" : {