about summary refs log tree commit diff
path: root/src/engine/client/backend_sdl.cpp
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2012-03-04 12:46:55 +0100
committeroy <Tom_Adams@web.de>2013-02-24 17:25:55 +0100
commit2a4af1573b385f1c30ce376eee1385581d42beab (patch)
tree063e19c50895094adef5379eaaa1f8caa5ae8299 /src/engine/client/backend_sdl.cpp
parent38256d0d45ff929796cc85d0dfcb39242290f3ba (diff)
downloadzcatch-2a4af1573b385f1c30ce376eee1385581d42beab.tar.gz
zcatch-2a4af1573b385f1c30ce376eee1385581d42beab.zip
auto adjust the screen resolution on first start. Closes #921
Diffstat (limited to 'src/engine/client/backend_sdl.cpp')
-rw-r--r--src/engine/client/backend_sdl.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp
index e7975aca..b04b729e 100644
--- a/src/engine/client/backend_sdl.cpp
+++ b/src/engine/client/backend_sdl.cpp
@@ -388,7 +388,7 @@ void CCommandProcessor_SDL_OpenGL::RunBuffer(CCommandBuffer *pBuffer)
 
 // ------------ CGraphicsBackend_SDL_OpenGL
 
-int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int Width, int Height, int FsaaSamples, int Flags)
+int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags)
 {
 	if(!SDL_WasInit(SDL_INIT_VIDEO))
 	{
@@ -407,6 +407,13 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int Width, int Height,
 	const SDL_VideoInfo *pInfo = SDL_GetVideoInfo();
 	SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); // prevent stuck mouse cursor sdl-bug when loosing fullscreen focus in windows
 
+	// use current resolution as default
+	if(*Width == 0 || *Height == 0)
+	{
+		*Width = pInfo->current_w;
+		*Height = pInfo->current_h;
+	}
+
 	// set flags
 	int SdlFlags = SDL_OPENGL;
 	if(Flags&IGraphicsBackend::INITFLAG_RESIZABLE)
@@ -442,7 +449,7 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int Width, int Height,
 	SDL_WM_SetCaption(pName, pName);
 
 	// create window
-	m_pScreenSurface = SDL_SetVideoMode(Width, Height, 0, SdlFlags);
+	m_pScreenSurface = SDL_SetVideoMode(*Width, *Height, 0, SdlFlags);
 	if(!m_pScreenSurface)
 	{
 		dbg_msg("gfx", "unable to set video mode: %s", SDL_GetError());