index 891c65861f35d410caa42643337953059278cb23..c5ec8f36e94baae90f47ca21bbd20d32416a36d9 100644 (file)
function e_CreateTextureMem(pData: Pointer; dataSize: LongInt; var ID: DWORD): Boolean;
function e_CreateTextureMemEx(pData: Pointer; dataSize: LongInt; var ID: DWORD; fX, fY, fWidth, fHeight: Word): Boolean;
procedure e_GetTextureSize(ID: DWORD; Width, Height: PWord);
-function e_GetTextureSize2(ID: DWORD): TRectWH;
procedure e_DeleteTexture(ID: DWORD);
procedure e_RemoveAllTextures();
if Height <> nil then Height^ := e_Textures[ID].tx.Height;
end;
-function e_GetTextureSize2(ID: DWORD): TRectWH;
-var
- data: PChar;
- x, y: Integer;
- w, h: Word;
- a: Boolean;
- lastline: Integer;
-begin
- w := e_Textures[ID].tx.Width;
- h := e_Textures[ID].tx.Height;
-
- Result.Y := 0;
- Result.X := 0;
- Result.Width := w;
- Result.Height := h;
-
-{$IFNDEF USE_NANOGL} // FIXIT: nanoGL doesn't support glGetTexImage
- if e_NoGraphics then Exit;
-
- data := GetMemory(w*h*4);
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, e_Textures[ID].tx.id);
- glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
-
- for y := h-1 downto 0 do
- begin
- lastline := y;
- a := True;
-
- for x := 1 to w-4 do
- begin
- a := Byte((data+y*w*4+x*4+3)^) <> 0;
- if a then Break;
- end;
-
- if a then
- begin
- Result.Y := h-lastline;
- Break;
- end;
- end;
-
- for y := 0 to h-1 do
- begin
- lastline := y;
- a := True;
-
- for x := 1 to w-4 do
- begin
- a := Byte((data+y*w*4+x*4+3)^) <> 0;
- if a then Break;
- end;
-
- if a then
- begin
- Result.Height := h-lastline-Result.Y;
- Break;
- end;
- end;
-
- for x := 0 to w-1 do
- begin
- lastline := x;
- a := True;
-
- for y := 1 to h-4 do
- begin
- a := Byte((data+y*w*4+x*4+3)^) <> 0;
- if a then Break;
- end;
-
- if a then
- begin
- Result.X := lastline+1;
- Break;
- end;
- end;
-
- for x := w-1 downto 0 do
- begin
- lastline := x;
- a := True;
-
- for y := 1 to h-4 do
- begin
- a := Byte((data+y*w*4+x*4+3)^) <> 0;
- if a then Break;
- end;
-
- if a then
- begin
- Result.Width := lastline-Result.X+1;
- Break;
- end;
- end;
-
- FreeMemory(data);
-{$ENDIF}
-end;
-
procedure e_ResizeWindow(Width, Height: Integer);
begin
if Height = 0 then
procedure e_DrawQuad(X1, Y1, X2, Y2: Integer; Red, Green, Blue: Byte; Alpha: Byte = 0);
var
nX1, nY1, nX2, nY2: Integer;
+{$IFDEF USE_NANOGL}
+ v: array [0..15] of GLfloat;
+{$ENDIF}
begin
-{$IFNDEF USE_NANOGL} // FIXIT: nanoGL doesn't support glBegin(GL_LINES)
if e_NoGraphics then Exit;
// Only top-left/bottom-right quad
if X1 > X2 then
glDisable(GL_TEXTURE_2D);
glColor4ub(Red, Green, Blue, 255-Alpha);
glLineWidth(1);
+{$IFDEF USE_NANOGL}
+ nX1 := X1; nY1 := Y1;
+ nX2 := X2; nY2 := Y1;
+ e_LineCorrection(nX1, nY1, nX2, nY2);
+ v[0] := nX1; v[1] := nY1; v[2] := nX2; v[3] := nY2;
+
+ nX1 := X2; nY1 := Y1;
+ nX2 := X2; nY2 := Y2;
+ e_LineCorrection(nX1, nY1, nX2, nY2);
+ v[4] := nX1; v[5] := nY1; v[6] := nX2; v[7] := nY2;
+
+ nX1 := X2; nY1 := Y2;
+ nX2 := X1; nY2 := Y2;
+ e_LineCorrection(nX1, nY1, nX2, nY2);
+ v[8] := nX1; v[9] := nY1; v[10] := nX2; v[11] := nY2;
+
+ nX1 := X1; nY1 := Y2;
+ nX2 := X1; nY2 := Y1;
+ e_LineCorrection(nX1, nY1, nX2, nY2);
+ v[12] := nX1; v[13] := nY1; v[14] := nX2; v[15] := nY2;
+ 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, 16);
+{$ELSE}
glBegin(GL_LINES);
nX1 := X1; nY1 := Y1;
nX2 := X2; nY2 := Y1;
glVertex2i(nX1, nY1);
glVertex2i(nX2, nY2);
glEnd();
+{$ENDIF}
glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
glDisable(GL_BLEND);
-{$ENDIF}
end;
procedure e_DrawFillQuad(X1, Y1, X2, Y2: Integer; Red, Green, Blue, Alpha: Byte;