summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1277f7d)
raw | patch | inline | side by side (parent: 1277f7d)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Tue, 20 Feb 2018 15:08:41 +0000 (18:08 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sat, 17 Mar 2018 00:04:27 +0000 (02:04 +0200) |
src/engine/e_graphics.pas | patch | blob | history | |
src/game/g_gfx.pas | patch | blob | history |
index b78a175885a26b4652088019e36ac59cf8cdd50d..18e4c1a676a81416360fc4c950bd25f4081ae864 100644 (file)
procedure e_DrawLine(Width: Byte; X1, Y1, X2, Y2: Integer; Red, Green, Blue: Byte; Alpha: Byte = 0);
+{$IFDEF USE_NANOGL}
+ var
+ v: array [0..3] of GLfloat;
+{$ENDIF}
begin
-{$IFNDEF USE_NANOGL} // FIXIT: nanoGL doesn't support glBegin(GL_LINES)
if e_NoGraphics then Exit;
// Pixel-perfect lines
if Width = 1 then
glColor4ub(Red, Green, Blue, 255-Alpha);
glLineWidth(Width);
+{$IFDEF USE_NANOGL}
+ v[0] := X1; v[1] := Y1; v[2] := X2; v[3] := Y2;
+ glVertexPointer(2, GL_FLOAT, 0, @v[0]);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDrawArrays(GL_LINES, 0, 4);
+{$ELSE}
glBegin(GL_LINES);
glVertex2i(X1, Y1);
glVertex2i(X2, Y2);
glEnd();
+{$ENDIF}
glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
glDisable(GL_BLEND);
-{$ENDIF}
end;
//------------------------------------------------------------------
diff --git a/src/game/g_gfx.pas b/src/game/g_gfx.pas
index 0f26212b29ce8f21c066bb80299f4c395011bfbe..01ada5245edcbb7606cfd4ffdd3f12af364719b6 100644 (file)
--- a/src/game/g_gfx.pas
+++ b/src/game/g_gfx.pas
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);
procedure g_GFX_Draw ();
-var
- a, len: Integer;
+ var
+ a, len: Integer;
+{$IFDEF USE_NANOGL}
+ type
+ PVertex = ^Vertex;
+ Vertex = record
+ x, y: GLfloat;
+ r, g, b, a: GLfloat;
+ end;
+ var
+ count: Integer;
+ v: PVertex;
+{$ENDIF}
begin
if not gpart_dbg_enabled then exit;
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+{$IFDEF USE_NANOGL}
+ len := High(Particles);
+ v := GetMem(len * SizeOf(Vertex) + 1);
+ count := 0;
+ for a := 0 to len 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.x);
+ glColorPointer(4, GL_FLOAT, SizeOf(Vertex), @v.r);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDrawArrays(GL_POINTS, 0, count - 1);
+
+ Dispose(v);
+{$ELSE}
glBegin(GL_POINTS);
len := High(Particles);
end;
glEnd();
+{$ENDIF}
glDisable(GL_BLEND);
end;