update sdl apis to use the new rendering functions
authorkoda
Mon, 07 Feb 2011 23:12:56 +0100
changeset 4933 86bd82d58a0b
parent 4932 f11d80bac7ed
child 4934 727da72f754a
update sdl apis to use the new rendering functions
hedgewars/SDLh.pas
hedgewars/hwengine.pas
hedgewars/uStore.pas
hedgewars/uVariables.pas
project_files/HedgewarsMobile/SDL.patch
--- a/hedgewars/SDLh.pas	Sun Feb 06 21:50:29 2011 +0300
+++ b/hedgewars/SDLh.pas	Mon Feb 07 23:12:56 2011 +0100
@@ -358,6 +358,7 @@
 
 {$IFDEF SDL13}
     PSDL_Window = pointer;
+    PSDL_Renderer = pointer;
     PSDL_Texture = pointer;
 
     TSDL_WindowEvent = record
@@ -715,24 +716,23 @@
 
 {$IFDEF SDL13}
 function  SDL_CreateWindow(title: PChar; x,y,w,h, flags: LongInt): PSDL_Window; cdecl; external SDLLibName;
-function  SDL_CreateRenderer(window: PSDL_Window; index, flags: LongInt): LongInt; cdecl; external SDLLibName;
-function  SDL_SetRenderDrawColor(r,g,b,a: byte): LongInt; cdecl; external SDLLibName;
-function  SDL_DestroyRenderer(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
+function  SDL_CreateRenderer(window: PSDL_Window; index, flags: LongInt): PSDL_Renderer; cdecl; external SDLLibName;
+function  SDL_DestroyRenderer(renderer: PSDL_Renderer): LongInt; cdecl; external SDLLibName;
 function  SDL_DestroyWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
+procedure SDL_VideoQuit; cdecl; external SDLLibName;
 function  SDL_SelectVideoDisplay(index: LongInt): LongInt; cdecl; external SDLLibName;
 function  SDL_GetNumVideoDisplays: LongInt; cdecl; external SDLLibName;
 
-function  SDL_RenderFill(rect: PSDL_Rect): LongInt;
-function  SDL_RenderFillRect(rect: PSDL_Rect): LongInt; cdecl; external SDLLibName;
-function  SDL_RenderClear: LongInt; cdecl; external SDLLibName;
-procedure SDL_RenderPresent; cdecl; external SDLLibName;
-procedure SDL_VideoQuit; cdecl; external SDLLibName;
+function  SDL_SetRenderDrawColor(renderer: PSDL_Renderer; r,g,b,a: byte): LongInt; cdecl; external SDLLibName;
+function  SDL_RenderFillRect(renderer: PSDL_Renderer; rect: PSDL_Rect): LongInt; cdecl; external SDLLibName;
+function  SDL_RenderClear(renderer: PSDL_Renderer): LongInt; cdecl; external SDLLibName;
+procedure SDL_RenderPresent(renderer: PSDL_Renderer); cdecl; external SDLLibName;
+function  SDL_RenderReadPixels(renderer: PSDL_Renderer; rect: PSDL_Rect; format: LongInt; pixels: pointer; pitch: LongInt): LongInt; cdecl; external SDLLibName;
 
 function  SDL_SelectMouse(index: LongInt): LongInt; cdecl; external SDLLibName;
 function  SDL_GetRelativeMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
 function  SDL_GetNumMice: LongInt; cdecl; external SDLLibName;
 function  SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): boolean; cdecl; external SDLLibName;
-function  SDL_RenderReadPixels(rect: PSDL_Rect; format: LongInt; pixels: pointer; pitch: LongInt): LongInt; cdecl; external SDLLibName;
 {$ENDIF}
 
 function  SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName {$IFDEF SDL13} name 'SDL_GetKeyboardState'{$ENDIF};
@@ -891,15 +891,5 @@
                   (PByteArray(buf)^[0] shl 24)
 end;
 
-{$IFDEF SDL13}
-function SDL_RenderFill(rect: PSDL_Rect): LongInt;
-var res: LongInt;
-begin
-    if (rect <> nil) then res:= SDL_RenderFillRect(rect)
-    else res:= SDL_RenderClear();
-    exit(res);
-end;
-{$ENDIF}
-
 end.
 
--- a/hedgewars/hwengine.pas	Sun Feb 06 21:50:29 2011 +0300
+++ b/hedgewars/hwengine.pas	Mon Feb 07 23:12:56 2011 +0100
@@ -104,7 +104,7 @@
         end;
 
 {$IFDEF SDL13}
-    SDL_RenderPresent();
+    SDL_RenderPresent(SDLrender);
 {$ELSE}
     SDL_GL_SwapBuffers();
 {$ENDIF}
@@ -130,7 +130,8 @@
     CloseIPC();
     TTF_Quit();
 {$IFDEF SDL13}
-    SDL_DestroyRenderer(SDLwindow);
+    SDL_RenderClear(SDLrender);
+    SDL_DestroyRenderer(SDLrender);
     SDL_DestroyWindow(SDLwindow);
 {$ENDIF}
     SDL_Quit();
--- a/hedgewars/uStore.pas	Sun Feb 06 21:50:29 2011 +0300
+++ b/hedgewars/uStore.pas	Mon Feb 07 23:12:56 2011 +0100
@@ -689,7 +689,7 @@
 
     SDL_GL_SwapBuffers();
 {$IFDEF SDL13}
-    SDL_RenderPresent();
+    SDL_RenderPresent(SDLrender);
 {$ENDIF}
     inc(Step);
 
@@ -932,12 +932,12 @@
         SDLwindow:= SDL_CreateWindow('Hedgewars', 0, 0, cScreenWidth, cScreenHeight,
                         SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN
                         {$IFDEF IPHONEOS} or SDL_WINDOW_BORDERLESS{$ENDIF});
-        SDL_CreateRenderer(SDLwindow, -1, 0);
+        SDLrender:= SDL_CreateRenderer(SDLwindow, -1, 1 and 2);
     end;
 
-    SDL_SetRenderDrawColor(0, 0, 0, 255);
-    SDL_RenderFill(nil);
-    SDL_RenderPresent();
+    SDL_SetRenderDrawColor(SDLrender,0, 0, 0, 255);
+    SDL_RenderClear(SDLrender);
+    SDL_RenderPresent(SDLrender);
 {$ELSE}
     SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
     SDLTry(SDLPrimSurface <> nil, true);
--- a/hedgewars/uVariables.pas	Sun Feb 06 21:50:29 2011 +0300
+++ b/hedgewars/uVariables.pas	Mon Feb 07 23:12:56 2011 +0100
@@ -141,6 +141,7 @@
 
 {$IFDEF SDL13}
     SDLwindow       : PSDL_Window;
+    SDLrender       : PSDL_Renderer;
 {$ENDIF}
 
     WorldDx: LongInt;
@@ -2337,6 +2338,7 @@
 
 {$IFDEF SDL13}
     SDLwindow       := nil;
+    SDLrender       := nil;
 {$ENDIF}
 
     // those values still are not perfect
--- a/project_files/HedgewarsMobile/SDL.patch	Sun Feb 06 21:50:29 2011 +0300
+++ b/project_files/HedgewarsMobile/SDL.patch	Mon Feb 07 23:12:56 2011 +0100
@@ -1,7 +1,7 @@
-diff -r f2c2f0ecba5f Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj
---- a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Sun Jan 30 13:42:05 2011 -0800
-+++ b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Mon Jan 31 23:57:58 2011 +0100
-@@ -1564,11 +1564,15 @@
+diff -r 1fbe1c202501 Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj
+--- a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Mon Feb 07 10:40:21 2011 -0800
++++ b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Mon Feb 07 23:10:55 2011 +0100
+@@ -1603,11 +1603,15 @@
  			isa = XCBuildConfiguration;
  			buildSettings = {
  				ALWAYS_SEARCH_USER_PATHS = NO;
@@ -17,7 +17,7 @@
  				IPHONEOS_DEPLOYMENT_TARGET = 3.1;
  				ONLY_ACTIVE_ARCH = NO;
  				PREBINDING = NO;
-@@ -1581,12 +1585,18 @@
+@@ -1620,12 +1624,18 @@
  			isa = XCBuildConfiguration;
  			buildSettings = {
  				ALWAYS_SEARCH_USER_PATHS = NO;
@@ -37,20 +37,9 @@
  				PREBINDING = NO;
  				SDKROOT = iphoneos;
  				TARGETED_DEVICE_FAMILY = "1,2";
-diff -r f2c2f0ecba5f Xcode-iPhoneOS/SDL/testsdl-Info.plist
---- a/Xcode-iPhoneOS/SDL/testsdl-Info.plist	Sun Jan 30 13:42:05 2011 -0800
-+++ b/Xcode-iPhoneOS/SDL/testsdl-Info.plist	Mon Jan 31 23:57:58 2011 +0100
-@@ -16,7 +16,5 @@
- 	<string>????</string>
- 	<key>CFBundleVersion</key>
- 	<string>1.0</string>
--	<key>NSMainNibFile</key>
--	<string>MainWindow</string>
- </dict>
- </plist>
-diff -r f2c2f0ecba5f include/SDL_config_iphoneos.h
---- a/include/SDL_config_iphoneos.h	Sun Jan 30 13:42:05 2011 -0800
-+++ b/include/SDL_config_iphoneos.h	Mon Jan 31 23:57:58 2011 +0100
+diff -r 1fbe1c202501 include/SDL_config_iphoneos.h
+--- a/include/SDL_config_iphoneos.h	Mon Feb 07 10:40:21 2011 -0800
++++ b/include/SDL_config_iphoneos.h	Mon Feb 07 23:10:55 2011 +0100
 @@ -119,7 +119,7 @@
  /* enable iPhone version of Core Audio driver */
  #define SDL_AUDIO_DRIVER_COREAUDIOIPHONE 1
@@ -60,7 +49,7 @@
  
  /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */
  #define SDL_HAPTIC_DISABLED	1
-@@ -140,14 +140,17 @@
+@@ -140,15 +140,18 @@
  
  /* Supported video drivers */
  #define SDL_VIDEO_DRIVER_UIKIT	1
@@ -70,6 +59,8 @@
  /* enable OpenGL ES */
  #define SDL_VIDEO_OPENGL_ES	1
  #define SDL_VIDEO_RENDER_OGL_ES	1
+-#define SDL_VIDEO_RENDER_OGL_ES2	1
++#define SDL_VIDEO_RENDER_OGL_ES2	0
  
  /* Enable system power support */
 -#define SDL_POWER_UIKIT 1
@@ -80,7 +71,7 @@
  
  /* enable iPhone keyboard support */
  #define SDL_IPHONE_KEYBOARD 1
-@@ -157,4 +160,7 @@
+@@ -158,4 +161,7 @@
   */
  #define SDL_IPHONE_MAX_GFORCE 5.0
  
@@ -88,182 +79,3 @@
 +#define SDL_VIEW_TAG 456987
 +
  #endif /* _SDL_config_iphoneos_h */
-diff -r f2c2f0ecba5f src/video/SDL_video.c
---- a/src/video/SDL_video.c	Sun Jan 30 13:42:05 2011 -0800
-+++ b/src/video/SDL_video.c	Mon Jan 31 23:57:58 2011 +0100
-@@ -1414,9 +1414,9 @@
-         SDL_MinimizeWindow(window);
-     }
- 
--    if (display->gamma && _this->SetDisplayGammaRamp) {
-+    /*if (display->gamma && _this->SetDisplayGammaRamp) {
-         _this->SetDisplayGammaRamp(_this, display, display->saved_gamma);
--    }
-+    }*/
-     if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN))
-         && _this->SetWindowGrab) {
-         _this->SetWindowGrab(_this, window);
-diff -r f2c2f0ecba5f src/video/uikit/SDL_uikitopengles.m
---- a/src/video/uikit/SDL_uikitopengles.m	Sun Jan 30 13:42:05 2011 -0800
-+++ b/src/video/uikit/SDL_uikitopengles.m	Mon Jan 31 23:57:58 2011 +0100
-@@ -115,6 +115,7 @@
- 									aBits: _this->gl_config.alpha_size \
- 									depthBits: _this->gl_config.depth_size];
- 	
-+	view.tag = SDL_VIEW_TAG;
- 	data->view = view;
- 	
- 	/* add the view to our window */
-diff -r f2c2f0ecba5f src/video/uikit/SDL_uikitopenglview.m
---- a/src/video/uikit/SDL_uikitopenglview.m	Sun Jan 30 13:42:05 2011 -0800
-+++ b/src/video/uikit/SDL_uikitopenglview.m	Mon Jan 31 23:57:58 2011 +0100
-@@ -117,6 +117,8 @@
- 			return NO;
- 		}
- 		/* end create buffers */
-+            if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
-+                self.contentScaleFactor = [UIScreen mainScreen].scale;
- 	}
- 	return self;
- }
-diff -r f2c2f0ecba5f src/video/uikit/SDL_uikitview.h
---- a/src/video/uikit/SDL_uikitview.h	Sun Jan 30 13:42:05 2011 -0800
-+++ b/src/video/uikit/SDL_uikitview.h	Mon Jan 31 23:57:58 2011 +0100
-@@ -23,11 +23,11 @@
- #include "SDL_stdinc.h"
- #include "SDL_events.h"
- 
--#define IPHONE_TOUCH_EFFICIENT_DANGEROUS
--#define FIXED_MULTITOUCH
-+#undef IPHONE_TOUCH_EFFICIENT_DANGEROUS
-+#undef FIXED_MULTITOUCH
- 
- #ifndef IPHONE_TOUCH_EFFICIENT_DANGEROUS
--#define MAX_SIMULTANEOUS_TOUCHES 5
-+#define MAX_SIMULTANEOUS_TOUCHES 0
- #endif
- 
- /* *INDENT-OFF* */
-diff -r f2c2f0ecba5f src/video/uikit/SDL_uikitview.m
---- a/src/video/uikit/SDL_uikitview.m	Sun Jan 30 13:42:05 2011 -0800
-+++ b/src/video/uikit/SDL_uikitview.m	Mon Jan 31 23:57:58 2011 +0100
-@@ -298,6 +298,7 @@
- 
- /* Terminates the editing session */
- - (BOOL)textFieldShouldReturn:(UITextField*)_textField {
-+	SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RETURN);
- 	[self hideKeyboard];
- 	return YES;
- }
-@@ -312,7 +313,7 @@
- int SDL_iPhoneKeyboardShow(SDL_Window * window) {
- 	
- 	SDL_WindowData *data;
--	SDL_uikitview *view;
-+	SDL_uikitview *view = NULL;
- 	
- 	if (NULL == window) {
- 		SDL_SetError("Window does not exist");
-@@ -320,7 +321,8 @@
- 	}
- 	
- 	data = (SDL_WindowData *)window->driverdata;
--	view = data->view;
-+	if (data != NULL)
-+            view = data->view;
- 	
- 	if (nil == view) {
- 		SDL_SetError("Window has no view");
-@@ -335,7 +337,7 @@
- int SDL_iPhoneKeyboardHide(SDL_Window * window) {
- 	
- 	SDL_WindowData *data;
--	SDL_uikitview *view;
-+	SDL_uikitview *view = NULL;
- 	
- 	if (NULL == window) {
- 		SDL_SetError("Window does not exist");
-@@ -343,7 +345,8 @@
- 	}	
- 	
- 	data = (SDL_WindowData *)window->driverdata;
--	view = data->view;
-+	if (data != NULL)
-+            view = data->view;
- 	
- 	if (NULL == view) {
- 		SDL_SetError("Window has no view");
-@@ -358,7 +361,7 @@
- SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) {
- 	
- 	SDL_WindowData *data;
--	SDL_uikitview *view;
-+	SDL_uikitview *view = NULL;
- 	
- 	if (NULL == window) {
- 		SDL_SetError("Window does not exist");
-@@ -366,7 +369,8 @@
- 	}	
- 	
- 	data = (SDL_WindowData *)window->driverdata;
--	view = data->view;
-+	if (data != NULL)
-+            view = data->view;
- 	
- 	if (NULL == view) {
- 		SDL_SetError("Window has no view");
-@@ -380,7 +384,7 @@
- int SDL_iPhoneKeyboardToggle(SDL_Window * window) {
- 	
- 	SDL_WindowData *data;
--	SDL_uikitview *view;
-+	SDL_uikitview *view = NULL;
- 	
- 	if (NULL == window) {
- 		SDL_SetError("Window does not exist");
-@@ -388,7 +392,8 @@
- 	}	
- 	
- 	data = (SDL_WindowData *)window->driverdata;
--	view = data->view;
-+	if (data != NULL)
-+            view = data->view;
- 	
- 	if (NULL == view) {
- 		SDL_SetError("Window has no view");
-diff -r f2c2f0ecba5f src/video/uikit/SDL_uikitwindow.m
---- a/src/video/uikit/SDL_uikitwindow.m	Sun Jan 30 13:42:05 2011 -0800
-+++ b/src/video/uikit/SDL_uikitwindow.m	Mon Jan 31 23:57:58 2011 +0100
-@@ -145,7 +145,10 @@
-     if (SDL_UIKit_supports_multiple_displays) {
-         [uiwindow setScreen:uiscreen];
-     }
--
-+    
-+    if ([UIScreen respondsToSelector:@selector(screens)] && [[UIScreen screens] count] > 1)
-+        uiwindow.screen = [[UIScreen screens] objectAtIndex:1];
-+    
-     if (SetupWindowData(_this, window, uiwindow, SDL_TRUE) < 0) {
-         [uiwindow release];
-         return -1;
-diff -r f2c2f0ecba5f src/video/uikit/keyinfotable.h
---- a/src/video/uikit/keyinfotable.h	Sun Jan 30 13:42:05 2011 -0800
-+++ b/src/video/uikit/keyinfotable.h	Mon Jan 31 23:57:58 2011 +0100
-@@ -54,7 +54,7 @@
- /*  10 */ {   SDL_SCANCODE_UNKNOWN, 0 },
- /*  11 */ {   SDL_SCANCODE_UNKNOWN, 0 },
- /*  12 */ {   SDL_SCANCODE_UNKNOWN, 0 },
--/*  13 */ {   SDL_SCANCODE_UNKNOWN, 0 },
-+/*  13 */ {   SDL_SCANCODE_RETURN, 0 },
- /*  14 */ {   SDL_SCANCODE_UNKNOWN, 0 },
- /*  15 */ {   SDL_SCANCODE_UNKNOWN, 0 },
- /*  16 */ {   SDL_SCANCODE_UNKNOWN, 0 },
-@@ -137,7 +137,7 @@
- /*  93 */ {   SDL_SCANCODE_RIGHTBRACKET, 0 },
- /*  94 */ {   SDL_SCANCODE_6,  KMOD_SHIFT },			/* plus shift modifier '^' */
- /*  95 */ {   SDL_SCANCODE_MINUS,  KMOD_SHIFT },		/* plus shift modifier '_' */
--/*  96 */ {   SDL_SCANCODE_GRAVE,  KMOD_SHIFT },		/* '`'
-+/*  96 */ {   SDL_SCANCODE_GRAVE,  KMOD_SHIFT },		/* '`' */
- /*  97 */ {   SDL_SCANCODE_A, 0	},	
- /*  98 */ {   SDL_SCANCODE_B, 0 },
- /*  99 */ {   SDL_SCANCODE_C, 0 },