hedgewars/uRender.pas
author sheepluva
Sat, 14 Jun 2014 15:49:44 +0200
changeset 10304 7e40820b7ed6
parent 10302 ea0b0e2efd95
child 10306 4fca8bcfaff0
permissions -rw-r--r--
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
     1
(*
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
     2
 * Hedgewars, a free turn based strategy game
9998
736015b847e3 update copyright to 2014
sheepluva
parents: 9792
diff changeset
     3
 * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
     4
 *
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
     8
 *
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    12
 * GNU General Public License for more details.
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    13
 *
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    14
 * You should have received a copy of the GNU General Public License
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    15
 * along with this program; if not, write to the Free Software
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 10040
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    17
 *)
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    18
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    19
{$INCLUDE "options.inc"}
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
    20
{$IF GLunit = GL}{$DEFINE GLunit:=GL,GLext}{$ENDIF}
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4452
diff changeset
    21
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    22
unit uRender;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    23
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    24
interface
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    25
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
    26
uses SDLh, uTypes, GLunit;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
    27
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
    28
procedure initModule;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
    29
procedure freeModule;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    30
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    31
procedure DrawSprite            (Sprite: TSprite; X, Y, Frame: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    32
procedure DrawSprite            (Sprite: TSprite; X, Y, FrameX, FrameY: LongInt);
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
    33
procedure DrawSpriteFromRect    (Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); inline;
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    34
procedure DrawSpriteClipped     (Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    35
procedure DrawSpriteRotated     (Sprite: TSprite; X, Y, Dir: LongInt; Angle: real);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    36
procedure DrawSpriteRotatedF    (Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real);
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
    37
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    38
procedure DrawTexture           (X, Y: LongInt; Texture: PTexture); inline;
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    39
procedure DrawTexture           (X, Y: LongInt; Texture: PTexture; Scale: GLfloat);
10020
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
    40
procedure DrawTexture2          (X, Y: LongInt; Texture: PTexture; Scale, Overlap: GLfloat);
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
    41
procedure DrawTextureFromRect   (X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
    42
procedure DrawTextureFromRect   (X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
    43
procedure DrawTextureFromRectDir(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture; Dir: LongInt);
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    44
procedure DrawTextureCentered   (X, Top: LongInt; Source: PTexture);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    45
procedure DrawTextureF          (Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    46
procedure DrawTextureRotated    (Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    47
procedure DrawTextureRotatedF   (Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real);
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
    48
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    49
procedure DrawCircle            (X, Y, Radius, Width: LongInt);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    50
procedure DrawCircle            (X, Y, Radius, Width: LongInt; r, g, b, a: Byte);
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
    51
9557
a5005b7ca305 differentiate borders a bit
nemo
parents: 9080
diff changeset
    52
procedure DrawLine              (X0, Y0, X1, Y1, Width: Single; color: LongWord); inline;
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    53
procedure DrawLine              (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte);
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
    54
procedure DrawRect              (rect: TSDL_Rect; r, g, b, a: Byte; Fill: boolean);
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    55
procedure DrawHedgehog          (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    56
procedure DrawScreenWidget      (widget: POnScreenWidget);
10276
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
    57
procedure DrawWaterBody         (pVertexBuffer: Pointer);
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    58
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
    59
procedure RenderClear           ();
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
    60
procedure RenderSetClearColor      (r, g, b, a: real);
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    61
procedure Tint                  (r, g, b, a: Byte); inline;
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
    62
procedure Tint                  (c: Longword); inline;
9666
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
    63
procedure untint(); inline;
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
    64
procedure setTintAdd            (f: boolean); inline;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    65
10266
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
    66
function isAreaOffscreen(X, Y, Width, Height: LongInt): boolean; inline;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
    67
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
    68
// 0 => not offscreen, <0 => left/top of screen >0 => right/below of screen
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
    69
function isDxAreaOffscreen(X, Width: LongInt): LongInt; inline;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
    70
function isDyAreaOffscreen(Y, Height: LongInt): LongInt; inline;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
    71
10302
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    72
procedure SetScale(f: GLfloat);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    73
procedure UpdateViewLimits();
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    74
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
    75
procedure RenderSetup();
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
    76
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
    77
// TODO everything below this should not need a public interface
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
    78
10302
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    79
procedure EnableTexture(enable:Boolean);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    80
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    81
procedure SetTexCoordPointer(p: Pointer;n: Integer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    82
procedure SetVertexPointer(p: Pointer;n: Integer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    83
procedure SetColorPointer(p: Pointer;n: Integer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    84
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    85
procedure UpdateModelviewProjection(); inline;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    86
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
    87
procedure openglLoadIdentity    (); inline;
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    88
procedure openglTranslProjMatrix(X, Y, Z: GLFloat); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    89
procedure openglPushMatrix      (); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    90
procedure openglPopMatrix       (); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    91
procedure openglTranslatef      (X, Y, Z: GLfloat); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    92
procedure openglScalef          (ScaleX, ScaleY, ScaleZ: GLfloat); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    93
procedure openglRotatef         (RotX, RotY, RotZ: GLfloat; dir: LongInt); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    94
procedure openglTint            (r, g, b, a: Byte); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    95
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
    96
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
    97
implementation
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
    98
uses {$IFNDEF PAS2C} StrUtils, {$ENDIF}SysUtils, uVariables, uUtils, uConsts
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
    99
     {$IFDEF GL2}, uMatrix, uConsole{$ENDIF};
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   100
8145
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
   101
{$IFDEF USE_TOUCH_INTERFACE}
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
   102
const
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
   103
    FADE_ANIM_TIME = 500;
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
   104
    MOVE_ANIM_TIME = 500;
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
   105
{$ENDIF}
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7069
diff changeset
   106
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   107
{$IFDEF GL2}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   108
var
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   109
    shaderMain: GLuint;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   110
    shaderWater: GLuint;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   111
{$ENDIF}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   112
7028
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 6999
diff changeset
   113
var LastTint: LongWord = 0;
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 6999
diff changeset
   114
10266
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   115
function isAreaOffscreen(X, Y, Width, Height: LongInt): boolean; inline;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   116
begin
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   117
    isAreaOffscreen:= (isDxAreaOffscreen(X, Width) <> 0) or (isDyAreaOffscreen(Y, Height) <> 0);
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   118
end;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   119
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   120
function isDxAreaOffscreen(X, Width: LongInt): LongInt; inline;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   121
begin
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   122
    if X > ViewRightX then exit(1);
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   123
    if X + Width < ViewLeftX then exit(-1);
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   124
    isDxAreaOffscreen:= 0;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   125
end;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   126
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   127
function isDyAreaOffscreen(Y, Height: LongInt): LongInt; inline;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   128
begin
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   129
    if Y > ViewBottomY then exit(1);
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   130
    if Y + Height < ViewTopY then exit(-1);
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   131
    isDyAreaOffscreen:= 0;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   132
end;
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   133
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   134
procedure RenderClear();
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   135
begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   136
    glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   137
end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   138
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   139
procedure RenderSetClearColor(r, g, b, a: real);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   140
begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   141
    glClearColor(r, g, b, a);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   142
end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   143
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   144
{$IFDEF GL2}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   145
function CompileShader(shaderFile: string; shaderType: GLenum): GLuint;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   146
var
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   147
    shader: GLuint;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   148
    f: Textfile;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   149
    source, line: AnsiString;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   150
    sourceA: Pchar;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   151
    lengthA: GLint;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   152
    compileResult: GLint;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   153
    logLength: GLint;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   154
    log: PChar;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   155
begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   156
    Assign(f, PathPrefix + cPathz[ptShaders] + '/' + shaderFile);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   157
    filemode:= 0; // readonly
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   158
    Reset(f);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   159
    if IOResult <> 0 then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   160
    begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   161
        AddFileLog('Unable to load ' + shaderFile);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   162
        halt(-1);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   163
    end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   164
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   165
    source:='';
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   166
    while not eof(f) do
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   167
    begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   168
        ReadLn(f, line);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   169
        source:= source + line + #10;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   170
    end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   171
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   172
    Close(f);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   173
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   174
    WriteLnToConsole('Compiling shader: ' + PathPrefix + cPathz[ptShaders] + '/' + shaderFile);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   175
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   176
    sourceA:=PChar(source);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   177
    lengthA:=Length(source);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   178
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   179
    shader:=glCreateShader(shaderType);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   180
    glShaderSource(shader, 1, @sourceA, @lengthA);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   181
    glCompileShader(shader);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   182
    glGetShaderiv(shader, GL_COMPILE_STATUS, @compileResult);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   183
    glGetShaderiv(shader, GL_INFO_LOG_LENGTH, @logLength);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   184
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   185
    if logLength > 1 then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   186
    begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   187
        log := GetMem(logLength);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   188
        glGetShaderInfoLog(shader, logLength, nil, log);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   189
        WriteLnToConsole('========== Compiler log  ==========');
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   190
        WriteLnToConsole(shortstring(log));
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   191
        WriteLnToConsole('===================================');
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   192
        FreeMem(log, logLength);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   193
    end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   194
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   195
    if compileResult <> GL_TRUE then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   196
    begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   197
        WriteLnToConsole('Shader compilation failed, halting');
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   198
        halt(-1);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   199
    end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   200
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   201
    CompileShader:= shader;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   202
end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   203
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   204
function CompileProgram(shaderName: string): GLuint;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   205
var
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   206
    program_: GLuint;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   207
    vs, fs: GLuint;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   208
    linkResult: GLint;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   209
    logLength: GLint;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   210
    log: PChar;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   211
begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   212
    program_:= glCreateProgram();
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   213
    vs:= CompileShader(shaderName + '.vs', GL_VERTEX_SHADER);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   214
    fs:= CompileShader(shaderName + '.fs', GL_FRAGMENT_SHADER);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   215
    glAttachShader(program_, vs);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   216
    glAttachShader(program_, fs);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   217
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   218
    glBindAttribLocation(program_, aVertex, PChar('vertex'));
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   219
    glBindAttribLocation(program_, aTexCoord, PChar('texcoord'));
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   220
    glBindAttribLocation(program_, aColor, PChar('color'));
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   221
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   222
    glLinkProgram(program_);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   223
    glDeleteShader(vs);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   224
    glDeleteShader(fs);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   225
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   226
    glGetProgramiv(program_, GL_LINK_STATUS, @linkResult);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   227
    glGetProgramiv(program_, GL_INFO_LOG_LENGTH, @logLength);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   228
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   229
    if logLength > 1 then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   230
    begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   231
        log := GetMem(logLength);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   232
        glGetProgramInfoLog(program_, logLength, nil, log);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   233
        WriteLnToConsole('========== Compiler log  ==========');
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   234
        WriteLnToConsole(shortstring(log));
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   235
        WriteLnToConsole('===================================');
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   236
        FreeMem(log, logLength);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   237
    end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   238
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   239
    if linkResult <> GL_TRUE then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   240
    begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   241
        WriteLnToConsole('Linking program failed, halting');
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   242
        halt(-1);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   243
    end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   244
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   245
    CompileProgram:= program_;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   246
end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   247
{$ENDIF}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   248
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   249
procedure RenderSetup();
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   250
var AuxBufNum: LongInt = 0;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   251
    tmpstr: ansistring;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   252
    tmpint: LongInt;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   253
    tmpn: LongInt;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   254
begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   255
    // suppress hint/warning
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   256
    AuxBufNum:= AuxBufNum;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   257
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   258
    // get the max (h and v) size for textures that the gpu can support
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   259
    glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   260
    if MaxTextureSize <= 0 then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   261
        begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   262
        MaxTextureSize:= 1024;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   263
        AddFileLog('OpenGL Warning - driver didn''t provide any valid max texture size; assuming 1024');
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   264
        end
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   265
    else if (MaxTextureSize < 1024) and (MaxTextureSize >= 512) then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   266
        begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   267
        cReducedQuality := cReducedQuality or rqNoBackground;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   268
        AddFileLog('Texture size too small for backgrounds, disabling.');
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   269
        end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   270
    // everyone loves debugging
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   271
    // find out which gpu we are using (for extension compatibility maybe?)
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   272
    AddFileLog('OpenGL-- Renderer: ' + shortstring(pchar(glGetString(GL_RENDERER))));
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   273
    AddFileLog('  |----- Vendor: ' + shortstring(pchar(glGetString(GL_VENDOR))));
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   274
    AddFileLog('  |----- Version: ' + shortstring(pchar(glGetString(GL_VERSION))));
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   275
    AddFileLog('  |----- Texture Size: ' + inttostr(MaxTextureSize));
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   276
{$IFDEF USE_VIDEO_RECORDING}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   277
    glGetIntegerv(GL_AUX_BUFFERS, @AuxBufNum);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   278
    AddFileLog('  |----- Number of auxiliary buffers: ' + inttostr(AuxBufNum));
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   279
{$ENDIF}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   280
{$IFNDEF PAS2C}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   281
    AddFileLog('  \----- Extensions: ');
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   282
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   283
    // fetch extentions and store them in string
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   284
    tmpstr := StrPas(PChar(glGetString(GL_EXTENSIONS)));
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   285
    tmpn := WordCount(tmpstr, [' ']);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   286
    tmpint := 1;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   287
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   288
    repeat
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   289
    begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   290
        // print up to 3 extentions per row
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   291
        // ExtractWord will return empty string if index out of range
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   292
        AddFileLog(TrimRight(
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   293
            ExtractWord(tmpint, tmpstr, [' ']) + ' ' +
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   294
            ExtractWord(tmpint+1, tmpstr, [' ']) + ' ' +
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   295
            ExtractWord(tmpint+2, tmpstr, [' '])
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   296
        ));
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   297
        tmpint := tmpint + 3;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   298
    end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   299
    until (tmpint > tmpn);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   300
{$ENDIF}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   301
    AddFileLog('');
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   302
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   303
    defaultFrame:= 0;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   305
{$IFDEF USE_VIDEO_RECORDING}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   306
    if GameType = gmtRecord then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   307
    begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   308
        if glLoadExtension('GL_EXT_framebuffer_object') then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   309
        begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   310
            CreateFramebuffer(defaultFrame, depthv, texv);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   311
            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, defaultFrame);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   312
            AddFileLog('Using framebuffer for video recording.');
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   313
        end
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   314
        else if AuxBufNum > 0 then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   315
        begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   316
            glDrawBuffer(GL_AUX0);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   317
            glReadBuffer(GL_AUX0);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   318
            AddFileLog('Using auxiliary buffer for video recording.');
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   319
        end
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   320
        else
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   321
        begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   322
            glDrawBuffer(GL_BACK);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   323
            glReadBuffer(GL_BACK);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   324
            AddFileLog('Warning: off-screen rendering is not supported; using back buffer but it may not work.');
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   325
        end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   326
    end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   327
{$ENDIF}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   328
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   329
{$IFDEF GL2}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   330
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   331
{$IFDEF PAS2C}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   332
    err := glewInit();
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   333
    if err <> GLEW_OK then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   334
    begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   335
        WriteLnToConsole('Failed to initialize GLEW.');
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   336
        halt;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   337
    end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   338
{$ENDIF}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   339
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   340
{$IFNDEF PAS2C}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   341
    if not Load_GL_VERSION_2_0 then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   342
        halt;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   343
{$ENDIF}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   344
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   345
    shaderWater:= CompileProgram('water');
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   346
    glUseProgram(shaderWater);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   347
    glUniform1i(glGetUniformLocation(shaderWater, pchar('tex0')), 0);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   348
    uWaterMVPLocation:= glGetUniformLocation(shaderWater, pchar('mvp'));
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   349
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   350
    shaderMain:= CompileProgram('default');
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   351
    glUseProgram(shaderMain);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   352
    glUniform1i(glGetUniformLocation(shaderMain, pchar('tex0')), 0);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   353
    uMainMVPLocation:= glGetUniformLocation(shaderMain, pchar('mvp'));
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   354
    uMainTintLocation:= glGetUniformLocation(shaderMain, pchar('tint'));
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   355
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   356
    uCurrentMVPLocation:= uMainMVPLocation;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   357
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   358
    Tint(255, 255, 255, 255);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   359
    UpdateModelviewProjection;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   360
{$ENDIF}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   361
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   362
{$IFNDEF USE_S3D_RENDERING}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   363
    if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   364
    begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   365
        // prepare left and right frame buffers and associated textures
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   366
        if glLoadExtension('GL_EXT_framebuffer_object') then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   367
            begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   368
            CreateFramebuffer(framel, depthl, texl);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   369
            CreateFramebuffer(framer, depthr, texr);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   370
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   371
            // reset
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   372
            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, defaultFrame)
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   373
            end
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   374
        else
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   375
            cStereoMode:= smNone;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   376
    end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   377
{$ENDIF}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   378
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   379
// set view port to whole window
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   380
glViewport(0, 0, cScreenWidth, cScreenHeight);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   381
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   382
{$IFDEF GL2}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   383
    uMatrix.initModule;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   384
    hglMatrixMode(MATRIX_MODELVIEW);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   385
    // prepare default translation/scaling
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   386
    hglLoadIdentity();
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   387
    hglScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   388
    hglTranslatef(0, -cScreenHeight / 2, 0);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   389
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   390
    EnableTexture(True);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   391
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   392
    glEnableVertexAttribArray(aVertex);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   393
    glEnableVertexAttribArray(aTexCoord);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   394
    glGenBuffers(1, @vBuffer);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   395
    glGenBuffers(1, @tBuffer);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   396
    glGenBuffers(1, @cBuffer);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   397
{$ELSE}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   398
    glMatrixMode(GL_MODELVIEW);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   399
    // prepare default translation/scaling
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   400
    glLoadIdentity();
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   401
    glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   402
    glTranslatef(0, -cScreenHeight / 2, 0);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   403
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   404
    // disable/lower perspective correction (will not need it anyway)
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   405
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   406
    // disable dithering
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   407
    glDisable(GL_DITHER);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   408
    // enable common states by default as they save a lot
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   409
    glEnable(GL_TEXTURE_2D);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   410
    glEnableClientState(GL_VERTEX_ARRAY);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   411
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   412
{$ENDIF}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   413
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   414
    // enable alpha blending
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   415
    glEnable(GL_BLEND);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   416
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   417
    // disable/lower perspective correction (will not need it anyway)
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   418
end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   419
10302
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   420
procedure openglLoadIdentity(); inline;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   421
begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   422
{$IFDEF GL2}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   423
    hglLoadIdentity();
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   424
{$ELSE}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   425
    glLoadIdentity();
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   426
{$ENDIF}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   427
end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   428
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   429
procedure openglTranslProjMatrix(X, Y, Z: GLfloat); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   430
begin
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   431
{$IFDEF GL2}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   432
    hglMatrixMode(MATRIX_PROJECTION);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   433
    hglTranslatef(X, Y, Z);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   434
    hglMatrixMode(MATRIX_MODELVIEW);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   435
{$ELSE}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   436
    glMatrixMode(GL_PROJECTION);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   437
    glTranslatef(X, Y, Z);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   438
    glMatrixMode(GL_MODELVIEW);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   439
{$ENDIF}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   440
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   441
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   442
procedure openglPushMatrix(); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   443
begin
10276
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   444
{$IFDEF GL2}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   445
    hglPushMatrix();
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   446
{$ELSE}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   447
    glPushMatrix();
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   448
{$ENDIF}
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   449
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   450
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   451
procedure openglPopMatrix(); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   452
begin
10276
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   453
{$IFDEF GL2}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   454
    hglPopMatrix();
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   455
{$ELSE}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   456
    glPopMatrix();
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   457
{$ENDIF}
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   458
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   459
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   460
procedure openglTranslatef(X, Y, Z: GLfloat); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   461
begin
10276
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   462
{$IFDEF GL2}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   463
    hglTranslatef(X, Y, Z);
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   464
{$ELSE}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   465
    glTranslatef(X, Y, Z);
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   466
{$ENDIF}
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   467
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   468
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   469
procedure openglScalef(ScaleX, ScaleY, ScaleZ: GLfloat); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   470
begin
10276
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   471
{$IFDEF GL2}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   472
    hglScalef(ScaleX, ScaleY, ScaleZ);
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   473
{$ELSE}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   474
    glScalef(ScaleX, ScaleY, ScaleZ);
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   475
{$ENDIF}
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   476
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   477
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   478
procedure openglRotatef(RotX, RotY, RotZ: GLfloat; dir: LongInt); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   479
begin
10276
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   480
{$IFDEF GL2}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   481
    hglRotatef(RotX, RotY, RotZ, dir);
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   482
{$ELSE}
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   483
    glRotatef(RotX, RotY, RotZ, dir);
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
   484
{$ENDIF}
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   485
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   486
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   487
procedure openglUseColorOnly(b :boolean); inline;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   488
begin
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   489
    if b then
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   490
        begin
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   491
        {$IFDEF GL2}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   492
        glDisableVertexAttribArray(aTexCoord);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   493
        glEnableVertexAttribArray(aColor);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   494
        {$ELSE}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   495
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   496
        glEnableClientState(GL_COLOR_ARRAY);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   497
        {$ENDIF}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   498
        end
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   499
    else
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   500
        begin
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   501
        {$IFDEF GL2}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   502
        glDisableVertexAttribArray(aColor);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   503
        glEnableVertexAttribArray(aTexCoord);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   504
        {$ELSE}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   505
        glDisableClientState(GL_COLOR_ARRAY);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   506
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   507
        {$ENDIF}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   508
        end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   509
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   510
10302
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   511
procedure UpdateModelviewProjection(); inline;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   512
{$IFDEF GL2}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   513
var
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   514
    mvp: TMatrix4x4f;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   515
{$ENDIF}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   516
begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   517
{$IFDEF GL2}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   518
    //MatrixMultiply(mvp, mProjection, mModelview);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   519
{$HINTS OFF}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   520
    hglMVP(mvp);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   521
{$HINTS ON}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   522
    glUniformMatrix4fv(uCurrentMVPLocation, 1, GL_FALSE, @mvp[0, 0]);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   523
{$ENDIF}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   524
end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   525
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   526
procedure SetTexCoordPointer(p: Pointer; n: Integer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   527
begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   528
{$IFDEF GL2}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   529
    glBindBuffer(GL_ARRAY_BUFFER, tBuffer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   530
    glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * n * 2, p, GL_STATIC_DRAW);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   531
    glEnableVertexAttribArray(aTexCoord);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   532
    glVertexAttribPointer(aTexCoord, 2, GL_FLOAT, GL_FALSE, 0, pointer(0));
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   533
{$ELSE}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   534
    n:= n;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   535
    glTexCoordPointer(2, GL_FLOAT, 0, p);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   536
{$ENDIF}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   537
end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   538
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   539
procedure SetVertexPointer(p: Pointer; n: Integer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   540
begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   541
{$IFDEF GL2}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   542
    glBindBuffer(GL_ARRAY_BUFFER, vBuffer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   543
    glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * n * 2, p, GL_STATIC_DRAW);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   544
    glEnableVertexAttribArray(aVertex);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   545
    glVertexAttribPointer(aVertex, 2, GL_FLOAT, GL_FALSE, 0, pointer(0));
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   546
{$ELSE}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   547
    n:= n;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   548
    glVertexPointer(2, GL_FLOAT, 0, p);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   549
{$ENDIF}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   550
end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   551
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   552
procedure SetColorPointer(p: Pointer; n: Integer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   553
begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   554
{$IFDEF GL2}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   555
    glBindBuffer(GL_ARRAY_BUFFER, cBuffer);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   556
    glBufferData(GL_ARRAY_BUFFER, n * 4, p, GL_STATIC_DRAW);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   557
    glEnableVertexAttribArray(aColor);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   558
    glVertexAttribPointer(aColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, pointer(0));
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   559
{$ELSE}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   560
    n:= n;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   561
    glColorPointer(4, GL_UNSIGNED_BYTE, 0, p);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   562
{$ENDIF}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   563
end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   564
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   565
procedure EnableTexture(enable:Boolean);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   566
begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   567
    {$IFDEF GL2}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   568
    if enable then
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   569
        glUniform1i(glGetUniformLocation(shaderMain, pchar('enableTexture')), 1)
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   570
    else
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   571
        glUniform1i(glGetUniformLocation(shaderMain, pchar('enableTexture')), 0);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   572
    {$ELSE}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   573
    if enable then
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   574
        glEnable(GL_TEXTURE_2D)
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   575
    else
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   576
        glDisable(GL_TEXTURE_2D);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   577
    {$ENDIF}
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   578
end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   579
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   580
procedure UpdateViewLimits();
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   581
var tmp: real;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   582
begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   583
    // cScaleFactor is 2.0 on "no zoom"
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   584
    tmp:= cScreenWidth / cScaleFactor;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   585
    ViewRightX:= round(tmp); // ceil could make more sense
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   586
    ViewLeftX:= round(-tmp); // floor could make more sense
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   587
    tmp:= cScreenHeight / cScaleFactor;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   588
    ViewBottomY:= round(tmp) + cScreenHeight div 2; // ceil could make more sense
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   589
    ViewTopY:= round(-tmp) + cScreenHeight div 2; // floor could make more sense
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   590
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   591
    // visual debugging fun :D
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   592
    if cViewLimitsDebug then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   593
        begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   594
        // some margin on each side
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   595
        tmp:= min(cScreenWidth, cScreenHeight) div 2 / cScaleFactor;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   596
        ViewLeftX  := ViewLeftX   + trunc(tmp);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   597
        ViewRightX := ViewRightX  - trunc(tmp);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   598
        ViewBottomY:= ViewBottomY - trunc(tmp);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   599
        ViewTopY   := ViewTopY    + trunc(tmp);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   600
        end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   601
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   602
    ViewWidth := ViewRightX  - ViewLeftX + 1;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   603
    ViewHeight:= ViewBottomY - ViewTopY  + 1;
10302
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   604
end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   605
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   606
procedure SetScale(f: GLfloat);
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   607
begin
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   608
    // leave immediately if scale factor did not change
10302
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   609
    if f = cScaleFactor then
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   610
        exit;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   611
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   612
    // for going back to default scaling just pop matrix
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   613
    if f = cDefaultZoomLevel then
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   614
        begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   615
        openglPopMatrix;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   616
        end
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   617
    else
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   618
        begin
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   619
        openglPushMatrix; // save default scaling in matrix
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   620
        openglLoadIdentity();
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   621
        openglScalef(f / cScreenWidth, -f / cScreenHeight, 1.0);
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   622
        openglTranslatef(0, -cScreenHeight div 2, 0);
10302
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   623
        end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   624
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   625
    cScaleFactor:= f;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   626
    updateViewLimits();
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   627
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   628
    UpdateModelviewProjection;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   629
end;
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
   630
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   631
procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); inline;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   632
begin
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   633
r.y:= r.y + Height * Position;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   634
r.h:= Height;
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   635
DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   636
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   637
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   638
procedure DrawTextureFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   639
begin
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   640
DrawTextureFromRectDir(X, Y, r^.w, r^.h, r, SourceTexture, 1)
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   641
end;
8833
c13ebed437cb update webgl branch
koda
parents: 8330 8626
diff changeset
   642
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   643
procedure DrawTextureFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   644
begin
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   645
DrawTextureFromRectDir(X, Y, W, H, r, SourceTexture, 1)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   646
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   647
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   648
procedure DrawTextureFromRectDir(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture; Dir: LongInt);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   649
var rr: TSDL_Rect;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   650
    _l, _r, _t, _b: real;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   651
    VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   652
begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   653
if (SourceTexture^.h = 0) or (SourceTexture^.w = 0) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   654
    exit;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   655
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   656
{if isDxAreaOffscreen(X, W) <> 0 then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   657
    exit;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   658
if isDyAreaOffscreen(Y, H) <> 0 then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   659
    exit;}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   660
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
   661
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   662
{if (abs(X) > W) and ((abs(X + W / 2) - W / 2) > cScreenWidth / cScaleFactor) then
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   663
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   664
if (abs(Y) > H) and ((abs(Y + H / 2 - (0.5 * cScreenHeight)) - H / 2) > cScreenHeight / cScaleFactor) then
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   665
    exit;}
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   666
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   667
rr.x:= X;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   668
rr.y:= Y;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   669
rr.w:= W;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   670
rr.h:= H;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   671
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   672
_l:= r^.x / SourceTexture^.w * SourceTexture^.rx;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   673
_r:= (r^.x + r^.w) / SourceTexture^.w * SourceTexture^.rx;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   674
_t:= r^.y / SourceTexture^.h * SourceTexture^.ry;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   675
_b:= (r^.y + r^.h) / SourceTexture^.h * SourceTexture^.ry;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   676
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   677
glBindTexture(GL_TEXTURE_2D, SourceTexture^.id);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   678
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   679
if Dir < 0 then
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   680
    begin
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   681
    VertexBuffer[0].X:= X + rr.w div 2;
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   682
    VertexBuffer[0].Y:= Y;
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   683
    VertexBuffer[1].X:= X - rr.w div 2;
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   684
    VertexBuffer[1].Y:= Y;
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   685
    VertexBuffer[2].X:= X - rr.w div 2;
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   686
    VertexBuffer[2].Y:= rr.h + Y;
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   687
    VertexBuffer[3].X:= X + rr.w div 2;
8560
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   688
    VertexBuffer[3].Y:= rr.h + Y;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   689
    end
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   690
else
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   691
    begin
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   692
    VertexBuffer[0].X:= X;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   693
    VertexBuffer[0].Y:= Y;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   694
    VertexBuffer[1].X:= rr.w + X;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   695
    VertexBuffer[1].Y:= Y;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   696
    VertexBuffer[2].X:= rr.w + X;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   697
    VertexBuffer[2].Y:= rr.h + Y;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   698
    VertexBuffer[3].X:= X;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   699
    VertexBuffer[3].Y:= rr.h + Y;
134a098235fa Messing around w/ Freezer
nemo
parents: 8145
diff changeset
   700
    end;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   701
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   702
TextureBuffer[0].X:= _l;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   703
TextureBuffer[0].Y:= _t;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   704
TextureBuffer[1].X:= _r;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   705
TextureBuffer[1].Y:= _t;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   706
TextureBuffer[2].X:= _r;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   707
TextureBuffer[2].Y:= _b;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   708
TextureBuffer[3].X:= _l;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   709
TextureBuffer[3].Y:= _b;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   710
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   711
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   712
glTexCoordPointer(2, GL_FLOAT, 0, @TextureBuffer[0]);
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   713
glDrawArrays(GL_TRIANGLE_FAN, 0, High(VertexBuffer) - Low(VertexBuffer) + 1);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   714
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   715
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   716
procedure DrawTexture(X, Y: LongInt; Texture: PTexture); inline;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   717
begin
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   718
    DrawTexture(X, Y, Texture, 1.0);
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   719
end;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   720
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   721
procedure DrawTexture(X, Y: LongInt; Texture: PTexture; Scale: GLfloat);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   722
begin
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   723
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   724
openglPushMatrix;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   725
openglTranslatef(X, Y, 0);
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   726
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   727
if Scale <> 1.0 then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   728
    openglScalef(Scale, Scale, 1);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   729
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   730
glBindTexture(GL_TEXTURE_2D, Texture^.id);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   731
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   732
SetVertexPointer(@Texture^.vb, Length(Texture^.vb));
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   733
SetTexCoordPointer(@Texture^.tb, Length(Texture^.vb));
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   734
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   735
UpdateModelviewProjection;
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   736
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   737
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(Texture^.vb));
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   738
openglPopMatrix;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   739
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   740
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   741
10020
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   742
{ this contains tweaks in order to avoid land tile borders in blurry land mode }
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   743
procedure DrawTexture2(X, Y: LongInt; Texture: PTexture; Scale, Overlap: GLfloat);
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   744
var
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   745
    TextureBuffer: array [0..3] of TVertex2f;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   746
begin
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   747
openglPushMatrix;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   748
openglTranslatef(X, Y, 0);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   749
openglScalef(Scale, Scale, 1);
10020
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   750
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   751
glBindTexture(GL_TEXTURE_2D, Texture^.id);
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   752
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   753
TextureBuffer[0].X:= Texture^.tb[0].X + Overlap;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   754
TextureBuffer[0].Y:= Texture^.tb[0].Y + Overlap;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   755
TextureBuffer[1].X:= Texture^.tb[1].X - Overlap;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   756
TextureBuffer[1].Y:= Texture^.tb[1].Y + Overlap;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   757
TextureBuffer[2].X:= Texture^.tb[2].X - Overlap;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   758
TextureBuffer[2].Y:= Texture^.tb[2].Y - Overlap;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   759
TextureBuffer[3].X:= Texture^.tb[3].X + Overlap;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   760
TextureBuffer[3].Y:= Texture^.tb[3].Y - Overlap;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   761
10266
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   762
SetVertexPointer(@Texture^.vb, Length(Texture^.vb));
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   763
SetTexCoordPointer(@TextureBuffer, Length(Texture^.vb));
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   764
a90a55ec5b98 some minor tweaks and stuff
sheepluva
parents: 10255
diff changeset
   765
UpdateModelviewProjection;
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   766
10020
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   767
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(Texture^.vb));
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   768
openglPopMatrix;
10020
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   769
end;
67e127027af6 small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents: 9998
diff changeset
   770
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   771
procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   772
begin
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   773
    DrawTextureRotatedF(Texture, Scale, 0, 0, X, Y, Frame, Dir, w, h, 0)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   774
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   775
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   776
procedure DrawTextureRotatedF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   777
var ft, fb, fl, fr: GLfloat;
10301
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   778
    hw, hh, nx, ny: LongInt;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   779
    VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   780
begin
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   781
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   782
if isDxAreaOffscreen(X, w) <> 0 then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   783
    exit;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   784
if isDyAreaOffscreen(Y, h) <> 0 then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   785
    exit;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   786
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
   787
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   788
{if (abs(X) > W) and ((abs(X + dir * OffsetX) - W / 2) * cScaleFactor > cScreenWidth) then
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   789
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   790
if (abs(Y) > H) and ((abs(Y + OffsetY - (0.5 * cScreenHeight)) - W / 2) * cScaleFactor > cScreenHeight) then
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   791
    exit;}
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   792
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   793
openglPushMatrix;
10301
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   794
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   795
openglTranslatef(X, Y, 0);
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   796
6323
c1aa6a3c84a7 Dir should not be 0, but set it to 1 if 0 in case I missed some other place this was done. Also correct cloud scaling.
nemo
parents: 6322
diff changeset
   797
if Dir = 0 then Dir:= 1;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   798
10301
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   799
if Angle <> 0 then
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   800
    openglRotatef(Angle, 0, 0, Dir);
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   801
10301
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   802
if (OffsetX <> 0) or (OffsetY <> 0) then
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   803
    openglTranslatef(Dir*OffsetX, OffsetY, 0);
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   804
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   805
if Scale <> 1.0 then
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   806
    openglScalef(Scale, Scale, 1);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   807
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   808
// Any reason for this call? And why only in t direction, not s?
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   809
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   810
10301
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   811
if Dir > 0 then
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   812
    hw:=  w div 2
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   813
else
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   814
    hw:= -w div 2;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   815
10301
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   816
hh:= h div 2;
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   817
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   818
nx:= Texture^.w div w; // number of horizontal frames
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   819
ny:= Texture^.h div h; // number of vertical frames
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   820
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   821
ft:= (Frame mod ny) * Texture^.ry / ny;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   822
fb:= ((Frame mod ny) + 1) * Texture^.ry / ny;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   823
fl:= (Frame div ny) * Texture^.rx / nx;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   824
fr:= ((Frame div ny) + 1) * Texture^.rx / nx;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   825
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   826
glBindTexture(GL_TEXTURE_2D, Texture^.id);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   827
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   828
VertexBuffer[0].X:= -hw;
10301
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   829
VertexBuffer[0].Y:= -hh;
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   830
VertexBuffer[1].X:=  hw;
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   831
VertexBuffer[1].Y:= -hh;
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   832
VertexBuffer[2].X:=  hw;
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   833
VertexBuffer[2].Y:=  hh;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   834
VertexBuffer[3].X:= -hw;
10301
6a225b469eef some rendering tweaks
sheepluva
parents: 10276
diff changeset
   835
VertexBuffer[3].Y:=  hh;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   836
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   837
TextureBuffer[0].X:= fl;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   838
TextureBuffer[0].Y:= ft;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   839
TextureBuffer[1].X:= fr;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   840
TextureBuffer[1].Y:= ft;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   841
TextureBuffer[2].X:= fr;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   842
TextureBuffer[2].Y:= fb;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   843
TextureBuffer[3].X:= fl;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   844
TextureBuffer[3].Y:= fb;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   845
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   846
SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer));
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   847
SetTexCoordPointer(@TextureBuffer[0], Length(VertexBuffer));
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   848
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   849
UpdateModelviewProjection;
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   850
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   851
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   852
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   853
openglPopMatrix;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   854
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   855
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   856
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   857
procedure DrawSpriteRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   858
begin
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   859
    DrawTextureRotated(SpritesData[Sprite].Texture,
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   860
        SpritesData[Sprite].Width,
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   861
        SpritesData[Sprite].Height,
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   862
        X, Y, Dir, Angle)
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   863
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   864
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   865
procedure DrawSpriteRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   866
begin
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   867
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   868
openglPushMatrix;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   869
openglTranslatef(X, Y, 0);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   870
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   871
if Dir < 0 then
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   872
    begin
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   873
    openglRotatef(Angle, 0, 0, -1);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   874
    openglScalef(-1.0, 1.0, 1.0);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   875
    end
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   876
else
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   877
    openglRotatef(Angle, 0, 0,  1);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   878
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   879
DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   880
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   881
openglPopMatrix;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   882
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   883
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   884
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   885
procedure DrawTextureRotated(Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   886
var VertexBuffer: array [0..3] of TVertex2f;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   887
begin
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   888
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   889
if isDxAreaOffscreen(X, 2 * hw) <> 0 then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   890
    exit;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   891
if isDyAreaOffscreen(Y, 2 * hh) <> 0 then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   892
    exit;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   893
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
   894
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   895
{if (abs(X) > 2 * hw) and ((abs(X) - hw) > cScreenWidth / cScaleFactor) then
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   896
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   897
if (abs(Y) > 2 * hh) and ((abs(Y - 0.5 * cScreenHeight) - hh) > cScreenHeight / cScaleFactor) then
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   898
    exit;}
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   899
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   900
openglPushMatrix;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   901
openglTranslatef(X, Y, 0);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   902
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   903
if Dir < 0 then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   904
    begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   905
    hw:= - hw;
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   906
    openglRotatef(Angle, 0, 0, -1);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   907
    end
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
   908
else
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   909
    openglRotatef(Angle, 0, 0, 1);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   910
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   911
glBindTexture(GL_TEXTURE_2D, Texture^.id);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   912
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   913
VertexBuffer[0].X:= -hw;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   914
VertexBuffer[0].Y:= -hh;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   915
VertexBuffer[1].X:= hw;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   916
VertexBuffer[1].Y:= -hh;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   917
VertexBuffer[2].X:= hw;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   918
VertexBuffer[2].Y:= hh;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   919
VertexBuffer[3].X:= -hw;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   920
VertexBuffer[3].Y:= hh;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   921
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   922
SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer));
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   923
SetTexCoordPointer(@Texture^.tb, Length(VertexBuffer));
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   924
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   925
UpdateModelviewProjection;
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   926
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   927
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   928
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
   929
openglPopMatrix;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
   930
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   931
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   932
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   933
procedure DrawSprite(Sprite: TSprite; X, Y, Frame: LongInt);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   934
var row, col, numFramesFirstCol: LongInt;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   935
begin
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   936
    if SpritesData[Sprite].imageHeight = 0 then
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   937
        exit;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   938
    numFramesFirstCol:= SpritesData[Sprite].imageHeight div SpritesData[Sprite].Height;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   939
    row:= Frame mod numFramesFirstCol;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   940
    col:= Frame div numFramesFirstCol;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   941
    DrawSprite(Sprite, X, Y, col, row);
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   942
end;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   943
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   944
procedure DrawSprite(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt);
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   945
var r: TSDL_Rect;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   946
begin
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   947
    r.x:= FrameX * SpritesData[Sprite].Width;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   948
    r.w:= SpritesData[Sprite].Width;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   949
    r.y:= FrameY * SpritesData[Sprite].Height;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
   950
    r.h:= SpritesData[Sprite].Height;
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   951
    DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   952
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   953
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   954
procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   955
var r: TSDL_Rect;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   956
begin
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   957
r.x:= 0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   958
r.y:= 0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   959
r.w:= SpritesData[Sprite].Width;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   960
r.h:= SpritesData[Sprite].Height;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   961
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   962
if (X < LeftX) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   963
    r.x:= LeftX - X;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   964
if (Y < TopY) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   965
    r.y:= TopY - Y;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   966
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   967
if (Y + SpritesData[Sprite].Height > BottomY) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   968
    r.h:= BottomY - Y + 1;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   969
if (X + SpritesData[Sprite].Width > RightX) then
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   970
    r.w:= RightX - X + 1;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   971
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 9998 9950
diff changeset
   972
if (r.h < r.y) or (r.w < r.x) then
9792
59cde1e53ca5 This seems to be enough to fix the bug with sprGirder rendered in stripe
unc0rr
parents: 9666
diff changeset
   973
    exit;
59cde1e53ca5 This seems to be enough to fix the bug with sprGirder rendered in stripe
unc0rr
parents: 9666
diff changeset
   974
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   975
dec(r.h, r.y);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   976
dec(r.w, r.x);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   977
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   978
DrawTextureFromRect(X + r.x, Y + r.y, @r, SpritesData[Sprite].Texture)
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   979
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   980
6999
486db9d26e4b rename a few Draw* routines
koda
parents: 6992
diff changeset
   981
procedure DrawTextureCentered(X, Top: LongInt; Source: PTexture);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   982
var scale: GLfloat;
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   983
    left : LongInt;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   984
begin
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   985
    // scale down if larger than screen
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   986
    if (Source^.w + 20) > cScreenWidth then
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   987
        begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   988
        scale:= cScreenWidth / (Source^.w + 20);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   989
        DrawTexture(X - round(Source^.w * scale) div 2, Top, Source, scale);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   990
        end
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   991
    else
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   992
        begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   993
        left:= X - Source^.w div 2;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   994
        if (not isAreaOffscreen(left, Top, Source^.w, Source^.h)) then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   995
            DrawTexture(left, Top, Source);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
   996
        end;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   997
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
   998
9557
a5005b7ca305 differentiate borders a bit
nemo
parents: 9080
diff changeset
   999
procedure DrawLine(X0, Y0, X1, Y1, Width: Single; color: LongWord); inline;
a5005b7ca305 differentiate borders a bit
nemo
parents: 9080
diff changeset
  1000
begin
a5005b7ca305 differentiate borders a bit
nemo
parents: 9080
diff changeset
  1001
DrawLine(X0, Y0, X1, Y1, Width, (color shr 24) and $FF, (color shr 16) and $FF, (color shr 8) and $FF, color and $FF)
a5005b7ca305 differentiate borders a bit
nemo
parents: 9080
diff changeset
  1002
end;
a5005b7ca305 differentiate borders a bit
nemo
parents: 9080
diff changeset
  1003
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1004
procedure DrawLine(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte);
8626
cfc44db21d72 Fix DrawLine bug
Urbertar@gmail.com
parents: 8560
diff changeset
  1005
var VertexBuffer: array [0..1] of TVertex2f;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1006
begin
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1007
    glEnable(GL_LINE_SMOOTH);
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1008
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1009
    EnableTexture(False);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1010
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1011
    openglPushMatrix;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1012
    openglTranslatef(WorldDx, WorldDy, 0);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1013
    glLineWidth(Width);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1014
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1015
    UpdateModelviewProjection;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1016
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1017
    Tint(r, g, b, a);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1018
    VertexBuffer[0].X:= X0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1019
    VertexBuffer[0].Y:= Y0;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1020
    VertexBuffer[1].X:= X1;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1021
    VertexBuffer[1].Y:= Y1;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1022
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1023
    SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer));
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1024
    glDrawArrays(GL_LINES, 0, Length(VertexBuffer));
9666
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
  1025
    untint;
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 9998 9950
diff changeset
  1026
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1027
    openglPopMatrix;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1028
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1029
    EnableTexture(True);
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1030
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1031
    glDisable(GL_LINE_SMOOTH);
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1032
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1033
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1034
procedure DrawRect(rect: TSDL_Rect; r, g, b, a: Byte; Fill: boolean);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1035
var VertexBuffer: array [0..3] of TVertex2f;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1036
begin
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
  1037
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1038
{if (abs(r.x) > r.w) and ((abs(r.x + r.w / 2) - r.w / 2) * cScaleFactor > cScreenWidth) then
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1039
    exit;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1040
if (abs(r.y) > r.h) and ((abs(r.y + r.h / 2 - (0.5 * cScreenHeight)) - r.h / 2) * cScaleFactor > cScreenHeight) then
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1041
    exit;}
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1042
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1043
EnableTexture(False);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1044
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1045
Tint(r, g, b, a);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1046
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1047
with rect do
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1048
begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1049
    VertexBuffer[0].X:= x;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1050
    VertexBuffer[0].Y:= y;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1051
    VertexBuffer[1].X:= x + w;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1052
    VertexBuffer[1].Y:= y;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1053
    VertexBuffer[2].X:= x + w;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1054
    VertexBuffer[2].Y:= y + h;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1055
    VertexBuffer[3].X:= x;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1056
    VertexBuffer[3].Y:= y + h;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1057
end;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1058
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1059
SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer));
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1060
if Fill then
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1061
    glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer))
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1062
else
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1063
    glDrawArrays(GL_LINE_LOOP, 0, Length(VertexBuffer));
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1064
9666
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
  1065
untint;
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1066
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1067
EnableTexture(True);
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1068
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1069
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1070
8330
aaefa587e277 update branch with default
koda
parents: 8026 8145
diff changeset
  1071
procedure DrawCircle(X, Y, Radius, Width: LongInt; r, g, b, a: Byte);
4451
1c342980b4aa trying to get tint to behave more as I expect. need to ask Smaxx what he intended here, to avoid too many pointless colour calls
nemo
parents: 4420
diff changeset
  1072
begin
1c342980b4aa trying to get tint to behave more as I expect. need to ask Smaxx what he intended here, to avoid too many pointless colour calls
nemo
parents: 4420
diff changeset
  1073
    Tint(r, g, b, a);
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 9998 9950
diff changeset
  1074
    DrawCircle(X, Y, Radius, Width);
9666
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
  1075
    untint;
4451
1c342980b4aa trying to get tint to behave more as I expect. need to ask Smaxx what he intended here, to avoid too many pointless colour calls
nemo
parents: 4420
diff changeset
  1076
end;
1c342980b4aa trying to get tint to behave more as I expect. need to ask Smaxx what he intended here, to avoid too many pointless colour calls
nemo
parents: 4420
diff changeset
  1077
8330
aaefa587e277 update branch with default
koda
parents: 8026 8145
diff changeset
  1078
procedure DrawCircle(X, Y, Radius, Width: LongInt);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1079
var
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1080
    i: LongInt;
5561
dfbe55237c64 Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents: 5559
diff changeset
  1081
    CircleVertex: array [0..59] of TVertex2f;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1082
begin
5561
dfbe55237c64 Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents: 5559
diff changeset
  1083
    for i := 0 to 59 do begin
dfbe55237c64 Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents: 5559
diff changeset
  1084
        CircleVertex[i].X := X + Radius*cos(i*pi/30);
dfbe55237c64 Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents: 5559
diff changeset
  1085
        CircleVertex[i].Y := Y + Radius*sin(i*pi/30);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1086
    end;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1087
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1088
    EnableTexture(False);
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1089
    glEnable(GL_LINE_SMOOTH);
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1090
    openglPushMatrix;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1091
    glLineWidth(Width);
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1092
    SetVertexPointer(@CircleVertex[0], 60);
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1093
    glDrawArrays(GL_LINE_LOOP, 0, 60);
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1094
    openglPopMatrix;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1095
    EnableTexture(True);
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1096
    glDisable(GL_LINE_SMOOTH);
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1097
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1098
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1099
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1100
procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1101
const VertexBuffer: array [0..3] of TVertex2f = (
7069
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7028
diff changeset
  1102
        (X: -16; Y: -16),
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7028
diff changeset
  1103
        (X:  16; Y: -16),
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7028
diff changeset
  1104
        (X:  16; Y:  16),
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7028
diff changeset
  1105
        (X: -16; Y:  16));
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1106
var l, r, t, b: real;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1107
    TextureBuffer: array [0..3] of TVertex2f;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1108
begin
5565
1a326ba319c9 smaller code cleanup
koda
parents: 5561
diff changeset
  1109
    // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1110
    if (abs(X) > 32) and ((abs(X) - 16) * cScaleFactor > cScreenWidth) then
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1111
        exit;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1112
    if (abs(Y) > 32) and ((abs(Y - 0.5 * cScreenHeight) - 16) * cScaleFactor > cScreenHeight) then
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1113
        exit;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1114
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1115
    t:= Pos * 32 / HHTexture^.h;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1116
    b:= (Pos + 1) * 32 / HHTexture^.h;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1117
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1118
    if Dir = -1 then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
  1119
        begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
  1120
        l:= (Step + 1) * 32 / HHTexture^.w;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
  1121
        r:= Step * 32 / HHTexture^.w
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
  1122
        end
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
  1123
    else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
  1124
        begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
  1125
        l:= Step * 32 / HHTexture^.w;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6394
diff changeset
  1126
        r:= (Step + 1) * 32 / HHTexture^.w
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1127
    end;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1128
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1129
    openglPushMatrix();
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1130
    openglTranslatef(X, Y, 0);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1131
    openglRotatef(Angle, 0, 0, 1);
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1132
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1133
    glBindTexture(GL_TEXTURE_2D, HHTexture^.id);
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1134
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1135
    TextureBuffer[0].X:= l;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1136
    TextureBuffer[0].Y:= t;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1137
    TextureBuffer[1].X:= r;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1138
    TextureBuffer[1].Y:= t;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1139
    TextureBuffer[2].X:= r;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1140
    TextureBuffer[2].Y:= b;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1141
    TextureBuffer[3].X:= l;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1142
    TextureBuffer[3].Y:= b;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1143
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1144
    SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer));
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1145
    SetTexCoordPointer(@TextureBuffer[0], Length(VertexBuffer));
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1146
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1147
    UpdateModelviewProjection;
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1148
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1149
    glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1150
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1151
    openglPopMatrix;
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1152
end;
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1153
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1154
procedure DrawScreenWidget(widget: POnScreenWidget);
6992
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6986
diff changeset
  1155
{$IFDEF USE_TOUCH_INTERFACE}
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1156
var alpha: byte = $FF;
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1157
begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1158
with widget^ do
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1159
    begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1160
    if (fadeAnimStart <> 0) then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1161
        begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1162
        if RealTicks > (fadeAnimStart + FADE_ANIM_TIME) then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1163
            fadeAnimStart:= 0
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1164
        else
8330
aaefa587e277 update branch with default
koda
parents: 8026 8145
diff changeset
  1165
            if show then
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1166
                alpha:= Byte(trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF))
8330
aaefa587e277 update branch with default
koda
parents: 8026 8145
diff changeset
  1167
            else
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1168
                alpha:= Byte($FF - trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF));
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1169
        end;
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1170
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1171
    with moveAnim do
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1172
        if animate then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1173
            if RealTicks > (startTime + MOVE_ANIM_TIME) then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1174
                begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1175
                startTime:= 0;
6710
42504695122d fixed the active region on widgets when they are animated, added active.x:= in uWorld too
Xeli
parents: 6700
diff changeset
  1176
                animate:= false;
6695
32de8965c62c refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents: 6689
diff changeset
  1177
                frame.x:= target.x;
32de8965c62c refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents: 6689
diff changeset
  1178
                frame.y:= target.y;
6710
42504695122d fixed the active region on widgets when they are animated, added active.x:= in uWorld too
Xeli
parents: 6700
diff changeset
  1179
                active.x:= active.x + (target.x - source.x);
42504695122d fixed the active region on widgets when they are animated, added active.x:= in uWorld too
Xeli
parents: 6700
diff changeset
  1180
                active.y:= active.y + (target.y - source.y);
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1181
                end
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1182
            else
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1183
                begin
6695
32de8965c62c refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents: 6689
diff changeset
  1184
                frame.x:= source.x + Round((target.x - source.x) * ((RealTicks - startTime) / MOVE_ANIM_TIME));
32de8965c62c refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents: 6689
diff changeset
  1185
                frame.y:= source.y + Round((target.y - source.y) * ((RealTicks - startTime) / MOVE_ANIM_TIME));
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1186
                end;
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1187
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1188
    if show or (fadeAnimStart <> 0) then
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1189
        begin
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1190
        Tint($FF, $FF, $FF, alpha);
6695
32de8965c62c refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents: 6689
diff changeset
  1191
        DrawTexture(frame.x, frame.y, spritesData[sprite].Texture, buttonScale);
9666
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
  1192
        untint;
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1193
        end;
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1194
    end;
6992
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6986
diff changeset
  1195
{$ELSE}
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6986
diff changeset
  1196
begin
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6986
diff changeset
  1197
widget:= widget; // avoid hint
6689
98a239848ba2 wops, added an extra USE_TOUCH_INTERFACE
Xeli
parents: 6688
diff changeset
  1198
{$ENDIF}
6688
b2084a00a4cf added translate/fade animations for OnScreenWidgets
Xeli
parents: 6580
diff changeset
  1199
end;
4385
f679ffa2dc8c Introduce uGearsRender
unc0rr
parents: 4378
diff changeset
  1200
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1201
procedure BeginWater;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1202
begin
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1203
{$IFDEF GL2}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1204
    glUseProgram(shaderWater);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1205
    uCurrentMVPLocation:=uWaterMVPLocation;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1206
    UpdateModelviewProjection;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1207
    glDisableVertexAttribArray(aTexCoord);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1208
    glEnableVertexAttribArray(aColor);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1209
{$ENDIF}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1210
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1211
    openglUseColorOnly(true);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1212
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1213
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1214
procedure EndWater;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1215
begin
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1216
{$IFDEF GL2}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1217
    glUseProgram(shaderMain);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1218
    uCurrentMVPLocation:=uMainMVPLocation;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1219
    UpdateModelviewProjection;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1220
    glDisableVertexAttribArray(aColor);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1221
    glEnableVertexAttribArray(aTexCoord);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1222
{$ENDIF}
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1223
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1224
    openglUseColorOnly(false);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1225
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1226
10276
89056c7254ef fix hint and gl2 build. NOTE: this does not change that GL2 segfaults right away. that is an issue that dates back at least 50 commits, but most likely even back to the webgl merge. I guess nobody actually tried to run hedgewars in GL2 since back then :P
sheepluva
parents: 10275
diff changeset
  1227
procedure DrawWaterBody(pVertexBuffer: Pointer);
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1228
begin
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1229
        UpdateModelviewProjection;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1230
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1231
        BeginWater;
10302
ea0b0e2efd95 huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents: 10301
diff changeset
  1232
10275
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1233
        if SuddenDeathDmg then
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1234
            SetColorPointer(@SDWaterColorArray[0], 4)
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1235
        else
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1236
            SetColorPointer(@WaterColorArray[0], 4);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1237
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1238
        SetVertexPointer(pVertexBuffer, 4);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1239
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1240
        glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1241
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1242
        EndWater;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1243
end;
6c91047f59b6 RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents: 10266
diff changeset
  1244
10255
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
  1245
procedure openglTint(r, g, b, a: Byte); inline;
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
  1246
{$IFDEF GL2}
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
  1247
const
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
  1248
    scale:Real = 1.0/255.0;
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
  1249
{$ENDIF}
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
  1250
begin
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
  1251
    {$IFDEF GL2}
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
  1252
    glUniform4f(uMainTintLocation, r*scale, g*scale, b*scale, a*scale);
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
  1253
    {$ELSE}
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
  1254
    glColor4ub(r, g, b, a);
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
  1255
    {$ENDIF}
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
  1256
end;
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
  1257
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1258
procedure Tint(r, g, b, a: Byte); inline;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1259
var
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7069
diff changeset
  1260
    nc, tw: Longword;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1261
begin
9557
a5005b7ca305 differentiate borders a bit
nemo
parents: 9080
diff changeset
  1262
    nc:= (r shl 24) or (g shl 16) or (b shl 8) or a;
5559
a937d43a032f Use local scope global var instead
unc0rr
parents: 5441
diff changeset
  1263
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
  1264
    if nc = lastTint then
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
  1265
        exit;
5559
a937d43a032f Use local scope global var instead
unc0rr
parents: 5441
diff changeset
  1266
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
  1267
    if GrayScale then
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
  1268
        begin
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
  1269
        tw:= round(r * RGB_LUMINANCE_RED + g * RGB_LUMINANCE_GREEN + b * RGB_LUMINANCE_BLUE);
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
  1270
        if tw > 255 then
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
  1271
            tw:= 255;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
  1272
        r:= tw;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
  1273
        g:= tw;
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
  1274
        b:= tw
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
  1275
        end;
5441
39962b855540 Add grayscale option for 3d, helps with colour clashing
nemo
parents: 5235
diff changeset
  1276
10255
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
  1277
    openglTint(r, g, b, a);
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
  1278
    lastTint:= nc;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1279
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1280
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1281
procedure Tint(c: Longword); inline;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1282
begin
9557
a5005b7ca305 differentiate borders a bit
nemo
parents: 9080
diff changeset
  1283
    if c = lastTint then exit;
6986
409dd3851309 add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents: 6982
diff changeset
  1284
    Tint(((c shr 24) and $FF), ((c shr 16) and $FF), (c shr 8) and $FF, (c and $FF))
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1285
end;
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1286
9666
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
  1287
procedure untint(); inline;
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
  1288
begin
10255
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
  1289
    if cWhiteColor = lastTint then exit;
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
  1290
    openglTint($FF, $FF, $FF, $FF);
fdc342ebdc31 tweak untint a little (especially in connection with GrayScale)
sheepluva
parents: 10108
diff changeset
  1291
    lastTint:= cWhiteColor;
9666
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
  1292
end;
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
  1293
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
  1294
procedure setTintAdd(f: boolean); inline;
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
  1295
begin
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
  1296
    if f then
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
  1297
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD)
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
  1298
    else
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
  1299
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
  1300
end;
8dcb25112d96 - Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents: 9557
diff changeset
  1301
10304
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1302
procedure initModule;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1303
begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1304
end;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1305
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1306
procedure freeModule;
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1307
begin
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1308
{$IFDEF GL2}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1309
    glDeleteProgram(shaderMain);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1310
    glDeleteProgram(shaderWater);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1311
    glDeleteBuffers(1, @vBuffer);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1312
    glDeleteBuffers(1, @tBuffer);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1313
    glDeleteBuffers(1, @cBuffer);
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1314
{$ENDIF}
7e40820b7ed6 fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents: 10302
diff changeset
  1315
end;
4378
91655618a510 Introduce uRender
unC0Rr
parents:
diff changeset
  1316
end.