author | unc0rr |
Sat, 07 Feb 2015 23:26:14 +0300 | |
branch | qmlfrontend |
changeset 10817 | 48a53259fad8 |
parent 10606 | 8e95911cb86b |
parent 10724 | eedd0697d55c |
child 10886 | 99273b7afbff |
permissions | -rw-r--r-- |
4976 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
9998 | 3 |
* Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com> |
4976 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
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 | 17 |
*) |
18 |
||
4378 | 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 | 21 |
|
4378 | 22 |
unit uRender; |
23 |
||
24 |
interface |
|
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 | 30 |
|
6999 | 31 |
procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt); |
32 |
procedure DrawSprite (Sprite: TSprite; X, Y, FrameX, FrameY: LongInt); |
|
8560 | 33 |
procedure DrawSpriteFromRect (Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); inline; |
6999 | 34 |
procedure DrawSpriteClipped (Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); |
35 |
procedure DrawSpriteRotated (Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); |
|
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 | 38 |
procedure DrawTexture (X, Y: LongInt; Texture: PTexture); inline; |
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 | 41 |
procedure DrawTextureFromRect (X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline; |
42 |
procedure DrawTextureFromRect (X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline; |
|
43 |
procedure DrawTextureFromRectDir(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture; Dir: LongInt); |
|
6999 | 44 |
procedure DrawTextureCentered (X, Top: LongInt; Source: PTexture); |
45 |
procedure DrawTextureF (Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); |
|
46 |
procedure DrawTextureRotated (Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); |
|
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 | 49 |
procedure DrawCircle (X, Y, Radius, Width: LongInt); |
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 | 52 |
procedure DrawLine (X0, Y0, X1, Y1, Width: Single; color: LongWord); inline; |
6999 | 53 |
procedure DrawLine (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
10360
c243b6a8ad9a
some adjustments and support for mirrored world rendering. disabled atm though, I think it is more confusing than helping
sheepluva
parents:
10354
diff
changeset
|
54 |
procedure DrawLineOnScreen (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
|
55 |
procedure DrawRect (rect: TSDL_Rect; r, g, b, a: Byte; Fill: boolean); |
6999 | 56 |
procedure DrawHedgehog (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); |
57 |
procedure DrawScreenWidget (widget: POnScreenWidget); |
|
10325 | 58 |
procedure DrawWater (Alpha: byte; OffsetY, OffsetX: LongInt); |
10330 | 59 |
procedure DrawWaves (Dir, dX, dY, oX: LongInt; tnt: Byte); |
6999 | 60 |
|
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
61 |
procedure RenderClear (); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
62 |
procedure RenderSetClearColor (r, g, b, a: real); |
6999 | 63 |
procedure Tint (r, g, b, a: Byte); inline; |
64 |
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
|
65 |
procedure untint(); inline; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
66 |
procedure setTintAdd (f: boolean); inline; |
4378 | 67 |
|
10266 | 68 |
function isAreaOffscreen(X, Y, Width, Height: LongInt): boolean; inline; |
69 |
||
70 |
// 0 => not offscreen, <0 => left/top of screen >0 => right/below of screen |
|
71 |
function isDxAreaOffscreen(X, Width: LongInt): LongInt; inline; |
|
72 |
function isDyAreaOffscreen(Y, Height: LongInt): LongInt; inline; |
|
73 |
||
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
74 |
procedure SetScale(f: GLfloat); |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
75 |
procedure UpdateViewLimits(); |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
76 |
|
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
77 |
procedure RenderSetup(); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
78 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
79 |
// 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
|
80 |
|
10309 | 81 |
procedure CreateFramebuffer(var frame, depth, tex: GLuint); |
82 |
procedure DeleteFramebuffer(var frame, depth, tex: GLuint); |
|
83 |
||
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
84 |
procedure EnableTexture(enable:Boolean); |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
85 |
|
10327 | 86 |
procedure SetTexCoordPointer(p: Pointer;n: Integer); inline; |
87 |
procedure SetVertexPointer(p: Pointer;n: Integer); inline; |
|
88 |
procedure SetColorPointer(p: Pointer;n: Integer); inline; |
|
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
89 |
|
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
90 |
procedure UpdateModelviewProjection(); inline; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
91 |
|
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
92 |
procedure openglLoadIdentity (); inline; |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
93 |
procedure openglTranslProjMatrix(X, Y, Z: GLFloat); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
94 |
procedure openglPushMatrix (); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
95 |
procedure openglPopMatrix (); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
96 |
procedure openglTranslatef (X, Y, Z: GLfloat); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
97 |
procedure openglScalef (ScaleX, ScaleY, ScaleZ: GLfloat); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
98 |
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
|
99 |
procedure openglTint (r, g, b, a: Byte); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
100 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
101 |
|
4378 | 102 |
implementation |
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
103 |
uses {$IFNDEF PAS2C} StrUtils, {$ENDIF}SysUtils, uVariables, uUtils, uConsts |
10404
1baaab44a0b2
- Fix arguments parsing in engine assuming paramcount > 0
unc0rr
parents:
10360
diff
changeset
|
104 |
{$IFDEF GL2}, uMatrix, uConsole{$ENDIF}; |
4378 | 105 |
|
8145
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
106 |
{$IFDEF USE_TOUCH_INTERFACE} |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
107 |
const |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
108 |
FADE_ANIM_TIME = 500; |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
109 |
MOVE_ANIM_TIME = 500; |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
110 |
{$ENDIF} |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7069
diff
changeset
|
111 |
|
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
112 |
{$IFDEF GL2} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
113 |
var |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
114 |
shaderMain: GLuint; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
115 |
shaderWater: GLuint; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
116 |
{$ENDIF} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
117 |
|
10327 | 118 |
var VertexBuffer : array [0 ..59] of TVertex2f; |
119 |
TextureBuffer: array [0 .. 7] of TVertex2f; |
|
120 |
LastTint: LongWord = 0; |
|
10326 | 121 |
LastColorPointer , LastTexCoordPointer , LastVertexPointer : Pointer; |
122 |
{$IFDEF GL2} |
|
123 |
LastColorPointerN, LastTexCoordPointerN, LastVertexPointerN: Integer; |
|
124 |
{$ENDIF} |
|
7028 | 125 |
|
10266 | 126 |
function isAreaOffscreen(X, Y, Width, Height: LongInt): boolean; inline; |
127 |
begin |
|
128 |
isAreaOffscreen:= (isDxAreaOffscreen(X, Width) <> 0) or (isDyAreaOffscreen(Y, Height) <> 0); |
|
129 |
end; |
|
130 |
||
131 |
function isDxAreaOffscreen(X, Width: LongInt): LongInt; inline; |
|
132 |
begin |
|
133 |
if X > ViewRightX then exit(1); |
|
134 |
if X + Width < ViewLeftX then exit(-1); |
|
135 |
isDxAreaOffscreen:= 0; |
|
136 |
end; |
|
137 |
||
138 |
function isDyAreaOffscreen(Y, Height: LongInt): LongInt; inline; |
|
139 |
begin |
|
140 |
if Y > ViewBottomY then exit(1); |
|
141 |
if Y + Height < ViewTopY then exit(-1); |
|
142 |
isDyAreaOffscreen:= 0; |
|
143 |
end; |
|
144 |
||
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
145 |
procedure RenderClear(); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
146 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
147 |
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
|
148 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
149 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
150 |
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
|
151 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
152 |
glClearColor(r, g, b, a); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
153 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
154 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
155 |
{$IFDEF GL2} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
156 |
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
|
157 |
var |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
158 |
shader: GLuint; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
159 |
f: Textfile; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
160 |
source, line: AnsiString; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
161 |
sourceA: Pchar; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
162 |
lengthA: GLint; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
163 |
compileResult: GLint; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
164 |
logLength: GLint; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
165 |
log: PChar; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
166 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
167 |
Assign(f, PathPrefix + cPathz[ptShaders] + '/' + shaderFile); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
168 |
filemode:= 0; // readonly |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
169 |
Reset(f); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
170 |
if IOResult <> 0 then |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
171 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
172 |
AddFileLog('Unable to load ' + shaderFile); |
10306 | 173 |
halt(HaltStartupError); |
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
174 |
end; |
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 |
source:=''; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
177 |
while not eof(f) do |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
178 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
179 |
ReadLn(f, line); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
180 |
source:= source + line + #10; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
181 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
182 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
183 |
Close(f); |
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 |
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
|
186 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
187 |
sourceA:=PChar(source); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
188 |
lengthA:=Length(source); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
189 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
190 |
shader:=glCreateShader(shaderType); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
191 |
glShaderSource(shader, 1, @sourceA, @lengthA); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
192 |
glCompileShader(shader); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
193 |
glGetShaderiv(shader, GL_COMPILE_STATUS, @compileResult); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
194 |
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
|
195 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
196 |
if logLength > 1 then |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
197 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
198 |
log := GetMem(logLength); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
199 |
glGetShaderInfoLog(shader, logLength, nil, log); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
200 |
WriteLnToConsole('========== Compiler log =========='); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
201 |
WriteLnToConsole(shortstring(log)); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
202 |
WriteLnToConsole('==================================='); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
203 |
FreeMem(log, logLength); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
204 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
205 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
206 |
if compileResult <> GL_TRUE then |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
207 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
208 |
WriteLnToConsole('Shader compilation failed, halting'); |
10306 | 209 |
halt(HaltStartupError); |
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
210 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
211 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
212 |
CompileShader:= shader; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
213 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
214 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
215 |
function CompileProgram(shaderName: string): GLuint; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
216 |
var |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
217 |
program_: GLuint; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
218 |
vs, fs: GLuint; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
219 |
linkResult: GLint; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
220 |
logLength: GLint; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
221 |
log: PChar; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
222 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
223 |
program_:= glCreateProgram(); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
224 |
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
|
225 |
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
|
226 |
glAttachShader(program_, vs); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
227 |
glAttachShader(program_, fs); |
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 |
glBindAttribLocation(program_, aVertex, PChar('vertex')); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
230 |
glBindAttribLocation(program_, aTexCoord, PChar('texcoord')); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
231 |
glBindAttribLocation(program_, aColor, PChar('color')); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
232 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
233 |
glLinkProgram(program_); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
234 |
glDeleteShader(vs); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
235 |
glDeleteShader(fs); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
236 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
237 |
glGetProgramiv(program_, GL_LINK_STATUS, @linkResult); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
238 |
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
|
239 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
240 |
if logLength > 1 then |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
241 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
242 |
log := GetMem(logLength); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
243 |
glGetProgramInfoLog(program_, logLength, nil, log); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
244 |
WriteLnToConsole('========== Compiler log =========='); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
245 |
WriteLnToConsole(shortstring(log)); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
246 |
WriteLnToConsole('==================================='); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
247 |
FreeMem(log, logLength); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
248 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
249 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
250 |
if linkResult <> GL_TRUE then |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
251 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
252 |
WriteLnToConsole('Linking program failed, halting'); |
10306 | 253 |
halt(HaltStartupError); |
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
254 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
255 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
256 |
CompileProgram:= program_; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
257 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
258 |
{$ENDIF} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
259 |
|
10309 | 260 |
function glLoadExtension(extension : shortstring) : boolean; |
261 |
begin |
|
262 |
//TODO: pas2c does not handle {$IF (GLunit = gles11) OR DEFINED(PAS2C)} |
|
263 |
{$IFNDEF PAS2C} |
|
264 |
{$IF GLunit = gles11} |
|
265 |
// FreePascal doesnt come with OpenGL ES 1.1 Extension headers |
|
266 |
extension:= extension; // avoid hint |
|
267 |
glLoadExtension:= false; |
|
268 |
AddFileLog('OpenGL - "' + extension + '" skipped') |
|
269 |
{$ELSE} |
|
270 |
glLoadExtension:= glext_LoadExtension(extension); |
|
271 |
if glLoadExtension then |
|
272 |
AddFileLog('OpenGL - "' + extension + '" loaded') |
|
273 |
else |
|
274 |
AddFileLog('OpenGL - "' + extension + '" failed to load'); |
|
275 |
{$ENDIF} |
|
276 |
||
277 |
{$ELSE} // pas2c part |
|
278 |
glLoadExtension:= false; |
|
279 |
{$ENDIF} |
|
280 |
end; |
|
281 |
||
10429
e3cdbba07732
simplify {$IF that pas2c did not seem to understand
sheepluva
parents:
10427
diff
changeset
|
282 |
{$IFDEF USE_S3D_RENDERING OR USE_VIDEO_RECORDING} |
10309 | 283 |
procedure CreateFramebuffer(var frame, depth, tex: GLuint); |
284 |
begin |
|
285 |
glGenFramebuffersEXT(1, @frame); |
|
286 |
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frame); |
|
287 |
glGenRenderbuffersEXT(1, @depth); |
|
288 |
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth); |
|
289 |
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, cScreenWidth, cScreenHeight); |
|
290 |
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth); |
|
291 |
glGenTextures(1, @tex); |
|
292 |
glBindTexture(GL_TEXTURE_2D, tex); |
|
10531
b8e6164a1a18
fix for issue 234 - the framebuffers for side-by-side and top/bottom had alpha channels. so when sprites with alpha were blended into the framebuffer it would blend the sprite pixel alpha with the fb pixel alpha
sheepluva
parents:
10494
diff
changeset
|
293 |
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, cScreenWidth, cScreenHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, nil); |
10309 | 294 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
295 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
|
296 |
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0); |
|
297 |
end; |
|
298 |
||
299 |
procedure DeleteFramebuffer(var frame, depth, tex: GLuint); |
|
300 |
begin |
|
301 |
glDeleteTextures(1, @tex); |
|
302 |
glDeleteRenderbuffersEXT(1, @depth); |
|
303 |
glDeleteFramebuffersEXT(1, @frame); |
|
304 |
end; |
|
305 |
||
306 |
{$ENDIF} |
|
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
307 |
procedure RenderSetup(); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
308 |
var AuxBufNum: LongInt = 0; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
309 |
tmpstr: ansistring; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
310 |
tmpint: LongInt; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
311 |
tmpn: LongInt; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
312 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
313 |
// suppress hint/warning |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
314 |
AuxBufNum:= AuxBufNum; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
315 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
316 |
// 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
|
317 |
glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
318 |
if MaxTextureSize <= 0 then |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
319 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
320 |
MaxTextureSize:= 1024; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
321 |
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
|
322 |
end |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
323 |
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
|
324 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
325 |
cReducedQuality := cReducedQuality or rqNoBackground; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
326 |
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
|
327 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
328 |
// everyone loves debugging |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
329 |
// 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
|
330 |
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
|
331 |
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
|
332 |
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
|
333 |
AddFileLog(' |----- Texture Size: ' + inttostr(MaxTextureSize)); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
334 |
{$IFDEF USE_VIDEO_RECORDING} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
335 |
glGetIntegerv(GL_AUX_BUFFERS, @AuxBufNum); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
336 |
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
|
337 |
{$ENDIF} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
338 |
{$IFNDEF PAS2C} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
339 |
AddFileLog(' \----- Extensions: '); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
340 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
341 |
// 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
|
342 |
tmpstr := StrPas(PChar(glGetString(GL_EXTENSIONS))); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
343 |
tmpn := WordCount(tmpstr, [' ']); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
344 |
tmpint := 1; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
345 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
346 |
repeat |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
347 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
348 |
// 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
|
349 |
// 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
|
350 |
AddFileLog(TrimRight( |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
351 |
ExtractWord(tmpint, tmpstr, [' ']) + ' ' + |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
352 |
ExtractWord(tmpint+1, tmpstr, [' ']) + ' ' + |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
353 |
ExtractWord(tmpint+2, tmpstr, [' ']) |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
354 |
)); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
355 |
tmpint := tmpint + 3; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
356 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
357 |
until (tmpint > tmpn); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
358 |
{$ENDIF} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
359 |
AddFileLog(''); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
360 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
361 |
defaultFrame:= 0; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
362 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
363 |
{$IFDEF USE_VIDEO_RECORDING} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
364 |
if GameType = gmtRecord then |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
365 |
begin |
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(defaultFrame, depthv, texv); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
369 |
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, defaultFrame); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
370 |
AddFileLog('Using framebuffer for video recording.'); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
371 |
end |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
372 |
else if AuxBufNum > 0 then |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
373 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
374 |
glDrawBuffer(GL_AUX0); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
375 |
glReadBuffer(GL_AUX0); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
376 |
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
|
377 |
end |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
378 |
else |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
379 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
380 |
glDrawBuffer(GL_BACK); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
381 |
glReadBuffer(GL_BACK); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
382 |
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
|
383 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
384 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
385 |
{$ENDIF} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
386 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
387 |
{$IFDEF GL2} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
388 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
389 |
{$IFDEF PAS2C} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
390 |
err := glewInit(); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
391 |
if err <> GLEW_OK then |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
392 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
393 |
WriteLnToConsole('Failed to initialize GLEW.'); |
10306 | 394 |
halt(HaltStartupError); |
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
395 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
396 |
{$ENDIF} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
397 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
398 |
{$IFNDEF PAS2C} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
399 |
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
|
400 |
halt; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
401 |
{$ENDIF} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
402 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
403 |
shaderWater:= CompileProgram('water'); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
404 |
glUseProgram(shaderWater); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
405 |
glUniform1i(glGetUniformLocation(shaderWater, pchar('tex0')), 0); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
406 |
uWaterMVPLocation:= glGetUniformLocation(shaderWater, pchar('mvp')); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
407 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
408 |
shaderMain:= CompileProgram('default'); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
409 |
glUseProgram(shaderMain); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
410 |
glUniform1i(glGetUniformLocation(shaderMain, pchar('tex0')), 0); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
411 |
uMainMVPLocation:= glGetUniformLocation(shaderMain, pchar('mvp')); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
412 |
uMainTintLocation:= glGetUniformLocation(shaderMain, pchar('tint')); |
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 |
uCurrentMVPLocation:= uMainMVPLocation; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
415 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
416 |
Tint(255, 255, 255, 255); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
417 |
UpdateModelviewProjection; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
418 |
{$ENDIF} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
419 |
|
10427
dd44d2c8fd0e
also fix top/bottom and side-by-side rendering (got also broken in webgl branch)
sheepluva
parents:
10360
diff
changeset
|
420 |
{$IFDEF USE_S3D_RENDERING} |
dd44d2c8fd0e
also fix top/bottom and side-by-side rendering (got also broken in webgl branch)
sheepluva
parents:
10360
diff
changeset
|
421 |
if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) then |
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
422 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
423 |
// 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
|
424 |
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
|
425 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
426 |
CreateFramebuffer(framel, depthl, texl); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
427 |
CreateFramebuffer(framer, depthr, texr); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
428 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
429 |
// reset |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
430 |
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, defaultFrame) |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
431 |
end |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
432 |
else |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
433 |
cStereoMode:= smNone; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
434 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
435 |
{$ENDIF} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
436 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
437 |
// set view port to whole window |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
438 |
glViewport(0, 0, cScreenWidth, cScreenHeight); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
439 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
440 |
{$IFDEF GL2} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
441 |
uMatrix.initModule; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
442 |
hglMatrixMode(MATRIX_MODELVIEW); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
443 |
// prepare default translation/scaling |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
444 |
hglLoadIdentity(); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
445 |
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
|
446 |
hglTranslatef(0, -cScreenHeight / 2, 0); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
447 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
448 |
EnableTexture(True); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
449 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
450 |
glEnableVertexAttribArray(aVertex); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
451 |
glEnableVertexAttribArray(aTexCoord); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
452 |
glGenBuffers(1, @vBuffer); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
453 |
glGenBuffers(1, @tBuffer); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
454 |
glGenBuffers(1, @cBuffer); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
455 |
{$ELSE} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
456 |
glMatrixMode(GL_MODELVIEW); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
457 |
// prepare default translation/scaling |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
458 |
glLoadIdentity(); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
459 |
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
|
460 |
glTranslatef(0, -cScreenHeight / 2, 0); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
461 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
462 |
// 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
|
463 |
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
|
464 |
// disable dithering |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
465 |
glDisable(GL_DITHER); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
466 |
// 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
|
467 |
glEnable(GL_TEXTURE_2D); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
468 |
glEnableClientState(GL_VERTEX_ARRAY); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
469 |
glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
470 |
{$ENDIF} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
471 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
472 |
// enable alpha blending |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
473 |
glEnable(GL_BLEND); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
474 |
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
|
475 |
// 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
|
476 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
477 |
|
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
478 |
procedure openglLoadIdentity(); inline; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
479 |
begin |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
480 |
{$IFDEF GL2} |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
481 |
hglLoadIdentity(); |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
482 |
{$ELSE} |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
483 |
glLoadIdentity(); |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
484 |
{$ENDIF} |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
485 |
end; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
486 |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
487 |
procedure openglTranslProjMatrix(X, Y, Z: GLfloat); 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 |
{$IFDEF GL2} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
490 |
hglMatrixMode(MATRIX_PROJECTION); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
491 |
hglTranslatef(X, Y, Z); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
492 |
hglMatrixMode(MATRIX_MODELVIEW); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
493 |
{$ELSE} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
494 |
glMatrixMode(GL_PROJECTION); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
495 |
glTranslatef(X, Y, Z); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
496 |
glMatrixMode(GL_MODELVIEW); |
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 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
500 |
procedure openglPushMatrix(); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
501 |
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
|
502 |
{$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
|
503 |
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
|
504 |
{$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
|
505 |
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
|
506 |
{$ENDIF} |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
507 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
508 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
509 |
procedure openglPopMatrix(); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
510 |
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
|
511 |
{$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
|
512 |
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
|
513 |
{$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
|
514 |
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
|
515 |
{$ENDIF} |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
516 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
517 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
518 |
procedure openglTranslatef(X, Y, Z: GLfloat); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
519 |
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
|
520 |
{$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
|
521 |
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
|
522 |
{$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
|
523 |
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
|
524 |
{$ENDIF} |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
525 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
526 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
527 |
procedure openglScalef(ScaleX, ScaleY, ScaleZ: GLfloat); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
528 |
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
|
529 |
{$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
|
530 |
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
|
531 |
{$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
|
532 |
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
|
533 |
{$ENDIF} |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
534 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
535 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
536 |
procedure openglRotatef(RotX, RotY, RotZ: GLfloat; dir: LongInt); inline; |
10724
eedd0697d55c
Fix arm* build failures
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10531
diff
changeset
|
537 |
{ workaround for pascal bug http://bugs.freepascal.org/view.php?id=27222 } |
eedd0697d55c
Fix arm* build failures
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10531
diff
changeset
|
538 |
var tmpdir: LongInt; |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
539 |
begin |
10724
eedd0697d55c
Fix arm* build failures
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10531
diff
changeset
|
540 |
tmpdir:=dir; |
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
|
541 |
{$IFDEF GL2} |
10724
eedd0697d55c
Fix arm* build failures
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10531
diff
changeset
|
542 |
hglRotatef(RotX, RotY, RotZ, tmpdir); |
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
|
543 |
{$ELSE} |
10724
eedd0697d55c
Fix arm* build failures
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
10531
diff
changeset
|
544 |
glRotatef(RotX, RotY, RotZ, tmpdir); |
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
|
545 |
{$ENDIF} |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
546 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
547 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
548 |
procedure openglUseColorOnly(b :boolean); inline; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
549 |
begin |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
550 |
if b then |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
551 |
begin |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
552 |
{$IFDEF GL2} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
553 |
glDisableVertexAttribArray(aTexCoord); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
554 |
glEnableVertexAttribArray(aColor); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
555 |
{$ELSE} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
556 |
glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
557 |
glEnableClientState(GL_COLOR_ARRAY); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
558 |
{$ENDIF} |
10326 | 559 |
LastTexCoordPointer:= nil; |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
560 |
end |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
561 |
else |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
562 |
begin |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
563 |
{$IFDEF GL2} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
564 |
glDisableVertexAttribArray(aColor); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
565 |
glEnableVertexAttribArray(aTexCoord); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
566 |
{$ELSE} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
567 |
glDisableClientState(GL_COLOR_ARRAY); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
568 |
glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
569 |
{$ENDIF} |
10326 | 570 |
LastColorPointer:= nil; |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
571 |
end; |
10318 | 572 |
EnableTexture(not b); |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
573 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
574 |
|
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
575 |
procedure UpdateModelviewProjection(); inline; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
576 |
{$IFDEF GL2} |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
577 |
var |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
578 |
mvp: TMatrix4x4f; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
579 |
{$ENDIF} |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
580 |
begin |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
581 |
{$IFDEF GL2} |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
582 |
//MatrixMultiply(mvp, mProjection, mModelview); |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
583 |
{$HINTS OFF} |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
584 |
hglMVP(mvp); |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
585 |
{$HINTS ON} |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
586 |
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
|
587 |
{$ENDIF} |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
588 |
end; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
589 |
|
10327 | 590 |
procedure SetTexCoordPointer(p: Pointer; n: Integer); inline; |
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
591 |
begin |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
592 |
{$IFDEF GL2} |
10326 | 593 |
if (p = LastTexCoordPointer) and (n = LastTexCoordPointerN) then |
594 |
exit; |
|
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
595 |
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
|
596 |
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
|
597 |
glEnableVertexAttribArray(aTexCoord); |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
598 |
glVertexAttribPointer(aTexCoord, 2, GL_FLOAT, GL_FALSE, 0, pointer(0)); |
10327 | 599 |
LastTexCoordPointerN:= n; |
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
600 |
{$ELSE} |
10326 | 601 |
if p = LastTexCoordPointer then |
602 |
exit; |
|
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
603 |
n:= n; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
604 |
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
|
605 |
{$ENDIF} |
10326 | 606 |
LastTexCoordPointer:= p; |
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
607 |
end; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
608 |
|
10327 | 609 |
procedure SetVertexPointer(p: Pointer; n: Integer); inline; |
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
610 |
begin |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
611 |
{$IFDEF GL2} |
10326 | 612 |
if (p = LastVertexPointer) and (n = LastVertexPointerN) then |
613 |
exit; |
|
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
614 |
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
|
615 |
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
|
616 |
glEnableVertexAttribArray(aVertex); |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
617 |
glVertexAttribPointer(aVertex, 2, GL_FLOAT, GL_FALSE, 0, pointer(0)); |
10327 | 618 |
LastVertexPointerN:= n; |
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
619 |
{$ELSE} |
10326 | 620 |
if p = LastVertexPointer then |
621 |
exit; |
|
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
622 |
n:= n; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
623 |
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
|
624 |
{$ENDIF} |
10326 | 625 |
LastVertexPointer:= p; |
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
626 |
end; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
627 |
|
10327 | 628 |
procedure SetColorPointer(p: Pointer; n: Integer); inline; |
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
629 |
begin |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
630 |
{$IFDEF GL2} |
10326 | 631 |
if (p = LastColorPointer) and (n = LastColorPointerN) then |
632 |
exit; |
|
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
633 |
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
|
634 |
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
|
635 |
glEnableVertexAttribArray(aColor); |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
636 |
glVertexAttribPointer(aColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, pointer(0)); |
10327 | 637 |
LastColorPointerN:= n; |
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
638 |
{$ELSE} |
10326 | 639 |
if p = LastColorPointer then |
640 |
exit; |
|
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
641 |
n:= n; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
642 |
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
|
643 |
{$ENDIF} |
10326 | 644 |
LastColorPointer:= p; |
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
645 |
end; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
646 |
|
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
647 |
procedure EnableTexture(enable:Boolean); |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
648 |
begin |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
649 |
{$IFDEF GL2} |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
650 |
if enable then |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
651 |
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
|
652 |
else |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
653 |
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
|
654 |
{$ELSE} |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
655 |
if enable then |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
656 |
glEnable(GL_TEXTURE_2D) |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
657 |
else |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
658 |
glDisable(GL_TEXTURE_2D); |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
659 |
{$ENDIF} |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
660 |
end; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
661 |
|
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
662 |
procedure UpdateViewLimits(); |
10318 | 663 |
var tmp: LongInt; |
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
664 |
begin |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
665 |
// cScaleFactor is 2.0 on "no zoom" |
10318 | 666 |
tmp:= round(0.5 + cScreenWidth / cScaleFactor); |
667 |
ViewRightX := tmp; |
|
668 |
ViewLeftX := -tmp; |
|
669 |
tmp:= round(0.5 + cScreenHeight / cScaleFactor); |
|
670 |
ViewBottomY:= tmp + cScreenHeight div 2; |
|
671 |
ViewTopY := -tmp + cScreenHeight div 2; |
|
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
672 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
673 |
// visual debugging fun :D |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
674 |
if cViewLimitsDebug then |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
675 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
676 |
// some margin on each side |
10318 | 677 |
tmp:= trunc(min(cScreenWidth, cScreenHeight) div 2 / cScaleFactor); |
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
678 |
ViewLeftX := ViewLeftX + trunc(tmp); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
679 |
ViewRightX := ViewRightX - trunc(tmp); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
680 |
ViewBottomY:= ViewBottomY - trunc(tmp); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
681 |
ViewTopY := ViewTopY + trunc(tmp); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
682 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
683 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
684 |
ViewWidth := ViewRightX - ViewLeftX + 1; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
685 |
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
|
686 |
end; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
687 |
|
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
688 |
procedure SetScale(f: GLfloat); |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
689 |
begin |
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
690 |
// 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
|
691 |
if f = cScaleFactor then |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
692 |
exit; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
693 |
|
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
694 |
// 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
|
695 |
if f = cDefaultZoomLevel then |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
696 |
begin |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
697 |
openglPopMatrix; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
698 |
end |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
699 |
else |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
700 |
begin |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
701 |
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
|
702 |
openglLoadIdentity(); |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
703 |
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
|
704 |
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
|
705 |
end; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
706 |
|
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
707 |
cScaleFactor:= f; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
708 |
updateViewLimits(); |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
709 |
|
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
710 |
UpdateModelviewProjection; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
711 |
end; |
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
712 |
|
8560 | 713 |
procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); inline; |
4378 | 714 |
begin |
715 |
r.y:= r.y + Height * Position; |
|
716 |
r.h:= Height; |
|
6999 | 717 |
DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture) |
4378 | 718 |
end; |
719 |
||
8560 | 720 |
procedure DrawTextureFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline; |
4378 | 721 |
begin |
8560 | 722 |
DrawTextureFromRectDir(X, Y, r^.w, r^.h, r, SourceTexture, 1) |
723 |
end; |
|
8833 | 724 |
|
8560 | 725 |
procedure DrawTextureFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); inline; |
726 |
begin |
|
727 |
DrawTextureFromRectDir(X, Y, W, H, r, SourceTexture, 1) |
|
4378 | 728 |
end; |
729 |
||
8560 | 730 |
procedure DrawTextureFromRectDir(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture; Dir: LongInt); |
10324
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
731 |
var _l, _r, _t, _b: real; |
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
732 |
xw, yh: LongInt; |
4378 | 733 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
734 |
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
|
735 |
exit; |
4378 | 736 |
|
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
737 |
{if isDxAreaOffscreen(X, W) <> 0 then |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
738 |
exit; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
739 |
if isDyAreaOffscreen(Y, H) <> 0 then |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
740 |
exit;} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
741 |
|
5565 | 742 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
10311 | 743 |
if (abs(X) > W) and ((abs(X + W / 2) - W / 2) * 2 > ViewWidth) then |
4378 | 744 |
exit; |
10311 | 745 |
if (abs(Y) > H) and ((abs(Y + H / 2 - (0.5 * cScreenHeight)) - H / 2) * 2 > ViewHeight) then |
746 |
exit; |
|
4378 | 747 |
|
748 |
_l:= r^.x / SourceTexture^.w * SourceTexture^.rx; |
|
749 |
_r:= (r^.x + r^.w) / SourceTexture^.w * SourceTexture^.rx; |
|
10324
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
750 |
|
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
751 |
// if direction is mirrored, switch left and right |
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
752 |
if Dir < 0 then |
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
753 |
begin |
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
754 |
_t:= _l; |
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
755 |
_l:= _r; |
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
756 |
_r:= _t; |
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
757 |
end; |
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
758 |
|
4378 | 759 |
_t:= r^.y / SourceTexture^.h * SourceTexture^.ry; |
760 |
_b:= (r^.y + r^.h) / SourceTexture^.h * SourceTexture^.ry; |
|
761 |
||
762 |
glBindTexture(GL_TEXTURE_2D, SourceTexture^.id); |
|
763 |
||
10324
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
764 |
xw:= X + W; |
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
765 |
yh:= Y + H; |
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
766 |
|
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
767 |
VertexBuffer[0].X:= X; |
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
768 |
VertexBuffer[0].Y:= Y; |
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
769 |
VertexBuffer[1].X:= xw; |
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
770 |
VertexBuffer[1].Y:= Y; |
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
771 |
VertexBuffer[2].X:= xw; |
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
772 |
VertexBuffer[2].Y:= yh; |
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
773 |
VertexBuffer[3].X:= X; |
5d90d8ca9657
tweak code of DrawTextureFromRectDir a bit, removing issue with different x offset depending on dir. also removing the workaround wrt that issue in the frozen hog code
sheepluva
parents:
10318
diff
changeset
|
774 |
VertexBuffer[3].Y:= yh; |
4378 | 775 |
|
776 |
TextureBuffer[0].X:= _l; |
|
777 |
TextureBuffer[0].Y:= _t; |
|
778 |
TextureBuffer[1].X:= _r; |
|
779 |
TextureBuffer[1].Y:= _t; |
|
780 |
TextureBuffer[2].X:= _r; |
|
781 |
TextureBuffer[2].Y:= _b; |
|
782 |
TextureBuffer[3].X:= _l; |
|
783 |
TextureBuffer[3].Y:= _b; |
|
784 |
||
10327 | 785 |
SetVertexPointer(@VertexBuffer[0], 4); |
786 |
SetTexCoordPointer(@TextureBuffer[0], 4); |
|
787 |
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
|
4378 | 788 |
end; |
789 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
790 |
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
|
791 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
792 |
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
|
793 |
end; |
4378 | 794 |
|
795 |
procedure DrawTexture(X, Y: LongInt; Texture: PTexture; Scale: GLfloat); |
|
796 |
begin |
|
797 |
||
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
798 |
openglPushMatrix; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
799 |
openglTranslatef(X, Y, 0); |
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
800 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
801 |
if Scale <> 1.0 then |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
802 |
openglScalef(Scale, Scale, 1); |
4378 | 803 |
|
804 |
glBindTexture(GL_TEXTURE_2D, Texture^.id); |
|
805 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
806 |
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
|
807 |
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
|
808 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
809 |
UpdateModelviewProjection; |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
810 |
|
4378 | 811 |
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
|
812 |
openglPopMatrix; |
4378 | 813 |
|
814 |
end; |
|
815 |
||
10020
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
816 |
{ 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
|
817 |
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
|
818 |
var |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
819 |
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
|
820 |
begin |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
821 |
openglPushMatrix; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
822 |
openglTranslatef(X, Y, 0); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
823 |
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
|
824 |
|
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
825 |
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
|
826 |
|
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
827 |
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
|
828 |
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
|
829 |
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
|
830 |
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
|
831 |
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
|
832 |
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
|
833 |
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
|
834 |
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
|
835 |
|
10327 | 836 |
SetVertexPointer(@Texture^.vb, 4); |
837 |
SetTexCoordPointer(@TextureBuffer, 4); |
|
10266 | 838 |
|
839 |
UpdateModelviewProjection; |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
840 |
|
10327 | 841 |
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
842 |
openglPopMatrix; |
10020
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
843 |
end; |
67e127027af6
small tweak/hax for blurry land to make tile borders vanish (when clamping is off)
sheepluva
parents:
9998
diff
changeset
|
844 |
|
4378 | 845 |
procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); |
846 |
begin |
|
6999 | 847 |
DrawTextureRotatedF(Texture, Scale, 0, 0, X, Y, Frame, Dir, w, h, 0) |
4378 | 848 |
end; |
849 |
||
6999 | 850 |
procedure DrawTextureRotatedF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); |
4378 | 851 |
var ft, fb, fl, fr: GLfloat; |
10301 | 852 |
hw, hh, nx, ny: LongInt; |
4378 | 853 |
begin |
10431 | 854 |
// visibility check only under trivial conditions |
855 |
if (Scale <= 1) then |
|
856 |
begin |
|
857 |
if Angle <> 0 then |
|
858 |
begin |
|
859 |
if (OffsetX = 0) and (OffsetY = 0) then |
|
860 |
begin |
|
861 |
// sized doubled because the sprite might occupy up to 1.4 * of it's |
|
862 |
// original size in each dimension, because it is rotated |
|
863 |
if isDxAreaOffscreen(X - w, 2 * w) <> 0 then |
|
864 |
exit; |
|
865 |
if isDYAreaOffscreen(Y - h, 2 * h) <> 0 then |
|
866 |
exit; |
|
867 |
end; |
|
868 |
end |
|
869 |
else |
|
870 |
begin |
|
871 |
if isDxAreaOffscreen(X + dir * trunc(OffsetX) - w div 2, w) <> 0 then |
|
872 |
exit; |
|
873 |
if isDYAreaOffscreen(Y + trunc(OffsetY) - h div 2, h) <> 0 then |
|
874 |
exit; |
|
875 |
end; |
|
876 |
end; |
|
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
877 |
|
10311 | 878 |
{ |
5565 | 879 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
10311 | 880 |
if (abs(X) > W) and ((abs(X + dir * OffsetX) - W / 2) * 2 > ViewWidth) then |
4378 | 881 |
exit; |
10311 | 882 |
if (abs(Y) > H) and ((abs(Y + OffsetY - (cScreenHeight / 2)) - W / 2) * 2 > ViewHeight) then |
883 |
exit; |
|
884 |
} |
|
4378 | 885 |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
886 |
openglPushMatrix; |
10301 | 887 |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
888 |
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
|
889 |
|
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
|
890 |
if Dir = 0 then Dir:= 1; |
4378 | 891 |
|
10301 | 892 |
if Angle <> 0 then |
893 |
openglRotatef(Angle, 0, 0, Dir); |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
894 |
|
10301 | 895 |
if (OffsetX <> 0) or (OffsetY <> 0) then |
896 |
openglTranslatef(Dir*OffsetX, OffsetY, 0); |
|
897 |
||
898 |
if Scale <> 1.0 then |
|
899 |
openglScalef(Scale, Scale, 1); |
|
4378 | 900 |
|
901 |
// Any reason for this call? And why only in t direction, not s? |
|
902 |
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
|
903 |
||
10301 | 904 |
if Dir > 0 then |
905 |
hw:= w div 2 |
|
906 |
else |
|
907 |
hw:= -w div 2; |
|
4378 | 908 |
|
10301 | 909 |
hh:= h div 2; |
910 |
||
911 |
nx:= Texture^.w div w; // number of horizontal frames |
|
10311 | 912 |
if nx = 0 then nx:= 1; // one frame is minimum |
10301 | 913 |
ny:= Texture^.h div h; // number of vertical frames |
10311 | 914 |
if ny = 0 then ny:= 1; |
4378 | 915 |
|
916 |
ft:= (Frame mod ny) * Texture^.ry / ny; |
|
917 |
fb:= ((Frame mod ny) + 1) * Texture^.ry / ny; |
|
918 |
fl:= (Frame div ny) * Texture^.rx / nx; |
|
919 |
fr:= ((Frame div ny) + 1) * Texture^.rx / nx; |
|
920 |
||
921 |
glBindTexture(GL_TEXTURE_2D, Texture^.id); |
|
922 |
||
923 |
VertexBuffer[0].X:= -hw; |
|
10301 | 924 |
VertexBuffer[0].Y:= -hh; |
925 |
VertexBuffer[1].X:= hw; |
|
926 |
VertexBuffer[1].Y:= -hh; |
|
927 |
VertexBuffer[2].X:= hw; |
|
928 |
VertexBuffer[2].Y:= hh; |
|
4378 | 929 |
VertexBuffer[3].X:= -hw; |
10301 | 930 |
VertexBuffer[3].Y:= hh; |
4378 | 931 |
|
932 |
TextureBuffer[0].X:= fl; |
|
933 |
TextureBuffer[0].Y:= ft; |
|
934 |
TextureBuffer[1].X:= fr; |
|
935 |
TextureBuffer[1].Y:= ft; |
|
936 |
TextureBuffer[2].X:= fr; |
|
937 |
TextureBuffer[2].Y:= fb; |
|
938 |
TextureBuffer[3].X:= fl; |
|
939 |
TextureBuffer[3].Y:= fb; |
|
940 |
||
10327 | 941 |
SetVertexPointer(@VertexBuffer[0], 4); |
942 |
SetTexCoordPointer(@TextureBuffer[0], 4); |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
943 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
944 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
945 |
|
10327 | 946 |
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
4378 | 947 |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
948 |
openglPopMatrix; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
949 |
|
4378 | 950 |
end; |
951 |
||
6999 | 952 |
procedure DrawSpriteRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); |
4378 | 953 |
begin |
6999 | 954 |
DrawTextureRotated(SpritesData[Sprite].Texture, |
4378 | 955 |
SpritesData[Sprite].Width, |
956 |
SpritesData[Sprite].Height, |
|
957 |
X, Y, Dir, Angle) |
|
958 |
end; |
|
959 |
||
6999 | 960 |
procedure DrawSpriteRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); |
4378 | 961 |
begin |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
962 |
|
10312 | 963 |
if Angle <> 0 then |
964 |
begin |
|
965 |
// sized doubled because the sprite might occupy up to 1.4 * of it's |
|
966 |
// original size in each dimension, because it is rotated |
|
967 |
if isDxAreaOffscreen(X - SpritesData[Sprite].Width, 2 * SpritesData[Sprite].Width) <> 0 then |
|
968 |
exit; |
|
969 |
if isDYAreaOffscreen(Y - SpritesData[Sprite].Height, 2 * SpritesData[Sprite].Height) <> 0 then |
|
970 |
exit; |
|
971 |
end |
|
972 |
else |
|
973 |
begin |
|
974 |
if isDxAreaOffscreen(X - SpritesData[Sprite].Width div 2, SpritesData[Sprite].Width) <> 0 then |
|
975 |
exit; |
|
976 |
if isDYAreaOffscreen(Y - SpritesData[Sprite].Height div 2 , SpritesData[Sprite].Height) <> 0 then |
|
977 |
exit; |
|
978 |
end; |
|
979 |
||
980 |
||
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
981 |
openglPushMatrix; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
982 |
openglTranslatef(X, Y, 0); |
4378 | 983 |
|
10312 | 984 |
// mirror |
4378 | 985 |
if Dir < 0 then |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
986 |
openglScalef(-1.0, 1.0, 1.0); |
10312 | 987 |
|
988 |
// apply angle after (conditional) mirroring |
|
989 |
if Angle <> 0 then |
|
990 |
openglRotatef(Angle, 0, 0, 1); |
|
4378 | 991 |
|
992 |
DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame); |
|
993 |
||
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
994 |
openglPopMatrix; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
995 |
|
4378 | 996 |
end; |
997 |
||
6999 | 998 |
procedure DrawTextureRotated(Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); |
4378 | 999 |
begin |
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1000 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1001 |
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
|
1002 |
exit; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1003 |
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
|
1004 |
exit; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1005 |
|
5565 | 1006 |
// 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
|
1007 |
{if (abs(X) > 2 * hw) and ((abs(X) - hw) > cScreenWidth / cScaleFactor) then |
4378 | 1008 |
exit; |
1009 |
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
|
1010 |
exit;} |
4378 | 1011 |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1012 |
openglPushMatrix; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1013 |
openglTranslatef(X, Y, 0); |
4378 | 1014 |
|
1015 |
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
|
1016 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
1017 |
hw:= - hw; |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1018 |
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
|
1019 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
1020 |
else |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1021 |
openglRotatef(Angle, 0, 0, 1); |
4378 | 1022 |
|
6999 | 1023 |
glBindTexture(GL_TEXTURE_2D, Texture^.id); |
4378 | 1024 |
|
1025 |
VertexBuffer[0].X:= -hw; |
|
1026 |
VertexBuffer[0].Y:= -hh; |
|
1027 |
VertexBuffer[1].X:= hw; |
|
1028 |
VertexBuffer[1].Y:= -hh; |
|
1029 |
VertexBuffer[2].X:= hw; |
|
1030 |
VertexBuffer[2].Y:= hh; |
|
1031 |
VertexBuffer[3].X:= -hw; |
|
1032 |
VertexBuffer[3].Y:= hh; |
|
1033 |
||
10327 | 1034 |
SetVertexPointer(@VertexBuffer[0], 4); |
1035 |
SetTexCoordPointer(@Texture^.tb, 4); |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1036 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1037 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1038 |
|
10327 | 1039 |
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
4378 | 1040 |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1041 |
openglPopMatrix; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1042 |
|
4378 | 1043 |
end; |
1044 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
1045 |
procedure DrawSprite(Sprite: TSprite; X, Y, Frame: LongInt); |
4378 | 1046 |
var row, col, numFramesFirstCol: LongInt; |
1047 |
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
|
1048 |
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
|
1049 |
exit; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
1050 |
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
|
1051 |
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
|
1052 |
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
|
1053 |
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
|
1054 |
end; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
1055 |
|
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
1056 |
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
|
1057 |
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
|
1058 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
1059 |
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
|
1060 |
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
|
1061 |
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
|
1062 |
r.h:= SpritesData[Sprite].Height; |
6999 | 1063 |
DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture) |
4378 | 1064 |
end; |
1065 |
||
1066 |
procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); |
|
1067 |
var r: TSDL_Rect; |
|
1068 |
begin |
|
1069 |
r.x:= 0; |
|
1070 |
r.y:= 0; |
|
1071 |
r.w:= SpritesData[Sprite].Width; |
|
1072 |
r.h:= SpritesData[Sprite].Height; |
|
1073 |
||
1074 |
if (X < LeftX) then |
|
1075 |
r.x:= LeftX - X; |
|
1076 |
if (Y < TopY) then |
|
1077 |
r.y:= TopY - Y; |
|
1078 |
||
1079 |
if (Y + SpritesData[Sprite].Height > BottomY) then |
|
1080 |
r.h:= BottomY - Y + 1; |
|
1081 |
if (X + SpritesData[Sprite].Width > RightX) then |
|
1082 |
r.w:= RightX - X + 1; |
|
1083 |
||
10015 | 1084 |
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
|
1085 |
exit; |
59cde1e53ca5
This seems to be enough to fix the bug with sprGirder rendered in stripe
unc0rr
parents:
9666
diff
changeset
|
1086 |
|
4378 | 1087 |
dec(r.h, r.y); |
1088 |
dec(r.w, r.x); |
|
1089 |
||
6999 | 1090 |
DrawTextureFromRect(X + r.x, Y + r.y, @r, SpritesData[Sprite].Texture) |
4378 | 1091 |
end; |
1092 |
||
6999 | 1093 |
procedure DrawTextureCentered(X, Top: LongInt; Source: PTexture); |
4378 | 1094 |
var scale: GLfloat; |
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1095 |
left : LongInt; |
4378 | 1096 |
begin |
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1097 |
// scale down if larger than screen |
4378 | 1098 |
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
|
1099 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1100 |
scale:= cScreenWidth / (Source^.w + 20); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1101 |
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
|
1102 |
end |
4378 | 1103 |
else |
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1104 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1105 |
left:= X - Source^.w div 2; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1106 |
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
|
1107 |
DrawTexture(left, Top, Source); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1108 |
end; |
4378 | 1109 |
end; |
1110 |
||
9557 | 1111 |
procedure DrawLine(X0, Y0, X1, Y1, Width: Single; color: LongWord); inline; |
1112 |
begin |
|
1113 |
DrawLine(X0, Y0, X1, Y1, Width, (color shr 24) and $FF, (color shr 16) and $FF, (color shr 8) and $FF, color and $FF) |
|
1114 |
end; |
|
1115 |
||
4378 | 1116 |
procedure DrawLine(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
1117 |
begin |
|
10360
c243b6a8ad9a
some adjustments and support for mirrored world rendering. disabled atm though, I think it is more confusing than helping
sheepluva
parents:
10354
diff
changeset
|
1118 |
openglPushMatrix(); |
c243b6a8ad9a
some adjustments and support for mirrored world rendering. disabled atm though, I think it is more confusing than helping
sheepluva
parents:
10354
diff
changeset
|
1119 |
openglTranslatef(WorldDx, WorldDy, 0); |
c243b6a8ad9a
some adjustments and support for mirrored world rendering. disabled atm though, I think it is more confusing than helping
sheepluva
parents:
10354
diff
changeset
|
1120 |
|
c243b6a8ad9a
some adjustments and support for mirrored world rendering. disabled atm though, I think it is more confusing than helping
sheepluva
parents:
10354
diff
changeset
|
1121 |
UpdateModelviewProjection; |
c243b6a8ad9a
some adjustments and support for mirrored world rendering. disabled atm though, I think it is more confusing than helping
sheepluva
parents:
10354
diff
changeset
|
1122 |
|
c243b6a8ad9a
some adjustments and support for mirrored world rendering. disabled atm though, I think it is more confusing than helping
sheepluva
parents:
10354
diff
changeset
|
1123 |
DrawLineOnScreen(X0, Y0, X1, Y1, Width, r, g, b, a); |
c243b6a8ad9a
some adjustments and support for mirrored world rendering. disabled atm though, I think it is more confusing than helping
sheepluva
parents:
10354
diff
changeset
|
1124 |
|
c243b6a8ad9a
some adjustments and support for mirrored world rendering. disabled atm though, I think it is more confusing than helping
sheepluva
parents:
10354
diff
changeset
|
1125 |
openglPopMatrix(); |
c243b6a8ad9a
some adjustments and support for mirrored world rendering. disabled atm though, I think it is more confusing than helping
sheepluva
parents:
10354
diff
changeset
|
1126 |
end; |
c243b6a8ad9a
some adjustments and support for mirrored world rendering. disabled atm though, I think it is more confusing than helping
sheepluva
parents:
10354
diff
changeset
|
1127 |
|
c243b6a8ad9a
some adjustments and support for mirrored world rendering. disabled atm though, I think it is more confusing than helping
sheepluva
parents:
10354
diff
changeset
|
1128 |
procedure DrawLineOnScreen(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
c243b6a8ad9a
some adjustments and support for mirrored world rendering. disabled atm though, I think it is more confusing than helping
sheepluva
parents:
10354
diff
changeset
|
1129 |
begin |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1130 |
glEnable(GL_LINE_SMOOTH); |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1131 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1132 |
EnableTexture(False); |
4378 | 1133 |
|
1134 |
glLineWidth(Width); |
|
1135 |
||
1136 |
Tint(r, g, b, a); |
|
1137 |
VertexBuffer[0].X:= X0; |
|
1138 |
VertexBuffer[0].Y:= Y0; |
|
1139 |
VertexBuffer[1].X:= X1; |
|
1140 |
VertexBuffer[1].Y:= Y1; |
|
1141 |
||
10327 | 1142 |
SetVertexPointer(@VertexBuffer[0], 2); |
1143 |
glDrawArrays(GL_LINES, 0, 2); |
|
10360
c243b6a8ad9a
some adjustments and support for mirrored world rendering. disabled atm though, I think it is more confusing than helping
sheepluva
parents:
10354
diff
changeset
|
1144 |
untint(); |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1145 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1146 |
EnableTexture(True); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1147 |
|
4378 | 1148 |
glDisable(GL_LINE_SMOOTH); |
1149 |
end; |
|
1150 |
||
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1151 |
procedure DrawRect(rect: TSDL_Rect; r, g, b, a: Byte; Fill: boolean); |
4378 | 1152 |
begin |
5565 | 1153 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
10311 | 1154 |
if (abs(rect.x) > rect.w) and ((abs(rect.x + rect.w / 2) - rect.w / 2) * 2 > ViewWidth) then |
4378 | 1155 |
exit; |
10311 | 1156 |
if (abs(rect.y) > rect.h) and ((abs(rect.y + rect.h / 2 - (cScreenHeight / 2)) - rect.h / 2) * 2 > ViewHeight) then |
1157 |
exit; |
|
4378 | 1158 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1159 |
EnableTexture(False); |
4378 | 1160 |
|
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1161 |
Tint(r, g, b, a); |
4378 | 1162 |
|
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1163 |
with rect do |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1164 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1165 |
VertexBuffer[0].X:= x; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1166 |
VertexBuffer[0].Y:= y; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1167 |
VertexBuffer[1].X:= x + w; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1168 |
VertexBuffer[1].Y:= y; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1169 |
VertexBuffer[2].X:= x + w; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1170 |
VertexBuffer[2].Y:= y + h; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1171 |
VertexBuffer[3].X:= x; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1172 |
VertexBuffer[3].Y:= y + h; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1173 |
end; |
4378 | 1174 |
|
10327 | 1175 |
SetVertexPointer(@VertexBuffer[0], 4); |
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1176 |
if Fill then |
10327 | 1177 |
glDrawArrays(GL_TRIANGLE_FAN, 0, 4) |
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1178 |
else |
10328 | 1179 |
begin |
1180 |
glLineWidth(1); |
|
10327 | 1181 |
glDrawArrays(GL_LINE_LOOP, 0, 4); |
10328 | 1182 |
end; |
4378 | 1183 |
|
9666
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
1184 |
untint; |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1185 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1186 |
EnableTexture(True); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1187 |
|
4378 | 1188 |
end; |
1189 |
||
8330 | 1190 |
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
|
1191 |
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
|
1192 |
Tint(r, g, b, a); |
10015 | 1193 |
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
|
1194 |
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
|
1195 |
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
|
1196 |
|
8330 | 1197 |
procedure DrawCircle(X, Y, Radius, Width: LongInt); |
4378 | 1198 |
var |
1199 |
i: LongInt; |
|
1200 |
begin |
|
10328 | 1201 |
i:= Radius + Width; |
1202 |
if isDxAreaOffscreen(X - i, 2 * i) <> 0 then |
|
1203 |
exit; |
|
1204 |
if isDyAreaOffscreen(Y - i, 2 * i) <> 0 then |
|
1205 |
exit; |
|
1206 |
||
5561
dfbe55237c64
Shrink number of circle points to 60, reenable seduction circle (no longer crashes)
nemo
parents:
5559
diff
changeset
|
1207 |
for i := 0 to 59 do begin |
10328 | 1208 |
VertexBuffer[i].X := X + Radius*cos(i*pi/30); |
1209 |
VertexBuffer[i].Y := Y + Radius*sin(i*pi/30); |
|
4378 | 1210 |
end; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1211 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1212 |
EnableTexture(False); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1213 |
glEnable(GL_LINE_SMOOTH); |
10327 | 1214 |
//openglPushMatrix; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1215 |
glLineWidth(Width); |
10328 | 1216 |
SetVertexPointer(@VertexBuffer[0], 60); |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1217 |
glDrawArrays(GL_LINE_LOOP, 0, 60); |
10327 | 1218 |
//openglPopMatrix; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1219 |
EnableTexture(True); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1220 |
glDisable(GL_LINE_SMOOTH); |
4378 | 1221 |
end; |
1222 |
||
1223 |
||
4385 | 1224 |
procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); |
1225 |
const VertexBuffer: array [0..3] of TVertex2f = ( |
|
7069 | 1226 |
(X: -16; Y: -16), |
1227 |
(X: 16; Y: -16), |
|
1228 |
(X: 16; Y: 16), |
|
1229 |
(X: -16; Y: 16)); |
|
4385 | 1230 |
var l, r, t, b: real; |
1231 |
begin |
|
5565 | 1232 |
// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
10311 | 1233 |
if (abs(X) > 32) and ((abs(X) - 16) * 2 > ViewWidth) then |
4385 | 1234 |
exit; |
10311 | 1235 |
if (abs(Y) > 32) and ((abs(Y - cScreenHeight / 2) - 16) * 2 > ViewHeight) then |
4385 | 1236 |
exit; |
1237 |
||
1238 |
t:= Pos * 32 / HHTexture^.h; |
|
1239 |
b:= (Pos + 1) * 32 / HHTexture^.h; |
|
1240 |
||
1241 |
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
|
1242 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
1243 |
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
|
1244 |
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
|
1245 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
1246 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
1247 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6394
diff
changeset
|
1248 |
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
|
1249 |
r:= (Step + 1) * 32 / HHTexture^.w |
4385 | 1250 |
end; |
1251 |
||
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1252 |
openglPushMatrix(); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1253 |
openglTranslatef(X, Y, 0); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1254 |
openglRotatef(Angle, 0, 0, 1); |
4385 | 1255 |
|
1256 |
glBindTexture(GL_TEXTURE_2D, HHTexture^.id); |
|
1257 |
||
1258 |
TextureBuffer[0].X:= l; |
|
1259 |
TextureBuffer[0].Y:= t; |
|
1260 |
TextureBuffer[1].X:= r; |
|
1261 |
TextureBuffer[1].Y:= t; |
|
1262 |
TextureBuffer[2].X:= r; |
|
1263 |
TextureBuffer[2].Y:= b; |
|
1264 |
TextureBuffer[3].X:= l; |
|
1265 |
TextureBuffer[3].Y:= b; |
|
1266 |
||
10327 | 1267 |
SetVertexPointer(@VertexBuffer[0], 4); |
1268 |
SetTexCoordPointer(@TextureBuffer[0], 4); |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1269 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1270 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1271 |
|
10327 | 1272 |
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
4385 | 1273 |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1274 |
openglPopMatrix; |
4385 | 1275 |
end; |
1276 |
||
6688 | 1277 |
procedure DrawScreenWidget(widget: POnScreenWidget); |
6992 | 1278 |
{$IFDEF USE_TOUCH_INTERFACE} |
6688 | 1279 |
var alpha: byte = $FF; |
1280 |
begin |
|
1281 |
with widget^ do |
|
1282 |
begin |
|
1283 |
if (fadeAnimStart <> 0) then |
|
1284 |
begin |
|
1285 |
if RealTicks > (fadeAnimStart + FADE_ANIM_TIME) then |
|
1286 |
fadeAnimStart:= 0 |
|
1287 |
else |
|
8330 | 1288 |
if show then |
6688 | 1289 |
alpha:= Byte(trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF)) |
8330 | 1290 |
else |
6688 | 1291 |
alpha:= Byte($FF - trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF)); |
1292 |
end; |
|
1293 |
||
1294 |
with moveAnim do |
|
1295 |
if animate then |
|
1296 |
if RealTicks > (startTime + MOVE_ANIM_TIME) then |
|
1297 |
begin |
|
1298 |
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
|
1299 |
animate:= false; |
6695
32de8965c62c
refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents:
6689
diff
changeset
|
1300 |
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
|
1301 |
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
|
1302 |
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
|
1303 |
active.y:= active.y + (target.y - source.y); |
6688 | 1304 |
end |
1305 |
else |
|
1306 |
begin |
|
6695
32de8965c62c
refactored a few types involved in the touch interface and corrected a few invisible mistakes
koda
parents:
6689
diff
changeset
|
1307 |
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
|
1308 |
frame.y:= source.y + Round((target.y - source.y) * ((RealTicks - startTime) / MOVE_ANIM_TIME)); |
6688 | 1309 |
end; |
1310 |
||
1311 |
if show or (fadeAnimStart <> 0) then |
|
1312 |
begin |
|
1313 |
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
|
1314 |
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
|
1315 |
untint; |
6688 | 1316 |
end; |
1317 |
end; |
|
6992 | 1318 |
{$ELSE} |
1319 |
begin |
|
1320 |
widget:= widget; // avoid hint |
|
6689 | 1321 |
{$ENDIF} |
6688 | 1322 |
end; |
4385 | 1323 |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1324 |
procedure BeginWater; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1325 |
begin |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1326 |
{$IFDEF GL2} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1327 |
glUseProgram(shaderWater); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1328 |
uCurrentMVPLocation:=uWaterMVPLocation; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1329 |
UpdateModelviewProjection; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1330 |
{$ENDIF} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1331 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1332 |
openglUseColorOnly(true); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1333 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1334 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1335 |
procedure EndWater; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1336 |
begin |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1337 |
{$IFDEF GL2} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1338 |
glUseProgram(shaderMain); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1339 |
uCurrentMVPLocation:=uMainMVPLocation; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1340 |
UpdateModelviewProjection; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1341 |
{$ENDIF} |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1342 |
|
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1343 |
openglUseColorOnly(false); |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1344 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1345 |
|
10330 | 1346 |
procedure PrepareVbForWater( |
1347 |
WithWalls: Boolean; |
|
1348 |
InTopY, OutTopY, InLeftX, OutLeftX, InRightX, OutRightX, BottomY: LongInt; |
|
1349 |
out first, count: LongInt); |
|
1350 |
||
10331 | 1351 |
var firsti, afteri, lol: LongInt; |
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1352 |
begin |
10325 | 1353 |
|
10330 | 1354 |
// We will draw both bottom water and the water walls with a single call, |
1355 |
// by rendering a GL_TRIANGLE_STRIP of eight points. |
|
1356 |
// |
|
1357 |
// GL_TRIANGLE_STRIP works like this: "always create triangle between |
|
1358 |
// newest point and the two points that were specified before it." |
|
1359 |
// |
|
1360 |
// To get the result we want we will order the points like this: |
|
1361 |
// ^ -Y |
|
1362 |
// | |
|
1363 |
// 0-------1 7-------6 <--------------------- OutTopY -| |
|
1364 |
// | /| | _/| | |
|
1365 |
// | / | | / | | |
|
1366 |
// | / | | _/ | | |
|
1367 |
// | / | | / | | |
|
1368 |
// | / _.3---------5{ | <--------------------- InTopY --| |
|
1369 |
// | / _/ `---.___ `--._ | | |
|
1370 |
// |/_/ `---.___\| | |
|
1371 |
// 2-------------------------4 <--------------------- BottomY -| |
|
1372 |
// | |
|
1373 |
// ^ ^ ^ ^ V +Y |
|
1374 |
// | | | | |
|
1375 |
// | | | | |
|
1376 |
// | | | | |
|
1377 |
// | | | | |
|
1378 |
// | | | | |
|
1379 |
// | | | | |
|
1380 |
// | | | | |
|
1381 |
// OutLeftX InLeftX InRightX OutRightX |
|
1382 |
// | | | | |
|
1383 |
// <----------------------------------------> |
|
1384 |
// -X +X |
|
1385 |
// |
|
1386 |
||
10325 | 1387 |
firsti:= -1; |
1388 |
afteri:= 0; |
|
1389 |
||
10331 | 1390 |
if GameTicks < 2000 then |
1391 |
lol:= 2000 - GameTicks |
|
1392 |
else |
|
1393 |
lol:= 0; |
|
1394 |
||
10330 | 1395 |
if InTopY < 0 then |
1396 |
InTopY:= 0; |
|
10325 | 1397 |
|
10330 | 1398 |
if not WithWalls then |
10325 | 1399 |
begin |
10330 | 1400 |
// if no walls are needed, then bottom water surface spans full length |
1401 |
InLeftX := OutLeftX; |
|
1402 |
InRightX:= OutRightX; |
|
10325 | 1403 |
end |
1404 |
else |
|
1405 |
begin |
|
10333 | 1406 |
if InLeftX > ViewLeftX then |
10325 | 1407 |
begin |
10331 | 1408 |
VertexBuffer[0].X:= OutLeftX - lol; |
10330 | 1409 |
VertexBuffer[0].Y:= OutTopY; |
10331 | 1410 |
VertexBuffer[1].X:= InLeftX - lol; |
10330 | 1411 |
VertexBuffer[1].Y:= OutTopY; |
10325 | 1412 |
// shares vertices 2 and 3 with bottom water |
1413 |
firsti:= 0; |
|
1414 |
afteri:= 4; |
|
1415 |
end; |
|
1416 |
||
10333 | 1417 |
if InRightX < ViewRightX then |
10325 | 1418 |
begin |
10331 | 1419 |
VertexBuffer[6].X:= OutRightX + lol; |
10330 | 1420 |
VertexBuffer[6].Y:= OutTopY; |
10331 | 1421 |
VertexBuffer[7].X:= InRightX + lol; |
10330 | 1422 |
VertexBuffer[7].Y:= OutTopY; |
10325 | 1423 |
// shares vertices 4 and 5 with bottom water |
1424 |
if firsti < 0 then |
|
1425 |
firsti:= 4; |
|
1426 |
afteri:= 8; |
|
1427 |
end; |
|
1428 |
end; |
|
1429 |
||
10333 | 1430 |
if InTopY < ViewBottomY then |
10325 | 1431 |
begin |
1432 |
// shares vertices 2-5 with water walls |
|
1433 |
||
1434 |
// starts at vertex 2 |
|
1435 |
if (firsti < 0) or (firsti > 2) then |
|
1436 |
firsti:= 2; |
|
1437 |
// ends at vertex 5 |
|
1438 |
if afteri < 6 then |
|
1439 |
afteri:= 6; |
|
1440 |
end; |
|
1441 |
||
1442 |
if firsti < 0 then |
|
10330 | 1443 |
begin |
1444 |
// nothing to draw at all! |
|
1445 |
first:= -1; |
|
1446 |
count:= 0; |
|
1447 |
exit; |
|
1448 |
end; |
|
10302
ea0b0e2efd95
huh? me? nono, don't mind me. I'm just here to clean up.
sheepluva
parents:
10301
diff
changeset
|
1449 |
|
10325 | 1450 |
if firsti < 4 then |
1451 |
begin |
|
10330 | 1452 |
VertexBuffer[2].X:= OutLeftX; |
1453 |
VertexBuffer[2].Y:= BottomY; |
|
1454 |
VertexBuffer[3].X:= InLeftX; |
|
1455 |
VertexBuffer[3].Y:= InTopY; |
|
10325 | 1456 |
end; |
1457 |
||
1458 |
if afteri > 4 then |
|
1459 |
begin |
|
10330 | 1460 |
VertexBuffer[4].X:= OutRightX; |
1461 |
VertexBuffer[4].Y:= BottomY; |
|
1462 |
VertexBuffer[5].X:= InRightX; |
|
1463 |
VertexBuffer[5].Y:= InTopY; |
|
10325 | 1464 |
end; |
1465 |
||
10330 | 1466 |
// first index to draw in vertex buffer |
1467 |
first:= firsti; |
|
10325 | 1468 |
// number of points to draw |
10330 | 1469 |
count:= afteri - firsti; |
1470 |
||
1471 |
end; |
|
1472 |
||
1473 |
procedure DrawWater(Alpha: byte; OffsetY, OffsetX: LongInt); |
|
1474 |
var first, count: LongInt; |
|
1475 |
begin |
|
1476 |
||
1477 |
if (WorldEdge <> weSea) then |
|
1478 |
PrepareVbForWater(false, |
|
1479 |
OffsetY + WorldDy + cWaterLine, 0, |
|
1480 |
0, ViewLeftX, |
|
1481 |
0, ViewRightX, |
|
1482 |
ViewBottomY, |
|
1483 |
first, count) |
|
1484 |
else |
|
1485 |
PrepareVbForWater(true, |
|
1486 |
OffsetY + WorldDy + cWaterLine, ViewTopY, |
|
10494 | 1487 |
LongInt(LeftX) + WorldDx - OffsetX, ViewLeftX, |
1488 |
LongInt(RightX) + WorldDx + OffsetX, ViewRightX, |
|
10330 | 1489 |
ViewBottomY, |
1490 |
first, count); |
|
1491 |
||
1492 |
// quit if there's nothing to draw (nothing in view) |
|
1493 |
if count < 1 then |
|
1494 |
exit; |
|
10325 | 1495 |
|
1496 |
// drawing time |
|
1497 |
||
1498 |
UpdateModelviewProjection; |
|
1499 |
||
1500 |
BeginWater; |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1501 |
|
10325 | 1502 |
if SuddenDeathDmg then |
1503 |
begin // only set alpha if it differs from what we want |
|
1504 |
if SDWaterColorArray[0].a <> Alpha then |
|
1505 |
begin |
|
1506 |
SDWaterColorArray[0].a := Alpha; |
|
1507 |
SDWaterColorArray[1].a := Alpha; |
|
1508 |
SDWaterColorArray[2].a := Alpha; |
|
1509 |
SDWaterColorArray[3].a := Alpha; |
|
1510 |
SDWaterColorArray[4].a := Alpha; |
|
1511 |
SDWaterColorArray[5].a := Alpha; |
|
1512 |
SDWaterColorArray[6].a := Alpha; |
|
1513 |
SDWaterColorArray[7].a := Alpha; |
|
1514 |
end; |
|
1515 |
SetColorPointer(@SDWaterColorArray[0], 8); |
|
1516 |
end |
|
1517 |
else |
|
1518 |
begin |
|
1519 |
if WaterColorArray[0].a <> Alpha then |
|
1520 |
begin |
|
1521 |
WaterColorArray[0].a := Alpha; |
|
1522 |
WaterColorArray[1].a := Alpha; |
|
1523 |
WaterColorArray[2].a := Alpha; |
|
1524 |
WaterColorArray[3].a := Alpha; |
|
1525 |
WaterColorArray[4].a := Alpha; |
|
1526 |
WaterColorArray[5].a := Alpha; |
|
1527 |
WaterColorArray[6].a := Alpha; |
|
1528 |
WaterColorArray[7].a := Alpha; |
|
1529 |
end; |
|
1530 |
SetColorPointer(@WaterColorArray[0], 8); |
|
1531 |
end; |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1532 |
|
10325 | 1533 |
SetVertexPointer(@VertexBuffer[0], 8); |
1534 |
||
10330 | 1535 |
glDrawArrays(GL_TRIANGLE_STRIP, first, count); |
10325 | 1536 |
|
1537 |
EndWater; |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1538 |
|
10325 | 1539 |
{$IFNDEF GL2} |
1540 |
// must not be Tint() as color array seems to stay active and color reset is required |
|
1541 |
glColor4ub($FF, $FF, $FF, $FF); |
|
1542 |
{$ENDIF} |
|
10275
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1543 |
end; |
6c91047f59b6
RAR: cleaning up a bit of the IFDEF-clusterf*ck
sheepluva
parents:
10266
diff
changeset
|
1544 |
|
10330 | 1545 |
procedure DrawWaves(Dir, dX, dY, oX: LongInt; tnt: Byte); |
1546 |
var first, count, topy, lx, rx, spriteHeight, spriteWidth: LongInt; |
|
1547 |
lw, nWaves, shift: GLfloat; |
|
1548 |
sprite: TSprite; |
|
1549 |
begin |
|
1550 |
// note: spriteHeight is the Height of the wave sprite while |
|
1551 |
// cWaveHeight describes how many pixels of it will be above waterline |
|
1552 |
||
1553 |
if SuddenDeathDmg then |
|
1554 |
sprite:= sprSDWater |
|
1555 |
else |
|
1556 |
sprite:= sprWater; |
|
1557 |
||
1558 |
spriteHeight:= SpritesData[sprite].Height; |
|
1559 |
||
1560 |
// shift parameters by wave height |
|
1561 |
// ( ox and dy are used to create different horizontal and vertical offsets |
|
1562 |
// between wave layers ) |
|
1563 |
dY:= -cWaveHeight + dy; |
|
1564 |
ox:= -cWaveHeight + ox; |
|
1565 |
||
10494 | 1566 |
lx:= LongInt(LeftX) + WorldDx - ox; |
1567 |
rx:= LongInt(RightX) + WorldDx + ox; |
|
10330 | 1568 |
|
1569 |
topy:= cWaterLine + WorldDy + dY; |
|
1570 |
||
1571 |
||
1572 |
if (WorldEdge <> weSea) then |
|
1573 |
PrepareVbForWater(false, |
|
1574 |
topy, 0, |
|
1575 |
0, ViewLeftX, |
|
1576 |
0, ViewRightX, |
|
1577 |
topy + spriteHeight, |
|
1578 |
first, count) |
|
1579 |
else |
|
1580 |
PrepareVbForWater(true, |
|
1581 |
topy, ViewTopY, |
|
1582 |
lx, lx - spriteHeight, |
|
1583 |
rx, rx + spriteHeight, |
|
1584 |
topy + spriteHeight, |
|
1585 |
first, count); |
|
1586 |
||
1587 |
// quit if there's nothing to draw (nothing in view) |
|
1588 |
if count < 1 then |
|
1589 |
exit; |
|
1590 |
||
1591 |
if SuddenDeathDmg then |
|
1592 |
Tint(LongInt(tnt) * SDWaterColorArray[1].r div 255 + 255 - tnt, |
|
1593 |
LongInt(tnt) * SDWaterColorArray[1].g div 255 + 255 - tnt, |
|
1594 |
LongInt(tnt) * SDWaterColorArray[1].b div 255 + 255 - tnt, |
|
1595 |
255 |
|
1596 |
) |
|
1597 |
else |
|
1598 |
Tint(LongInt(tnt) * WaterColorArray[1].r div 255 + 255 - tnt, |
|
1599 |
LongInt(tnt) * WaterColorArray[1].g div 255 + 255 - tnt, |
|
1600 |
LongInt(tnt) * WaterColorArray[1].b div 255 + 255 - tnt, |
|
1601 |
255 |
|
1602 |
); |
|
1603 |
||
1604 |
if WorldEdge = weSea then |
|
1605 |
begin |
|
1606 |
lw:= playWidth; |
|
1607 |
dX:= ox; |
|
1608 |
end |
|
1609 |
else |
|
1610 |
begin |
|
1611 |
lw:= ViewWidth; |
|
1612 |
dx:= dx - WorldDx; |
|
1613 |
end; |
|
1614 |
||
1615 |
spriteWidth:= SpritesData[sprite].Width; |
|
1616 |
nWaves:= lw / spriteWidth; |
|
1617 |
shift:= - nWaves / 2; |
|
1618 |
||
1619 |
TextureBuffer[3].X:= shift + ((LongInt(RealTicks shr 6) * Dir + dX) mod spriteWidth) / (spriteWidth - 1); |
|
1620 |
TextureBuffer[3].Y:= 0; |
|
1621 |
TextureBuffer[5].X:= TextureBuffer[3].X + nWaves; |
|
1622 |
TextureBuffer[5].Y:= 0; |
|
1623 |
TextureBuffer[4].X:= TextureBuffer[5].X; |
|
1624 |
TextureBuffer[4].Y:= SpritesData[sprite].Texture^.ry; |
|
1625 |
TextureBuffer[2].X:= TextureBuffer[3].X; |
|
1626 |
TextureBuffer[2].Y:= SpritesData[sprite].Texture^.ry; |
|
1627 |
||
1628 |
if (WorldEdge = weSea) then |
|
1629 |
begin |
|
1630 |
nWaves:= (topy - ViewTopY) / spriteWidth; |
|
1631 |
||
1632 |
// left side |
|
1633 |
TextureBuffer[1].X:= TextureBuffer[3].X - nWaves; |
|
1634 |
TextureBuffer[1].Y:= 0; |
|
1635 |
TextureBuffer[0].X:= TextureBuffer[1].X; |
|
1636 |
TextureBuffer[0].Y:= SpritesData[sprite].Texture^.ry; |
|
1637 |
||
1638 |
// right side |
|
1639 |
TextureBuffer[7].X:= TextureBuffer[5].X + nWaves; |
|
1640 |
TextureBuffer[7].Y:= 0; |
|
1641 |
TextureBuffer[6].X:= TextureBuffer[7].X; |
|
1642 |
TextureBuffer[6].Y:= SpritesData[sprite].Texture^.ry; |
|
1643 |
end; |
|
1644 |
||
1645 |
glBindTexture(GL_TEXTURE_2D, SpritesData[sprite].Texture^.id); |
|
1646 |
||
1647 |
SetVertexPointer(@VertexBuffer[0], 8); |
|
1648 |
SetTexCoordPointer(@TextureBuffer[0], 8); |
|
1649 |
||
1650 |
UpdateModelviewProjection; |
|
1651 |
||
1652 |
glDrawArrays(GL_TRIANGLE_STRIP, first, count); |
|
1653 |
||
1654 |
untint; |
|
1655 |
||
1656 |
end; |
|
1657 |
||
10255
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
1658 |
procedure openglTint(r, g, b, a: Byte); inline; |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
1659 |
{$IFDEF GL2} |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
1660 |
const |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
1661 |
scale:Real = 1.0/255.0; |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
1662 |
{$ENDIF} |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
1663 |
begin |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
1664 |
{$IFDEF GL2} |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
1665 |
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
|
1666 |
{$ELSE} |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
1667 |
glColor4ub(r, g, b, a); |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
1668 |
{$ENDIF} |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
1669 |
end; |
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
1670 |
|
4378 | 1671 |
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
|
1672 |
var |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7069
diff
changeset
|
1673 |
nc, tw: Longword; |
4378 | 1674 |
begin |
9557 | 1675 |
nc:= (r shl 24) or (g shl 16) or (b shl 8) or a; |
5559 | 1676 |
|
10326 | 1677 |
if nc = LastTint then |
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
1678 |
exit; |
5559 | 1679 |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
1680 |
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
|
1681 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
1682 |
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
|
1683 |
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
|
1684 |
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
|
1685 |
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
|
1686 |
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
|
1687 |
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
|
1688 |
end; |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5235
diff
changeset
|
1689 |
|
10255
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
1690 |
openglTint(r, g, b, a); |
10326 | 1691 |
LastTint:= nc; |
4378 | 1692 |
end; |
1693 |
||
1694 |
procedure Tint(c: Longword); inline; |
|
1695 |
begin |
|
10326 | 1696 |
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
|
1697 |
Tint(((c shr 24) and $FF), ((c shr 16) and $FF), (c shr 8) and $FF, (c and $FF)) |
4378 | 1698 |
end; |
1699 |
||
9666
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
1700 |
procedure untint(); inline; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
1701 |
begin |
10326 | 1702 |
if cWhiteColor = LastTint then exit; |
10255
fdc342ebdc31
tweak untint a little (especially in connection with GrayScale)
sheepluva
parents:
10108
diff
changeset
|
1703 |
openglTint($FF, $FF, $FF, $FF); |
10326 | 1704 |
LastTint:= cWhiteColor; |
9666
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
1705 |
end; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
1706 |
|
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
1707 |
procedure setTintAdd(f: boolean); inline; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
1708 |
begin |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
1709 |
if f then |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
1710 |
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
|
1711 |
else |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
1712 |
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
|
1713 |
end; |
8dcb25112d96
- Bring back white dot in the center of crosshair. Crosshair is blurred now!
unc0rr
parents:
9557
diff
changeset
|
1714 |
|
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1715 |
procedure initModule; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1716 |
begin |
10326 | 1717 |
LastTint:= cWhiteColor + 1; |
1718 |
LastColorPointer := nil; |
|
1719 |
LastTexCoordPointer := nil; |
|
1720 |
LastVertexPointer := nil; |
|
1721 |
{$IFDEF GL2} |
|
1722 |
LastColorPointerN := 0; |
|
1723 |
LastTexCoordPointerN:= 0; |
|
1724 |
LastVertexPointerN := 0; |
|
1725 |
{$ENDIF} |
|
10304
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1726 |
end; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1727 |
|
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1728 |
procedure freeModule; |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1729 |
begin |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1730 |
{$IFDEF GL2} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1731 |
glDeleteProgram(shaderMain); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1732 |
glDeleteProgram(shaderWater); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1733 |
glDeleteBuffers(1, @vBuffer); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1734 |
glDeleteBuffers(1, @tBuffer); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1735 |
glDeleteBuffers(1, @cBuffer); |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1736 |
{$ENDIF} |
7e40820b7ed6
fix gl2 build, further rendering cleanup WIP, also new chat command: /debugvl
sheepluva
parents:
10302
diff
changeset
|
1737 |
end; |
4378 | 1738 |
end. |