From 2a4af1573b385f1c30ce376eee1385581d42beab Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 4 Mar 2012 12:46:55 +0100 Subject: auto adjust the screen resolution on first start. Closes #921 --- src/engine/client/backend_sdl.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/engine/client/backend_sdl.cpp') 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()); -- cgit 1.4.1