DEADSOFTWARE

Added new OpenGL ES wrapper
[d2df-sdl.git] / src / game / g_gfx.pas
index 0f26212b29ce8f21c066bb80299f4c395011bfbe..4e9cdd89354dc382ed48437bc452b2f20043cf94 100644 (file)
@@ -78,11 +78,7 @@ function awmIsSetHolmes (x, y: Integer): Boolean; inline;
 implementation
 
 uses
-{$IFDEF USE_NANOGL}
-  nanoGL,
-{$ELSE}
-  GL, GLExt,
-{$ENDIF}
+  {$INCLUDE ../nogl/noGLuses.inc}
   g_map, g_panel, g_basic, Math, e_graphics,
   g_options, g_console, SysUtils, g_triggers, MAPDEF,
   g_game, g_language, g_net, utils, xprofiler;
@@ -1469,9 +1465,6 @@ procedure g_GFX_SetMax (count: Integer);
 var
   a: Integer;
 begin
-{$IFDEF USE_NANOGL} // FIXIT: nanoGL doesn't support glBegin(GL_POINTS)
-  count := 0;
-{$ENDIF}
   if count > 50000 then count := 50000;
   if (count < 1) then count := 1;
   SetLength(Particles, count);
@@ -1627,8 +1620,18 @@ end;
 
 
 procedure g_GFX_Draw ();
-var
-  a, len: Integer;
+  var
+    a, len: Integer;
+{$IFDEF USE_NANOGL}
+  type
+    Vertex = record
+      x, y: GLfloat;
+      r, g, b, a: GLfloat;
+    end;
+  var
+    count: Integer;
+    v: array of Vertex;
+{$ENDIF}
 begin
   if not gpart_dbg_enabled then exit;
 
@@ -1643,6 +1646,34 @@ begin
     glEnable(GL_BLEND);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
+{$IFDEF USE_NANOGL}
+    count := 0;
+    SetLength(v, Length(Particles));
+    for a := 0 to High(Particles) do
+    begin
+      with Particles[a] do
+      begin
+        if alive and (x >= sX) and (y >= sY) and (x <= sX + sWidth) and (sY <= sY + sHeight) then
+        begin
+          v[count].x := x + 0.37;
+          v[count].y := y + 0.37;
+          v[count].r := red / 255;
+          v[count].g := green / 255;
+          v[count].b := blue / 255;
+          v[count].a := alpha / 255;
+          Inc(count);
+        end;
+      end;
+    end;
+
+    glVertexPointer(2, GL_FLOAT, SizeOf(Vertex), @v[0].x);
+    glColorPointer(4, GL_FLOAT, SizeOf(Vertex), @v[0].r);
+    glEnableClientState(GL_VERTEX_ARRAY);
+    glEnableClientState(GL_COLOR_ARRAY);
+    glDisableClientState(GL_NORMAL_ARRAY);
+    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+    glDrawArrays(GL_POINTS, 0, count);
+{$ELSE}
     glBegin(GL_POINTS);
 
     len := High(Particles);
@@ -1660,6 +1691,7 @@ begin
     end;
 
     glEnd();
+{$ENDIF}
 
     glDisable(GL_BLEND);
   end;