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