hedgewars/uStore.pas
changeset 7049 35d762458d66
parent 7043 7c080e5ac8d0
child 7082 17b0892ac794
child 7085 953a9d896df1
--- a/hedgewars/uStore.pas	Thu May 10 23:21:56 2012 +0200
+++ b/hedgewars/uStore.pas	Fri May 11 00:05:47 2012 +0200
@@ -41,16 +41,22 @@
 procedure FreeWeaponTooltip;
 procedure MakeCrossHairs;
 
+procedure WarpMouse(x, y: Word); inline;
+procedure SwapBuffers; inline;
+
 implementation
-uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands, uDebug, uWorld;
+uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands,
+     uDebug{$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF};
 
 //type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple);
 
 var MaxTextureSize: LongInt;
+{$IFDEF SDL13}
+    SDLwindow: PSDL_Window;
+    SDLGLcontext: PSDL_GLContext;
+{$ELSE}
     SDLPrimSurface: PSDL_Surface;
-{$IFDEF SDL13}SDLGLcontext: PSDL_GLContext;{$ENDIF}
-
-//    cGPUVendor: TGPUVendor;
+{$ENDIF}
 
 function WriteInRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect;
 var w, h: LongInt;
@@ -794,11 +800,7 @@
 
     DrawTextureFromRect( -squaresize div 2, (cScreenHeight - squaresize) shr 1, @r, ProgrTex);
 
-{$IFDEF SDL13}
-    SDL_GL_SwapWindow(SDLwindow);
-{$ELSE}
-    SDL_GL_SwapBuffers();
-{$ENDIF}
+    SwapBuffers;
     inc(Step);
 end;
 
@@ -1124,13 +1126,10 @@
 begin
     RegisterVariable('fullscr', @chFullScr, true);
 
-    SDLPrimSurface:= nil;
-
     cScaleFactor:= 2.0;
     Step:= 0;
     ProgrTex:= nil;
     SupportNPOTT:= false;
-//    cGPUVendor:= gvUnknown;
 
     // init all ammo name texture pointers
     for ai:= Low(TAmmoType) to High(TAmmoType) do
@@ -1141,7 +1140,10 @@
     for i:= Low(CountTexz) to High(CountTexz) do
         CountTexz[i] := nil;
 {$IFDEF SDL13}
-    SDLGLcontext    := nil;
+    SDLwindow:= nil;
+    SDLGLcontext:= nil;
+{$ELSE}
+    SDLPrimSurface:= nil;
 {$ENDIF}
 end;
 
@@ -1156,4 +1158,22 @@
     SDL_Quit();
 end;
 
+procedure WarpMouse(x, y: Word); inline;
+begin
+{$IFDEF SDL13}
+    SDL_WarpMouseInWindow(SDLwindow, x, y);
+{$ELSE}
+    x:= x; y:= y; // avoid hints
+{$ENDIF}
+end;
+
+procedure SwapBuffers; inline;
+begin
+{$IFDEF SDL13}
+    SDL_GL_SwapWindow(SDLwindow);
+{$ELSE}
+    SDL_GL_SwapBuffers();
+{$ENDIF}
+end;
+
 end.