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