DEADSOFTWARE

gl: fix build for gles (still not work on android)
[d2df-sdl.git] / src / game / renders / opengl / r_render.pas
index 202500d6170fbe92ddd1416d47811ce01e071656..b896b06cc189757131193261a53e450a576b8bdb 100644 (file)
@@ -82,17 +82,16 @@ interface
 implementation
 
   uses
-    {$IFDEF USE_GLES1}
-      GLES11,
-    {$ELSE}
-      GL, GLEXT,
-    {$ENDIF}
+    {$I ../../../nogl/noGLuses.inc}
     {$IFDEF ENABLE_MENU}
       r_gui,
     {$ENDIF}
     {$IFDEF ENABLE_SYSTEM}
       g_system,
     {$ENDIF}
+    {$IFDEF ENABLE_TOUCH}
+      r_touch,
+    {$ENDIF}
     {$IFDEF ENABLE_HOLMES}
       r_holmes,
     {$ENDIF}
@@ -202,7 +201,11 @@ implementation
     info.maximized := gRC_Maximized;
     info.major := 1;
     info.minor := 1;
-    info.profile := TGLProfile.Compat;
+    {$IFDEF USE_GLES1}
+      info.profile := TGLProfile.Common;
+    {$ELSE}
+      info.profile := TGLProfile.Compat;
+    {$ENDIF}
     result := info;
   end;
 {$ENDIF}
@@ -214,6 +217,9 @@ implementation
         raise Exception.Create('Failed to set videomode on startup.');
       sys_EnableVSync(gVSync);
     {$ENDIF}
+    {$IFDEF NOGL_INIT}
+      nogl_Init;
+    {$ENDIF}
     r_LoadScreen_Initialize;
     r_Textures_Initialize;
     r_Console_Initialize;
@@ -226,6 +232,9 @@ implementation
     r_Console_Finalize;
     r_Textures_Finalize;
     r_LoadScreen_Finalize;
+    {$IFDEF NOGL_INIT}
+      nogl_Quit;
+    {$ENDIF}
   end;
 
   procedure r_Render_Update;
@@ -320,7 +329,7 @@ implementation
 
     if gShowScore and (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
     begin
-      (* RED TEAM GOALS *)
+      (* RED TEAM SCORE *)
       fw := 0;
       if gGameSettings.GameMode = GM_CTF then
       begin
@@ -337,7 +346,7 @@ implementation
       end;
       r_Common_DrawText(IntToStr(gTeamStat[TEAM_RED].Score), x + w - 16 - fw, y + 240 - 72 - 4, TEAMCOLOR[TEAM_RED].R, TEAMCOLOR[TEAM_RED].G, TEAMCOLOR[TEAM_RED].B, 255, menufont, TBasePoint.BP_RIGHTUP);
 
-      (* BLUE TEAM GOALS *)
+      (* BLUE TEAM SCORE *)
       fw := 0;
       if gGameSettings.GameMode = GM_CTF then
       begin
@@ -554,7 +563,7 @@ implementation
     w3 := cw * 8;           (* frags width *)
     w2 := cw * 12;          (* ping/loss width *)
     w1 := w - w2 - w3 - w4; (* name width *)
-    tw := w1 - cw * 2 - w2; (* team goals *)
+    tw := w1 - cw * 2 - w2; (* team score *)
     if cs.PlayerStat = nil then players := 0 else players := Length(cs.PlayerStat);
     yy := y;
     if cs.GameMode in [GM_TDM, GM_CTF] then
@@ -1062,7 +1071,7 @@ implementation
     r_Draw_Setup(gWinSizeX, gWinSizeY, gScreenWidth, gScreenHeight);
 
     glClearColor(0.0, 0.0, 0.0, 0.0);
-    glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
+    glClear(GL_COLOR_BUFFER_BIT);
 
     p1 := nil;
     p2 := nil;
@@ -1240,7 +1249,9 @@ implementation
       r_Holmes_DrawUI;
     {$ENDIF}
 
-    // TODO draw touch screen controls
+    {$IFDEF ENABLE_TOUCH}
+      r_Touch_Draw;
+    {$ENDIF}
 
     sys_Repaint;
   end;
@@ -1262,7 +1273,10 @@ implementation
         e_LogWriteln('resolution changed')
       else
         e_LogWriteln('resolution not changed');
-      sys_EnableVSync(gVSync)
+      sys_EnableVSync(gVSync);
+    {$ENDIF}
+    {$IFDEF NOGL_INIT}
+      nogl_Init;
     {$ENDIF}
   end;
 
@@ -1289,8 +1303,7 @@ implementation
 {$IFDEF ENABLE_TOUCH}
   procedure r_Render_GetKeyRect (key: Integer; out x, y, w, h: Integer; out founded: Boolean);
   begin
-    // TODO implement touchscreen
-    founded := False;
+    r_Touch_GetKeyRect(key, x, y, w, h, founded)
   end;
 {$ENDIF}