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