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