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