# HG changeset patch # User koda # Date 1316914327 -7200 # Node ID 652a199d4f38f5becbec0839f5a1f63294dd89bf # Parent c792d4b3e08076a2d9de3d2e0db684eaaea9d4f1 some hopefully harmless experiments diff -r c792d4b3e080 -r 652a199d4f38 hedgewars/SDLh.pas --- a/hedgewars/SDLh.pas Sun Sep 25 02:28:33 2011 +0200 +++ b/hedgewars/SDLh.pas Sun Sep 25 03:32:07 2011 +0200 @@ -776,6 +776,7 @@ function SDL_CreateRenderer(window: PSDL_Window; index, flags: LongInt): PSDL_Renderer; cdecl; external SDLLibName; function SDL_DestroyWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName; function SDL_DestroyRenderer(renderer: PSDL_Renderer): LongInt; cdecl; external SDLLibName; +procedure SDL_SetWindowSize(window: PSDL_Window; w, h: LongInt); cdecl; external SDLLibName; function SDL_GL_CreateContext(window: PSDL_Window): PSDL_GLContext; cdecl; external SDLLibName; procedure SDL_GL_DeleteContext(context: PSDL_GLContext); cdecl; external SDLLibName; diff -r c792d4b3e080 -r 652a199d4f38 hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Sun Sep 25 02:28:33 2011 +0200 +++ b/hedgewars/hwengine.pas Sun Sep 25 03:32:07 2011 +0200 @@ -188,6 +188,12 @@ else if event.window.event = SDL_WINDOWEVENT_RESTORED then begin GameState:= previousGameState; + end + else if event.window.event = SDL_WINDOWEVENT_RESIZED then + begin + cNewScreenWidth:= max(2 * (event.window.data1 div 2), cMinScreenWidth); + cNewScreenHeight:= max(2 * (event.window.data2 div 2), cMinScreenHeight); + cScreenResizeDelay:= RealTicks+500; end; {$ELSE} KeyPressChat(event.key.keysym.unicode); diff -r c792d4b3e080 -r 652a199d4f38 hedgewars/uStore.pas --- a/hedgewars/uStore.pas Sun Sep 25 02:28:33 2011 +0200 +++ b/hedgewars/uStore.pas Sun Sep 25 03:32:07 2011 +0200 @@ -587,7 +587,11 @@ procedure SetupOpenGL; //var vendor: shortstring = ''; +var buf: array[byte] of char; begin + buf[0]:= char(0); // avoid compiler hint + AddFileLog('Setting up OpenGL (using driver: ' + shortstring(SDL_VideoDriverName(buf, sizeof(buf))) + ')'); + {$IFDEF SDL13} // this function creates an opengles1.1 context by default on mobile devices // use SDL_GL_SetAttribute to change this behaviour @@ -945,18 +949,16 @@ procedure chFullScr(var s: shortstring); var flags: Longword = 0; - ico: PSDL_Surface; - buf: array[byte] of char; + {$IFNDEF IPHONEOS}ico: PSDL_Surface;{$ENDIF} reinit: boolean; {$IFDEF SDL13}x, y: LongInt;{$ENDIF} begin if Length(s) = 0 then cFullScreen:= not cFullScreen else cFullScreen:= s = '1'; - buf[0]:= char(0); // avoid compiler hint AddFileLog('Preparing to change video parameters...'); - reinit:= false; +{$IFNDEF IPHONEOS} if SDLPrimSurface = nil then begin // set window title @@ -990,6 +992,7 @@ SDL_FreeSurface(SDLPrimSurface); SDLPrimSurface:= nil; end; +{$ENDIF} // these attributes must be set up before creating the sdl window {$IFNDEF WIN32} @@ -1014,8 +1017,9 @@ flags:= flags or SDL_WINDOW_BORDERLESS or SDL_WINDOW_RESIZABLE; {$ENDIF} - if cFullScreen then SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cOrigScreenWidth, cOrigScreenHeight, flags or SDL_WINDOW_FULLSCREEN) - else SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags); + if SDLwindow = nil then + if cFullScreen then SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cOrigScreenWidth, cOrigScreenHeight, flags or SDL_WINDOW_FULLSCREEN) + else SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags); SDLTry(SDLwindow <> nil, true); {$ELSE} flags:= SDL_OPENGL or SDL_RESIZABLE; @@ -1034,7 +1038,6 @@ end; {$ENDIF} - AddFileLog('Setting up OpenGL (using driver: ' + shortstring(SDL_VideoDriverName(buf, sizeof(buf))) + ')'); SetupOpenGL(); if reinit then begin