author | koda |
Sun, 27 Jan 2013 00:28:57 +0100 | |
branch | webgl |
changeset 8444 | 75db7bb8dce8 |
parent 8336 | 4877d7333818 |
parent 8370 | 0c79946e96f8 |
child 8446 | c18ba8726f5a |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
6700 | 3 |
* Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 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 |
|
4 | 8 |
* |
183 | 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. |
|
4 | 13 |
* |
183 | 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 |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
4 | 17 |
*) |
18 |
||
2623 | 19 |
{$INCLUDE "options.inc"} |
4850 | 20 |
{$IF GLunit = GL}{$DEFINE GLunit:=GL,GLext}{$ENDIF} |
2623 | 21 |
|
4 | 22 |
unit uStore; |
23 |
interface |
|
7637
60b213e5ded3
use old approach for printing gl extentions for pas2c (less complex/no StrUtils dependencies)
sheepluva
parents:
7635
diff
changeset
|
24 |
uses {$IFNDEF PAS2C} StrUtils, {$ENDIF}SysUtils, uConsts, SDLh, GLunit, uTypes, uLandTexture, uCaptions, uChat; |
3692 | 25 |
|
3038 | 26 |
procedure initModule; |
27 |
procedure freeModule; |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2705
diff
changeset
|
28 |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
29 |
procedure StoreLoad(reload: boolean); |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6982
diff
changeset
|
30 |
procedure StoreRelease(reload: boolean); |
4 | 31 |
procedure RenderHealth(var Hedgehog: THedgehog); |
32 |
procedure AddProgress; |
|
510 | 33 |
procedure FinishProgress; |
2905 | 34 |
function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
35 |
|
8145
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
8138
diff
changeset
|
36 |
// loads an image from the games data files |
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
37 |
function LoadDataImage(const path: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
38 |
// like LoadDataImage but uses altPath as fallback-path if file not found/loadable in path |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
39 |
function LoadDataImageAltPath(const path, altPath: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
40 |
// like LoadDataImage but uses altFile as fallback-filename if file cannot be loaded |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
41 |
function LoadDataImageAltFile(const path: TPathType; const filename, altFile: shortstring; imageFlags: LongInt): PSDL_Surface; |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
42 |
|
7754 | 43 |
procedure LoadHedgehogHat(var HH: THedgehog; newHat: shortstring); |
753 | 44 |
procedure SetupOpenGL; |
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2154
diff
changeset
|
45 |
procedure SetScale(f: GLfloat); |
3394
47b51e22e670
Henek's patch - adds a column to ammoMenu and removes the F* column in iphone version
koda
parents:
3390
diff
changeset
|
46 |
function RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture; |
2747 | 47 |
procedure RenderWeaponTooltip(atype: TAmmoType); |
48 |
procedure ShowWeaponTooltip(x, y: LongInt); |
|
49 |
procedure FreeWeaponTooltip; |
|
4889
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
50 |
procedure MakeCrossHairs; |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
51 |
{$IFDEF USE_VIDEO_RECORDING} |
7180 | 52 |
procedure InitOffscreenOpenGL; |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
53 |
{$ENDIF} |
4 | 54 |
|
7049 | 55 |
procedure WarpMouse(x, y: Word); inline; |
7866
58d10edc5d21
apparently we are forced to use a (dummy) callback for glut 3.0 compatibility
koda
parents:
7754
diff
changeset
|
56 |
procedure SwapBuffers; {$IFDEF USE_VIDEO_RECORDING}cdecl{$ELSE}inline{$ENDIF}; |
7049 | 57 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
58 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
59 |
procedure UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
60 |
procedure EnableTexture(enable:Boolean); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
61 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
62 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
63 |
procedure SetTexCoordPointer(p: Pointer;n: Integer); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
64 |
procedure SetVertexPointer(p: Pointer;n: Integer); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
65 |
procedure SetColorPointer(p: Pointer;n: Integer); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
66 |
procedure BeginWater; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
67 |
procedure EndWater; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
68 |
|
4 | 69 |
implementation |
8204 | 70 |
uses uMisc, uConsole, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands |
8022 | 71 |
, uPhysFSLayer |
72 |
, uDebug |
|
73 |
{$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF} |
|
74 |
{$IF NOT DEFINED(SDL13) AND DEFINED(USE_VIDEO_RECORDING)}, glut {$ENDIF}; |
|
4 | 75 |
|
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
76 |
//type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple); |
2568
e654cbfb23ba
Bunch of neat stuff by Smaxx. ATI check, translucent name tags to reduce terrain fail, disabling health crates on invulnerable hogs. Also tweaks to prior stuff.
nemo
parents:
2567
diff
changeset
|
77 |
|
4385 | 78 |
var MaxTextureSize: LongInt; |
7049 | 79 |
{$IFDEF SDL13} |
80 |
SDLwindow: PSDL_Window; |
|
81 |
SDLGLcontext: PSDL_GLContext; |
|
82 |
{$ELSE} |
|
7028 | 83 |
SDLPrimSurface: PSDL_Surface; |
7049 | 84 |
{$ENDIF} |
8145
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
8138
diff
changeset
|
85 |
squaresize : LongInt; |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
8138
diff
changeset
|
86 |
numsquares : LongInt; |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
8138
diff
changeset
|
87 |
ProgrTex: PTexture; |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
8138
diff
changeset
|
88 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
89 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
90 |
shaderMain: GLuint; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
91 |
shaderWater: GLuint; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
92 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
93 |
// attributes |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
94 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
95 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
96 |
{$IFDEF WEBGL} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
97 |
OpenGLSetupedBefore : boolean; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
98 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
99 |
|
8330 | 100 |
const |
8145
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
8138
diff
changeset
|
101 |
cHHFileName = 'Hedgehog'; |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
8138
diff
changeset
|
102 |
cCHFileName = 'Crosshair'; |
4 | 103 |
|
2905 | 104 |
function WriteInRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect; |
2747 | 105 |
var w, h: LongInt; |
106 |
tmpsurf: PSDL_Surface; |
|
107 |
clr: TSDL_Color; |
|
108 |
finalRect: TSDL_Rect; |
|
109 |
begin |
|
3407 | 110 |
w:= 0; h:= 0; // avoid compiler hints |
6286
835392304f81
and while we are giving SDLh.pas all this love, let's fix the signature of one SDL_ttf calls
koda
parents:
6089
diff
changeset
|
111 |
TTF_SizeUTF8(Fontz[Font].Handle, Str2PChar(s), @w, @h); |
6982 | 112 |
finalRect.x:= X + cFontBorder + 2; |
113 |
finalRect.y:= Y + cFontBorder; |
|
114 |
finalRect.w:= w + cFontBorder * 2 + 4; |
|
115 |
finalRect.h:= h + cFontBorder * 2; |
|
2747 | 116 |
clr.r:= Color shr 16; |
117 |
clr.g:= (Color shr 8) and $FF; |
|
118 |
clr.b:= Color and $FF; |
|
119 |
tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(s), clr); |
|
120 |
tmpsurf:= doSurfaceConversion(tmpsurf); |
|
121 |
SDLTry(tmpsurf <> nil, true); |
|
122 |
SDL_UpperBlit(tmpsurf, nil, Surface, @finalRect); |
|
123 |
SDL_FreeSurface(tmpsurf); |
|
124 |
finalRect.x:= X; |
|
125 |
finalRect.y:= Y; |
|
6982 | 126 |
finalRect.w:= w + cFontBorder * 2 + 4; |
127 |
finalRect.h:= h + cFontBorder * 2; |
|
2747 | 128 |
WriteInRect:= finalRect |
129 |
end; |
|
130 |
||
4889
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
131 |
procedure MakeCrossHairs; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
132 |
var t: LongInt; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
133 |
tmpsurf, texsurf: PSDL_Surface; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
134 |
Color, i: Longword; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
135 |
begin |
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
136 |
tmpsurf:= LoadDataImage(ptGraphics, cCHFileName, ifAlpha or ifCritical); |
4889
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
137 |
|
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
138 |
for t:= 0 to Pred(TeamsCount) do |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
139 |
with TeamsArray[t]^ do |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
140 |
begin |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
141 |
texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, tmpsurf^.w, tmpsurf^.h, 32, RMask, GMask, BMask, AMask); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
142 |
TryDo(texsurf <> nil, errmsgCreateSurface, true); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
143 |
|
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
144 |
Color:= Clan^.Color; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
145 |
Color:= SDL_MapRGB(texsurf^.format, Color shr 16, Color shr 8, Color and $FF); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
146 |
SDL_FillRect(texsurf, nil, Color); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
147 |
|
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
148 |
SDL_UpperBlit(tmpsurf, nil, texsurf, nil); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
149 |
|
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
150 |
TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Ooops', true); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
151 |
|
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
152 |
if SDL_MustLock(texsurf) then |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
153 |
SDLTry(SDL_LockSurface(texsurf) >= 0, true); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
154 |
|
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
155 |
// make black pixel be alpha-transparent |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
156 |
for i:= 0 to texsurf^.w * texsurf^.h - 1 do |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
157 |
if PLongwordArray(texsurf^.pixels)^[i] = AMask then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
158 |
PLongwordArray(texsurf^.pixels)^[i]:= (RMask or GMask or BMask) and Color; |
4889
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
159 |
|
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
160 |
if SDL_MustLock(texsurf) then |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
161 |
SDL_UnlockSurface(texsurf); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
162 |
|
6380
1ff5ad1d771b
Remove a bunch of unnecessary nil checks. FreeTexture does its own nil check.
nemo
parents:
6379
diff
changeset
|
163 |
FreeTexture(CrosshairTex); |
4889
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
164 |
CrosshairTex:= Surface2Tex(texsurf, false); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
165 |
SDL_FreeSurface(texsurf) |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
166 |
end; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
167 |
|
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
168 |
SDL_FreeSurface(tmpsurf) |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
169 |
end; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4874
diff
changeset
|
170 |
|
4 | 171 |
|
6492 | 172 |
procedure WriteNames(Font: THWFont); |
173 |
var t: LongInt; |
|
7495 | 174 |
i, maxLevel: LongInt; |
6492 | 175 |
r, rr: TSDL_Rect; |
176 |
drY: LongInt; |
|
177 |
texsurf, flagsurf, iconsurf: PSDL_Surface; |
|
7495 | 178 |
foundBot: boolean; |
6492 | 179 |
begin |
8027
e5ba3dd12531
make stats-only mode work headless. also skip a few things to save time/memory.
nemo
parents:
7866
diff
changeset
|
180 |
if cOnlyStats then exit; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
181 |
r.x:= 0; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
182 |
r.y:= 0; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
183 |
drY:= - 4; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
184 |
for t:= 0 to Pred(TeamsCount) do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
185 |
with TeamsArray[t]^ do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
186 |
begin |
7013 | 187 |
NameTagTex:= RenderStringTexLim(TeamName, Clan^.Color, Font, cTeamHealthWidth); |
690 | 188 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
189 |
r.w:= cTeamHealthWidth + 5; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
190 |
r.h:= NameTagTex^.h; |
690 | 191 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
192 |
texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, RMask, GMask, BMask, AMask); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
193 |
TryDo(texsurf <> nil, errmsgCreateSurface, true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
194 |
TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
690 | 195 |
|
7546
b50556f2a0e8
This union hasn't been needed for 5 years, and makes using other headers harder.
nemo
parents:
7495
diff
changeset
|
196 |
DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
197 |
rr:= r; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
198 |
inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
199 |
DrawRoundRect(@rr, Clan^.Color, Clan^.Color, texsurf, false); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
200 |
HealthTex:= Surface2Tex(texsurf, false); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
201 |
SDL_FreeSurface(texsurf); |
690 | 202 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
203 |
r.x:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
204 |
r.y:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
205 |
r.w:= 32; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
206 |
r.h:= 32; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
207 |
texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, RMask, GMask, BMask, AMask); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
208 |
TryDo(texsurf <> nil, errmsgCreateSurface, true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
209 |
TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
2747 | 210 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
211 |
r.w:= 26; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
212 |
r.h:= 19; |
2747 | 213 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
214 |
DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true); |
3697 | 215 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
216 |
// overwrite flag for cpu teams and keep players from using it |
7495 | 217 |
foundBot:= false; |
218 |
maxLevel:= -1; |
|
219 |
for i:= 0 to cMaxHHIndex do |
|
220 |
with Hedgehogs[i] do |
|
221 |
if (Gear <> nil) and (BotLevel > 0) then |
|
222 |
begin |
|
223 |
foundBot:= true; |
|
224 |
// initially was going to do the highest botlevel of the team, but for now, just apply if entire team has same bot level |
|
225 |
if maxLevel = -1 then maxLevel:= BotLevel |
|
8330 | 226 |
else if (maxLevel > 0) and (maxLevel <> BotLevel) then maxLevel:= 0; |
7495 | 227 |
//if (maxLevel > 0) and (BotLevel < maxLevel) then maxLevel:= BotLevel |
228 |
end |
|
229 |
else if Gear <> nil then maxLevel:= 0; |
|
230 |
||
231 |
if foundBot then |
|
232 |
begin |
|
233 |
// disabled the plain flag - I think it looks ok even w/ full bars obscuring CPU |
|
8330 | 234 |
//if (maxLevel > 0) and (maxLevel < 3) then Flag:= 'cpu_plain' else |
7495 | 235 |
Flag:= 'cpu' |
236 |
end |
|
237 |
else if (Flag = 'cpu') or (Flag = 'cpu_plain') then |
|
238 |
Flag:= 'hedgewars'; |
|
3697 | 239 |
|
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
240 |
flagsurf:= LoadDataImageAltFile(ptFlags, Flag, 'hedgewars', ifNone); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
241 |
TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true); |
7495 | 242 |
|
243 |
case maxLevel of |
|
8330 | 244 |
1: copyToXY(SpritesData[sprBotlevels].Surface, flagsurf, 0, 0); |
245 |
2: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 5, 2, 17, 13, 5, 2); |
|
246 |
3: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 9, 5, 13, 10, 9, 5); |
|
247 |
4: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 13, 9, 9, 6, 13, 9); |
|
7495 | 248 |
5: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 17, 11, 5, 4, 17, 11) |
249 |
end; |
|
250 |
||
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
251 |
copyToXY(flagsurf, texsurf, 2, 2); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
252 |
SDL_FreeSurface(flagsurf); |
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3509
diff
changeset
|
253 |
flagsurf:= nil; |
3697 | 254 |
|
7495 | 255 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
256 |
// restore black border pixels inside the flag |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
257 |
PLongwordArray(texsurf^.pixels)^[32 * 2 + 2]:= cNearBlackColor; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
258 |
PLongwordArray(texsurf^.pixels)^[32 * 2 + 23]:= cNearBlackColor; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
259 |
PLongwordArray(texsurf^.pixels)^[32 * 16 + 2]:= cNearBlackColor; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
260 |
PLongwordArray(texsurf^.pixels)^[32 * 16 + 23]:= cNearBlackColor; |
2747 | 261 |
|
7495 | 262 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
263 |
FlagTex:= Surface2Tex(texsurf, false); |
3041 | 264 |
SDL_FreeSurface(texsurf); |
4874 | 265 |
texsurf:= nil; |
3041 | 266 |
|
3773 | 267 |
AIKillsTex := RenderStringTex(inttostr(stats.AIKills), Clan^.Color, fnt16); |
268 |
||
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
269 |
dec(drY, r.h + 2); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
270 |
DrawHealthY:= drY; |
7495 | 271 |
for i:= 0 to cMaxHHIndex do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
272 |
with Hedgehogs[i] do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
273 |
if Gear <> nil then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
274 |
begin |
7013 | 275 |
NameTagTex:= RenderStringTexLim(Name, Clan^.Color, fnt16, cTeamHealthWidth); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
276 |
if Hat <> 'NoHat' then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
277 |
begin |
2874
3c7c2bf1ba38
A simple hat reservation mechanism. Can be worked around with a little effort, but to make it useful, you'd have to get everyone you played with to work around it too. Quite a bit of effort for a small reward feature.
nemo
parents:
2873
diff
changeset
|
278 |
if (Length(Hat) > 39) and (Copy(Hat,1,8) = 'Reserved') and (Copy(Hat,9,32) = PlayerHash) then |
7754 | 279 |
LoadHedgehogHat(Hedgehogs[i], 'Reserved/' + Copy(Hat,9,Length(Hat)-8)) |
2874
3c7c2bf1ba38
A simple hat reservation mechanism. Can be worked around with a little effort, but to make it useful, you'd have to get everyone you played with to work around it too. Quite a bit of effort for a small reward feature.
nemo
parents:
2873
diff
changeset
|
280 |
else |
7754 | 281 |
LoadHedgehogHat(Hedgehogs[i], Hat); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
282 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
283 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
284 |
end; |
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
285 |
MissionIcons:= LoadDataImage(ptGraphics, 'missions', ifCritical); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
286 |
iconsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, 28, 28, 32, RMask, GMask, BMask, AMask); |
3862 | 287 |
if iconsurf <> nil then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
288 |
begin |
3862 | 289 |
r.x:= 0; |
290 |
r.y:= 0; |
|
291 |
r.w:= 28; |
|
292 |
r.h:= 28; |
|
293 |
DrawRoundRect(@r, cWhiteColor, cNearBlackColor, iconsurf, true); |
|
294 |
ropeIconTex:= Surface2Tex(iconsurf, false); |
|
295 |
SDL_FreeSurface(iconsurf); |
|
296 |
iconsurf:= nil; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
297 |
end; |
6492 | 298 |
end; |
4 | 299 |
|
6492 | 300 |
procedure InitHealth; |
301 |
var i, t: LongInt; |
|
302 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
303 |
for t:= 0 to Pred(TeamsCount) do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
304 |
if TeamsArray[t] <> nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
305 |
with TeamsArray[t]^ do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
306 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
307 |
for i:= 0 to cMaxHHIndex do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
308 |
if Hedgehogs[i].Gear <> nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
309 |
RenderHealth(Hedgehogs[i]); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
310 |
end |
6492 | 311 |
end; |
4 | 312 |
|
6492 | 313 |
procedure LoadGraves; |
314 |
var t: LongInt; |
|
315 |
texsurf: PSDL_Surface; |
|
316 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
317 |
for t:= 0 to Pred(TeamsCount) do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
318 |
if TeamsArray[t] <> nil then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
319 |
with TeamsArray[t]^ do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
320 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
321 |
if GraveName = '' then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
322 |
GraveName:= 'Statue'; |
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
323 |
texsurf:= LoadDataImageAltFile(ptGraves, GraveName, 'Statue', ifCritical or ifTransparent); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
324 |
GraveTex:= Surface2Tex(texsurf, false); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
325 |
SDL_FreeSurface(texsurf) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
326 |
end |
6492 | 327 |
end; |
4 | 328 |
|
6492 | 329 |
procedure StoreLoad(reload: boolean); |
330 |
var s: shortstring; |
|
331 |
ii: TSprite; |
|
844 | 332 |
fi: THWFont; |
333 |
ai: TAmmoType; |
|
334 |
tmpsurf: PSDL_Surface; |
|
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
335 |
i, imflags: LongInt; |
4 | 336 |
begin |
5712 | 337 |
AddFileLog('StoreLoad()'); |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
338 |
WriteLnToConsole('Entering StoreLoad'); |
5714 | 339 |
if not reload then |
340 |
for fi:= Low(THWFont) to High(THWFont) do |
|
341 |
with Fontz[fi] do |
|
342 |
begin |
|
8025 | 343 |
s:= cPathz[ptFonts] + '/' + Name; |
5714 | 344 |
WriteToConsole(msgLoading + s + ' (' + inttostr(Height) + 'pt)... '); |
8028 | 345 |
Handle:= TTF_OpenFontRW(rwopsOpenRead(s), true, Height); |
5714 | 346 |
SDLTry(Handle <> nil, true); |
347 |
TTF_SetFontStyle(Handle, style); |
|
348 |
WriteLnToConsole(msgOK) |
|
349 |
end; |
|
53 | 350 |
|
70 | 351 |
MakeCrossHairs; |
4 | 352 |
LoadGraves; |
6394
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
353 |
if not reload then |
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
354 |
AddProgress; |
4 | 355 |
|
356 |
for ii:= Low(TSprite) to High(TSprite) do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
357 |
with SpritesData[ii] do |
5215
d4c529624460
Try and avoid problem reported by users like RDChrisco with cards that only support 512 texture size, and disable backgrounds. Also, reorganise the rq flags sprite loading a bit. Needs testing to make sure it matches the sprite uses. It should though.
nemo
parents:
5187
diff
changeset
|
358 |
// FIXME - add a sprite attribute to match on rq flags? |
d4c529624460
Try and avoid problem reported by users like RDChrisco with cards that only support 512 texture size, and disable backgrounds. Also, reorganise the rq flags sprite loading a bit. Needs testing to make sure it matches the sprite uses. It should though.
nemo
parents:
5187
diff
changeset
|
359 |
if (((cReducedQuality and (rqNoBackground or rqLowRes)) = 0) or // why rqLowRes? |
d4c529624460
Try and avoid problem reported by users like RDChrisco with cards that only support 512 texture size, and disable backgrounds. Also, reorganise the rq flags sprite loading a bit. Needs testing to make sure it matches the sprite uses. It should though.
nemo
parents:
5187
diff
changeset
|
360 |
(not (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR]))) and |
d4c529624460
Try and avoid problem reported by users like RDChrisco with cards that only support 512 texture size, and disable backgrounds. Also, reorganise the rq flags sprite loading a bit. Needs testing to make sure it matches the sprite uses. It should though.
nemo
parents:
5187
diff
changeset
|
361 |
(((cReducedQuality and rqPlainSplash) = 0) or ((not (ii in [sprSplash, sprDroplet, sprSDSplash, sprSDDroplet])))) and |
5285
af4dc03dd60d
Make sky, horizon, flakes and clouds optional, replace repeated strips of skyL/skyR with 2x2 transparent PNGs instead of larger images of variable dimensions, remove a number of empty unused images
nemo
parents:
5284
diff
changeset
|
362 |
(((cReducedQuality and rqKillFlakes) = 0) or (Theme = 'Snow') or (Theme = 'Christmas') or ((not (ii in [sprFlake, sprSDFlake])))) and |
af4dc03dd60d
Make sky, horizon, flakes and clouds optional, replace repeated strips of skyL/skyR with 2x2 transparent PNGs instead of larger images of variable dimensions, remove a number of empty unused images
nemo
parents:
5284
diff
changeset
|
363 |
((cCloudsNumber > 0) or (ii <> sprCloud)) and |
af4dc03dd60d
Make sky, horizon, flakes and clouds optional, replace repeated strips of skyL/skyR with 2x2 transparent PNGs instead of larger images of variable dimensions, remove a number of empty unused images
nemo
parents:
5284
diff
changeset
|
364 |
((vobCount > 0) or (ii <> sprFlake)) then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
365 |
begin |
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
366 |
if reload then |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
367 |
tmpsurf:= Surface |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
368 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
369 |
begin |
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
370 |
imflags := (ifAlpha or ifTransparent); |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
371 |
|
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
372 |
// these sprites are optional |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
373 |
if not (ii in [sprHorizont, sprHorizontL, sprHorizontR, sprSky, sprSkyL, sprSkyR, sprChunk]) then // FIXME: hack |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
374 |
imflags := (imflags or ifCritical); |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
375 |
|
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
376 |
// load the image |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
377 |
tmpsurf := LoadDataImageAltPath(Path, AltPath, FileName, imflags) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
378 |
end; |
2426 | 379 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
380 |
if tmpsurf <> nil then |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
381 |
begin |
3558 | 382 |
if getImageDimensions then |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
383 |
begin |
3558 | 384 |
imageWidth:= tmpsurf^.w; |
385 |
imageHeight:= tmpsurf^.h |
|
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
386 |
end; |
3558 | 387 |
if getDimensions then |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
388 |
begin |
3558 | 389 |
Width:= tmpsurf^.w; |
390 |
Height:= tmpsurf^.h |
|
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
391 |
end; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
392 |
if (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR]) then |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
393 |
begin |
3537
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3525
diff
changeset
|
394 |
Texture:= Surface2Tex(tmpsurf, true); |
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3525
diff
changeset
|
395 |
Texture^.Scale:= 2 |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
396 |
end |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
397 |
else |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
398 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
399 |
Texture:= Surface2Tex(tmpsurf, false); |
4809
9c7d5f802618
rearrange quality flags a little, disable snow rendering on rqLowRes
koda
parents:
4782
diff
changeset
|
400 |
// HACK: We should include some sprite attribute to define the texture wrap directions |
9c7d5f802618
rearrange quality flags a little, disable snow rendering on rqLowRes
koda
parents:
4782
diff
changeset
|
401 |
if ((ii = sprWater) or (ii = sprSDWater)) and ((cReducedQuality and (rq2DWater or rqClampLess)) = 0) then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
402 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
403 |
end; |
3491 | 404 |
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, priority); |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
405 |
// This should maybe be flagged. It wastes quite a bit of memory. |
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
406 |
if not reload then |
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
407 |
begin |
6674 | 408 |
{$IFDEF USE_CONTEXT_RESTORE} |
8330 | 409 |
Surface:= tmpsurf |
5714 | 410 |
{$ELSE} |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
411 |
if saveSurf then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
412 |
Surface:= tmpsurf |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
413 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
414 |
SDL_FreeSurface(tmpsurf) |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
415 |
{$ENDIF} |
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
416 |
end |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
417 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
418 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
419 |
Surface:= nil |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
420 |
end; |
80 | 421 |
|
7495 | 422 |
WriteNames(fnt16); |
423 |
||
6394
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
424 |
if not reload then |
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
425 |
AddProgress; |
567 | 426 |
|
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
427 |
tmpsurf:= LoadDataImage(ptGraphics, cHHFileName, ifAlpha or ifCritical or ifTransparent); |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
428 |
|
2290
bf87ca44782e
Selectively enable clamping - seeing if this helps avoid weird flake problems while still fixing vertical lines in waves and sky
nemo
parents:
2285
diff
changeset
|
429 |
HHTexture:= Surface2Tex(tmpsurf, false); |
761 | 430 |
SDL_FreeSurface(tmpsurf); |
4 | 431 |
|
432 |
InitHealth; |
|
433 |
||
2623 | 434 |
PauseTexture:= RenderStringTex(trmsg[sidPaused], cYellowColor, fntBig); |
435 |
ConfirmTexture:= RenderStringTex(trmsg[sidConfirm], cYellowColor, fntBig); |
|
436 |
SyncTexture:= RenderStringTex(trmsg[sidSync], cYellowColor, fntBig); |
|
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
208
diff
changeset
|
437 |
|
6394
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
438 |
if not reload then |
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
439 |
AddProgress; |
2601 | 440 |
|
2670 | 441 |
// name of weapons in ammo menu |
843 | 442 |
for ai:= Low(TAmmoType) to High(TAmmoType) do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
443 |
with Ammoz[ai] do |
6380
1ff5ad1d771b
Remove a bunch of unnecessary nil checks. FreeTexture does its own nil check.
nemo
parents:
6379
diff
changeset
|
444 |
begin |
3384 | 445 |
TryDo(trAmmo[NameId] <> '','No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
446 |
tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, Str2PChar(trAmmo[NameId]), cWhiteColorChannels); |
3384 | 447 |
TryDo(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
448 |
tmpsurf:= doSurfaceConversion(tmpsurf); |
6380
1ff5ad1d771b
Remove a bunch of unnecessary nil checks. FreeTexture does its own nil check.
nemo
parents:
6379
diff
changeset
|
449 |
FreeTexture(NameTex); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
450 |
NameTex:= Surface2Tex(tmpsurf, false); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
451 |
SDL_FreeSurface(tmpsurf) |
6380
1ff5ad1d771b
Remove a bunch of unnecessary nil checks. FreeTexture does its own nil check.
nemo
parents:
6379
diff
changeset
|
452 |
end; |
2376 | 453 |
|
2670 | 454 |
// number of weapons in ammo menu |
844 | 455 |
for i:= Low(CountTexz) to High(CountTexz) do |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
456 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
457 |
tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColorChannels); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
458 |
tmpsurf:= doSurfaceConversion(tmpsurf); |
6380
1ff5ad1d771b
Remove a bunch of unnecessary nil checks. FreeTexture does its own nil check.
nemo
parents:
6379
diff
changeset
|
459 |
FreeTexture(CountTexz[i]); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
460 |
CountTexz[i]:= Surface2Tex(tmpsurf, false); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
461 |
SDL_FreeSurface(tmpsurf) |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
462 |
end; |
844 | 463 |
|
6394
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
464 |
if not reload then |
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
465 |
AddProgress; |
2669 | 466 |
IMG_Quit(); |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
467 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
468 |
WriteLnToConsole('Leaving StoreLoad'); |
4 | 469 |
end; |
470 |
||
8138
cfb228baa598
Invert S3D_DISABLED to more consistent USE_S3D_RENDERING
Chris Wong <lambda.fairy@gmail.com>
parents:
8057
diff
changeset
|
471 |
{$IF DEFINED(USE_S3D_RENDERING) OR DEFINED(USE_VIDEO_RECORDING)} |
7180 | 472 |
procedure CreateFramebuffer(var frame, depth, tex: GLuint); |
473 |
begin |
|
474 |
glGenFramebuffersEXT(1, @frame); |
|
475 |
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frame); |
|
476 |
glGenRenderbuffersEXT(1, @depth); |
|
477 |
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth); |
|
478 |
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, cScreenWidth, cScreenHeight); |
|
479 |
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth); |
|
480 |
glGenTextures(1, @tex); |
|
481 |
glBindTexture(GL_TEXTURE_2D, tex); |
|
482 |
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, cScreenWidth, cScreenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil); |
|
483 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
|
484 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
|
485 |
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0); |
|
486 |
end; |
|
487 |
||
488 |
procedure DeleteFramebuffer(var frame, depth, tex: GLuint); |
|
489 |
begin |
|
490 |
glDeleteTextures(1, @tex); |
|
491 |
glDeleteRenderbuffersEXT(1, @depth); |
|
492 |
glDeleteFramebuffersEXT(1, @frame); |
|
493 |
end; |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
494 |
{$ENDIF} |
7180 | 495 |
|
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
496 |
procedure StoreRelease(reload: boolean); |
4 | 497 |
var ii: TSprite; |
4901 | 498 |
ai: TAmmoType; |
499 |
i, t: LongInt; |
|
4 | 500 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
501 |
for ii:= Low(TSprite) to High(TSprite) do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
502 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
503 |
FreeTexture(SpritesData[ii].Texture); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
504 |
SpritesData[ii].Texture:= nil; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
505 |
if (SpritesData[ii].Surface <> nil) and (not reload) then |
5562 | 506 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
507 |
SDL_FreeSurface(SpritesData[ii].Surface); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
508 |
SpritesData[ii].Surface:= nil |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
509 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
510 |
end; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
511 |
SDL_FreeSurface(MissionIcons); |
6394
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
512 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
513 |
// free the textures declared in uVariables |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
514 |
FreeTexture(WeaponTooltipTex); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
515 |
WeaponTooltipTex:= nil; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
516 |
FreeTexture(PauseTexture); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
517 |
PauseTexture:= nil; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
518 |
FreeTexture(SyncTexture); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
519 |
SyncTexture:= nil; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
520 |
FreeTexture(ConfirmTexture); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
521 |
ConfirmTexture:= nil; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
522 |
FreeTexture(ropeIconTex); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
523 |
ropeIconTex:= nil; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
524 |
FreeTexture(HHTexture); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
525 |
HHTexture:= nil; |
6394
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
526 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
527 |
// free all ammo name textures |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
528 |
for ai:= Low(TAmmoType) to High(TAmmoType) do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
529 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
530 |
FreeTexture(Ammoz[ai].NameTex); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
531 |
Ammoz[ai].NameTex:= nil |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
532 |
end; |
5562 | 533 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
534 |
// free all count textures |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
535 |
for i:= Low(CountTexz) to High(CountTexz) do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
536 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
537 |
FreeTexture(CountTexz[i]); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
538 |
CountTexz[i]:= nil |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
539 |
end; |
5562 | 540 |
|
4901 | 541 |
// free all team and hedgehog textures |
542 |
for t:= 0 to Pred(TeamsCount) do |
|
6380
1ff5ad1d771b
Remove a bunch of unnecessary nil checks. FreeTexture does its own nil check.
nemo
parents:
6379
diff
changeset
|
543 |
begin |
4901 | 544 |
if TeamsArray[t] <> nil then |
6380
1ff5ad1d771b
Remove a bunch of unnecessary nil checks. FreeTexture does its own nil check.
nemo
parents:
6379
diff
changeset
|
545 |
begin |
4901 | 546 |
FreeTexture(TeamsArray[t]^.NameTagTex); |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
547 |
TeamsArray[t]^.NameTagTex:= nil; |
4901 | 548 |
FreeTexture(TeamsArray[t]^.CrosshairTex); |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
549 |
TeamsArray[t]^.CrosshairTex:= nil; |
4901 | 550 |
FreeTexture(TeamsArray[t]^.GraveTex); |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
551 |
TeamsArray[t]^.GraveTex:= nil; |
4901 | 552 |
FreeTexture(TeamsArray[t]^.HealthTex); |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
553 |
TeamsArray[t]^.HealthTex:= nil; |
4901 | 554 |
FreeTexture(TeamsArray[t]^.AIKillsTex); |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
555 |
TeamsArray[t]^.AIKillsTex:= nil; |
4901 | 556 |
FreeTexture(TeamsArray[t]^.FlagTex); |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
557 |
TeamsArray[t]^.FlagTex:= nil; |
4901 | 558 |
for i:= 0 to cMaxHHIndex do |
6380
1ff5ad1d771b
Remove a bunch of unnecessary nil checks. FreeTexture does its own nil check.
nemo
parents:
6379
diff
changeset
|
559 |
begin |
4901 | 560 |
FreeTexture(TeamsArray[t]^.Hedgehogs[i].NameTagTex); |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
561 |
TeamsArray[t]^.Hedgehogs[i].NameTagTex:= nil; |
4901 | 562 |
FreeTexture(TeamsArray[t]^.Hedgehogs[i].HealthTagTex); |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
563 |
TeamsArray[t]^.Hedgehogs[i].HealthTagTex:= nil; |
4901 | 564 |
FreeTexture(TeamsArray[t]^.Hedgehogs[i].HatTex); |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
565 |
TeamsArray[t]^.Hedgehogs[i].HatTex:= nil; |
6380
1ff5ad1d771b
Remove a bunch of unnecessary nil checks. FreeTexture does its own nil check.
nemo
parents:
6379
diff
changeset
|
566 |
end; |
4901 | 567 |
end; |
568 |
end; |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
569 |
{$IFDEF USE_VIDEO_RECORDING} |
7180 | 570 |
if defaultFrame <> 0 then |
571 |
DeleteFramebuffer(defaultFrame, depthv, texv); |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
572 |
{$ENDIF} |
8138
cfb228baa598
Invert S3D_DISABLED to more consistent USE_S3D_RENDERING
Chris Wong <lambda.fairy@gmail.com>
parents:
8057
diff
changeset
|
573 |
{$IFDEF USE_S3D_RENDERING} |
8359
9a7024b2a4d3
Removed wiggle 3D mode, reorder the list of 3D modes.
martin_bede
parents:
8354
diff
changeset
|
574 |
if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) then |
6380
1ff5ad1d771b
Remove a bunch of unnecessary nil checks. FreeTexture does its own nil check.
nemo
parents:
6379
diff
changeset
|
575 |
begin |
7180 | 576 |
DeleteFramebuffer(framel, depthl, texl); |
577 |
DeleteFramebuffer(framer, depthr, texr); |
|
6380
1ff5ad1d771b
Remove a bunch of unnecessary nil checks. FreeTexture does its own nil check.
nemo
parents:
6379
diff
changeset
|
578 |
end |
4347
0ddb100fea61
add a S3D_DISABLED symbol to disable/enable stereo rendering at compilation time
koda
parents:
4343
diff
changeset
|
579 |
{$ENDIF} |
4 | 580 |
end; |
581 |
||
2677
83ad68ceef72
Non-hacked version of CJK handling. Should switch to CJK rendering only if a particular string needs it, instead of based on locale file.
nemo
parents:
2674
diff
changeset
|
582 |
|
4 | 583 |
procedure RenderHealth(var Hedgehog: THedgehog); |
95 | 584 |
var s: shortstring; |
4 | 585 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
586 |
str(Hedgehog.Gear^.Health, s); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
587 |
FreeTexture(Hedgehog.HealthTagTex); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
588 |
Hedgehog.HealthTagTex:= RenderStringTex(s, Hedgehog.Team^.Clan^.Color, fnt16) |
4 | 589 |
end; |
590 |
||
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
591 |
function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
30 | 592 |
var tmpsurf: PSDL_Surface; |
355 | 593 |
s: shortstring; |
4 | 594 |
begin |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
595 |
LoadImage:= nil; |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
596 |
WriteToConsole(msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + '] '); |
2426 | 597 |
|
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
598 |
s:= filename + '.png'; |
8025 | 599 |
tmpsurf:= IMG_Load_RW(rwopsOpenRead(s), true); |
2254 | 600 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
601 |
if tmpsurf = nil then |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
602 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
603 |
OutError(msgFailed, (imageFlags and ifCritical) <> 0); |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
604 |
exit; |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
605 |
end; |
2153 | 606 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
607 |
if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
608 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
609 |
SDL_FreeSurface(tmpsurf); |
8039
a3b86c1f63b4
another tweak tomake --stats-only work on headless servers
Xeli
parents:
8027
diff
changeset
|
610 |
OutError(msgFailedSize, ((not cOnlyStats) and ((imageFlags and ifCritical) <> 0))); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
611 |
// dummy surface to replace non-critical textures that failed to load due to their size |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
612 |
LoadImage:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask); |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
613 |
exit; |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
614 |
end; |
351 | 615 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
616 |
tmpsurf:= doSurfaceConversion(tmpsurf); |
2630 | 617 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
618 |
if (imageFlags and ifTransparent) <> 0 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
619 |
TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
2630 | 620 |
|
3407 | 621 |
WriteLnToConsole(msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')'); |
2630 | 622 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
623 |
LoadImage:= tmpsurf //Result |
753 | 624 |
end; |
625 |
||
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
626 |
|
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
627 |
function LoadDataImage(const path: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
628 |
var tmpsurf: PSDL_Surface; |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
629 |
begin |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
630 |
// check for file in user dir (never critical) |
8022 | 631 |
tmpsurf:= LoadImage(cPathz[path] + '/' + filename, imageFlags); |
8370 | 632 |
|
633 |
LoadDataImage:= tmpsurf; |
|
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
634 |
end; |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
635 |
|
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
636 |
|
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
637 |
function LoadDataImageAltPath(const path, altPath: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
638 |
var tmpsurf: PSDL_Surface; |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
639 |
begin |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
640 |
// if there is no alternative path, just forward and return result |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
641 |
if (altPath = ptNone) then |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
642 |
exit(LoadDataImage(path, filename, imageFlags)); |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
643 |
|
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
644 |
// since we have a fallback path this search isn't critical yet |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
645 |
tmpsurf:= LoadDataImage(path, filename, imageFlags and (not ifCritical)); |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
646 |
|
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
647 |
// if image still not found try alternative path |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
648 |
if (tmpsurf = nil) then |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
649 |
tmpsurf:= LoadDataImage(altPath, filename, imageFlags); |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
650 |
|
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
651 |
LoadDataImageAltPath:= tmpsurf; |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
652 |
end; |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
653 |
|
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
654 |
function LoadDataImageAltFile(const path: TPathType; const filename, altFile: shortstring; imageFlags: LongInt): PSDL_Surface; |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
655 |
var tmpsurf: PSDL_Surface; |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
656 |
begin |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
657 |
// if there is no alternative filename, just forward and return result |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
658 |
if (altFile = '') then |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
659 |
exit(LoadDataImage(path, filename, imageFlags)); |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
660 |
|
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
661 |
// since we have a fallback filename this search isn't critical yet |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
662 |
tmpsurf:= LoadDataImage(path, filename, imageFlags and (not ifCritical)); |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
663 |
|
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
664 |
// if image still not found try alternative filename |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
665 |
if (tmpsurf = nil) then |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
666 |
tmpsurf:= LoadDataImage(path, altFile, imageFlags); |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
667 |
|
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
668 |
LoadDataImageAltFile:= tmpsurf; |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
669 |
end; |
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
670 |
|
7754 | 671 |
procedure LoadHedgehogHat(var HH: THedgehog; newHat: shortstring); |
4874 | 672 |
var texsurf: PSDL_Surface; |
673 |
begin |
|
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
674 |
texsurf:= LoadDataImage(ptHats, newHat, ifNone); |
7754 | 675 |
AddFileLog('Hat => '+newHat); |
4874 | 676 |
// only do something if the hat could be loaded |
677 |
if texsurf <> nil then |
|
678 |
begin |
|
7754 | 679 |
AddFileLog('Got Hat'); |
4874 | 680 |
// free the mem of any previously assigned texture |
7754 | 681 |
FreeTexture(HH.HatTex); |
4874 | 682 |
|
683 |
// assign new hat to hedgehog |
|
7754 | 684 |
HH.HatTex:= Surface2Tex(texsurf, true); |
4874 | 685 |
|
686 |
// cleanup: free temporary surface mem |
|
687 |
SDL_FreeSurface(texsurf) |
|
688 |
end; |
|
689 |
end; |
|
690 |
||
2905 | 691 |
function glLoadExtension(extension : shortstring) : boolean; |
2428 | 692 |
begin |
8032 | 693 |
//TODO: pas2c doesn't handle {$IF (GLunit = gles11) OR DEFINED(PAS2C)} |
694 |
{$IFNDEF PAS2C} |
|
4850 | 695 |
{$IF GLunit = gles11} |
4900 | 696 |
// FreePascal doesnt come with OpenGL ES 1.1 Extension headers |
3971 | 697 |
extension:= extension; // avoid hint |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
698 |
glLoadExtension:= false; |
3333 | 699 |
AddFileLog('OpenGL - "' + extension + '" skipped') |
2580
aeccc8f51d3f
completes touch input/control (problems with moving camera)
koda
parents:
2578
diff
changeset
|
700 |
{$ELSE} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
701 |
glLoadExtension:= glext_LoadExtension(extension); |
4347
0ddb100fea61
add a S3D_DISABLED symbol to disable/enable stereo rendering at compilation time
koda
parents:
4343
diff
changeset
|
702 |
if glLoadExtension then |
0ddb100fea61
add a S3D_DISABLED symbol to disable/enable stereo rendering at compilation time
koda
parents:
4343
diff
changeset
|
703 |
AddFileLog('OpenGL - "' + extension + '" loaded') |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
704 |
else |
4347
0ddb100fea61
add a S3D_DISABLED symbol to disable/enable stereo rendering at compilation time
koda
parents:
4343
diff
changeset
|
705 |
AddFileLog('OpenGL - "' + extension + '" failed to load'); |
2568
e654cbfb23ba
Bunch of neat stuff by Smaxx. ATI check, translucent name tags to reduce terrain fail, disabling health crates on invulnerable hogs. Also tweaks to prior stuff.
nemo
parents:
2567
diff
changeset
|
706 |
{$ENDIF} |
8032 | 707 |
{$ENDIF} |
2428 | 708 |
end; |
709 |
||
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
710 |
procedure SetupOpenGLAttributes; |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
711 |
begin |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
712 |
{$IFDEF IPHONEOS} |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
713 |
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0); |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
714 |
SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
715 |
{$ELSE} |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
716 |
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
717 |
{$IFNDEF SDL13} // vsync is default in 1.3 |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
718 |
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, LongInt((cReducedQuality and rqDesyncVBlank) = 0)); |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
719 |
{$ENDIF} |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
720 |
{$ENDIF} |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
721 |
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); // no depth buffer |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
722 |
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
723 |
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6); |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
724 |
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
725 |
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); // no alpha channel required |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
726 |
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 16); // buffer has to be 16 bit only |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
727 |
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); // try to prefer hardware rendering |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
728 |
end; |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
729 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
730 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
731 |
function CompileShader(shaderFile: string; shaderType: GLenum): GLuint; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
732 |
var |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
733 |
shader: GLuint; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
734 |
f: Textfile; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
735 |
source, line: AnsiString; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
736 |
sourceA: Pchar; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
737 |
lengthA: GLint; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
738 |
compileResult: GLint; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
739 |
logLength: GLint; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
740 |
log: PChar; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
741 |
begin |
8336
4877d7333818
uStore.pas: Correctly point to shaders
Michael Hartman <omh1280@gmail.com>
parents:
8330
diff
changeset
|
742 |
Assign(f, PathPrefix + cPathz[ptShaders] + '/' + shaderFile); |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
743 |
filemode:= 0; // readonly |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
744 |
Reset(f); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
745 |
if IOResult <> 0 then |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
746 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
747 |
AddFileLog('Unable to load ' + shaderFile); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
748 |
halt(-1); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
749 |
end; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
750 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
751 |
source:=''; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
752 |
while not eof(f) do |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
753 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
754 |
ReadLn(f, line); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
755 |
source:= source + line + #10; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
756 |
end; |
8330 | 757 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
758 |
Close(f); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
759 |
|
8336
4877d7333818
uStore.pas: Correctly point to shaders
Michael Hartman <omh1280@gmail.com>
parents:
8330
diff
changeset
|
760 |
WriteLnToConsole('Compiling shader: ' + PathPrefix + cPathz[ptShaders] + '/' + shaderFile); |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
761 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
762 |
sourceA:=PChar(source); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
763 |
lengthA:=Length(source); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
764 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
765 |
shader:=glCreateShader(shaderType); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
766 |
glShaderSource(shader, 1, @sourceA, @lengthA); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
767 |
glCompileShader(shader); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
768 |
glGetShaderiv(shader, GL_COMPILE_STATUS, @compileResult); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
769 |
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, @logLength); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
770 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
771 |
if logLength > 1 then |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
772 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
773 |
log := GetMem(logLength); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
774 |
glGetShaderInfoLog(shader, logLength, nil, log); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
775 |
WriteLnToConsole('========== Compiler log =========='); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
776 |
WriteLnToConsole(shortstring(log)); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
777 |
WriteLnToConsole('==================================='); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
778 |
FreeMem(log, logLength); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
779 |
end; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
780 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
781 |
if compileResult <> GL_TRUE then |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
782 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
783 |
WriteLnToConsole('Shader compilation failed, halting'); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
784 |
halt(-1); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
785 |
end; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
786 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
787 |
CompileShader:= shader; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
788 |
end; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
789 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
790 |
function CompileProgram(shaderName: string): GLuint; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
791 |
var |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
792 |
program_: GLuint; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
793 |
vs, fs: GLuint; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
794 |
linkResult: GLint; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
795 |
logLength: GLint; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
796 |
log: PChar; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
797 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
798 |
program_:= glCreateProgram(); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
799 |
vs:= CompileShader(shaderName + '.vs', GL_VERTEX_SHADER); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
800 |
fs:= CompileShader(shaderName + '.fs', GL_FRAGMENT_SHADER); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
801 |
glAttachShader(program_, vs); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
802 |
glAttachShader(program_, fs); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
803 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
804 |
glBindAttribLocation(program_, aVertex, PChar('vertex')); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
805 |
glBindAttribLocation(program_, aTexCoord, PChar('texcoord')); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
806 |
glBindAttribLocation(program_, aColor, PChar('color')); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
807 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
808 |
glLinkProgram(program_); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
809 |
glDeleteShader(vs); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
810 |
glDeleteShader(fs); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
811 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
812 |
glGetProgramiv(program_, GL_LINK_STATUS, @linkResult); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
813 |
glGetProgramiv(program_, GL_INFO_LOG_LENGTH, @logLength); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
814 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
815 |
if logLength > 1 then |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
816 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
817 |
log := GetMem(logLength); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
818 |
glGetProgramInfoLog(program_, logLength, nil, log); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
819 |
WriteLnToConsole('========== Compiler log =========='); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
820 |
WriteLnToConsole(shortstring(log)); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
821 |
WriteLnToConsole('==================================='); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
822 |
FreeMem(log, logLength); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
823 |
end; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
824 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
825 |
if linkResult <> GL_TRUE then |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
826 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
827 |
WriteLnToConsole('Linking program failed, halting'); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
828 |
halt(-1); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
829 |
end; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
830 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
831 |
CompileProgram:= program_; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
832 |
end; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
833 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
834 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
835 |
|
753 | 836 |
procedure SetupOpenGL; |
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
837 |
//var vendor: shortstring = ''; |
6021 | 838 |
var buf: array[byte] of char; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
839 |
{$IFDEF PAS2C}err: GLenum;{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
840 |
{$IFDEF USE_VIDEO_RECORDING}AuxBufNum: LongInt;{$ENDIF} |
7634
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
841 |
tmpstr: AnsiString; |
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
842 |
tmpint: LongInt; |
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
843 |
tmpn: LongInt; |
5505
a55aab592950
Ditch the renderer system in sdl1.3 and use the 'old fashioned' sdl/opengl context. This gives us more flexibility and less problem in receiving video events (expecially on mobile platform) as well as not having to care to reset the gl context every time sdl interferes.
koda
parents:
5285
diff
changeset
|
844 |
begin |
6021 | 845 |
buf[0]:= char(0); // avoid compiler hint |
846 |
AddFileLog('Setting up OpenGL (using driver: ' + shortstring(SDL_VideoDriverName(buf, sizeof(buf))) + ')'); |
|
847 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
848 |
{$IFDEF WEBGL} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
849 |
if OpenGLSetupedBefore then |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
850 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
851 |
glViewport(0, 0, cScreenWidth, cScreenHeight); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
852 |
hglMatrixMode(MATRIX_MODELVIEW); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
853 |
hglLoadIdentity(); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
854 |
hglScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
855 |
hglTranslatef(0, -cScreenHeight / 2, 0); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
856 |
exit; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
857 |
end |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
858 |
OpenGLSetupedBefore := true; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
859 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
860 |
|
5505
a55aab592950
Ditch the renderer system in sdl1.3 and use the 'old fashioned' sdl/opengl context. This gives us more flexibility and less problem in receiving video events (expecially on mobile platform) as well as not having to care to reset the gl context every time sdl interferes.
koda
parents:
5285
diff
changeset
|
861 |
{$IFDEF SDL13} |
a55aab592950
Ditch the renderer system in sdl1.3 and use the 'old fashioned' sdl/opengl context. This gives us more flexibility and less problem in receiving video events (expecially on mobile platform) as well as not having to care to reset the gl context every time sdl interferes.
koda
parents:
5285
diff
changeset
|
862 |
// this function creates an opengles1.1 context by default on mobile devices |
6885 | 863 |
// unless you un-comment this two attributes |
864 |
//SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); |
|
865 |
//SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); |
|
6611 | 866 |
if SDLGLcontext = nil then |
867 |
SDLGLcontext:= SDL_GL_CreateContext(SDLwindow); |
|
5505
a55aab592950
Ditch the renderer system in sdl1.3 and use the 'old fashioned' sdl/opengl context. This gives us more flexibility and less problem in receiving video events (expecially on mobile platform) as well as not having to care to reset the gl context every time sdl interferes.
koda
parents:
5285
diff
changeset
|
868 |
SDLTry(SDLGLcontext <> nil, true); |
a55aab592950
Ditch the renderer system in sdl1.3 and use the 'old fashioned' sdl/opengl context. This gives us more flexibility and less problem in receiving video events (expecially on mobile platform) as well as not having to care to reset the gl context every time sdl interferes.
koda
parents:
5285
diff
changeset
|
869 |
SDL_GL_SetSwapInterval(1); |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
3922
diff
changeset
|
870 |
{$ENDIF} |
3405 | 871 |
|
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
872 |
// get the max (horizontal and vertical) size for textures that the gpu can support |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
873 |
glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
874 |
if MaxTextureSize <= 0 then |
5215
d4c529624460
Try and avoid problem reported by users like RDChrisco with cards that only support 512 texture size, and disable backgrounds. Also, reorganise the rq flags sprite loading a bit. Needs testing to make sure it matches the sprite uses. It should though.
nemo
parents:
5187
diff
changeset
|
875 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
876 |
MaxTextureSize:= 1024; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
877 |
AddFileLog('OpenGL Warning - driver didn''t provide any valid max texture size; assuming 1024'); |
5215
d4c529624460
Try and avoid problem reported by users like RDChrisco with cards that only support 512 texture size, and disable backgrounds. Also, reorganise the rq flags sprite loading a bit. Needs testing to make sure it matches the sprite uses. It should though.
nemo
parents:
5187
diff
changeset
|
878 |
end |
d4c529624460
Try and avoid problem reported by users like RDChrisco with cards that only support 512 texture size, and disable backgrounds. Also, reorganise the rq flags sprite loading a bit. Needs testing to make sure it matches the sprite uses. It should though.
nemo
parents:
5187
diff
changeset
|
879 |
else if (MaxTextureSize < 1024) and (MaxTextureSize >= 512) then |
d4c529624460
Try and avoid problem reported by users like RDChrisco with cards that only support 512 texture size, and disable backgrounds. Also, reorganise the rq flags sprite loading a bit. Needs testing to make sure it matches the sprite uses. It should though.
nemo
parents:
5187
diff
changeset
|
880 |
begin |
8330 | 881 |
cReducedQuality := cReducedQuality or rqNoBackground; |
5215
d4c529624460
Try and avoid problem reported by users like RDChrisco with cards that only support 512 texture size, and disable backgrounds. Also, reorganise the rq flags sprite loading a bit. Needs testing to make sure it matches the sprite uses. It should though.
nemo
parents:
5187
diff
changeset
|
882 |
AddFileLog('Texture size too small for backgrounds, disabling.'); |
d4c529624460
Try and avoid problem reported by users like RDChrisco with cards that only support 512 texture size, and disable backgrounds. Also, reorganise the rq flags sprite loading a bit. Needs testing to make sure it matches the sprite uses. It should though.
nemo
parents:
5187
diff
changeset
|
883 |
end; |
2568
e654cbfb23ba
Bunch of neat stuff by Smaxx. ATI check, translucent name tags to reduce terrain fail, disabling health crates on invulnerable hogs. Also tweaks to prior stuff.
nemo
parents:
2567
diff
changeset
|
884 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
885 |
(* |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
886 |
// find out which gpu we are using (for extension compatibility maybe?) |
3692 | 887 |
{$IFDEF IPHONEOS} |
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
888 |
vendor:= vendor; // avoid hint |
3692 | 889 |
cGPUVendor:= gvApple; |
890 |
{$ELSE} |
|
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
891 |
vendor:= LowerCase(shortstring(pchar(glGetString(GL_VENDOR)))); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
892 |
if StrPos(Str2PChar(vendor), Str2PChar('nvidia')) <> nil then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
893 |
cGPUVendor:= gvNVIDIA |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
894 |
else if StrPos(Str2PChar(vendor), Str2PChar('intel')) <> nil then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
895 |
cGPUVendor:= gvATI |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
896 |
else if StrPos(Str2PChar(vendor), Str2PChar('ati')) <> nil then |
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
897 |
cGPUVendor:= gvIntel |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
898 |
else |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
899 |
AddFileLog('OpenGL Warning - unknown hardware vendor; please report'); |
4347
0ddb100fea61
add a S3D_DISABLED symbol to disable/enable stereo rendering at compilation time
koda
parents:
4343
diff
changeset
|
900 |
{$ENDIF} |
2647 | 901 |
//SupportNPOTT:= glLoadExtension('GL_ARB_texture_non_power_of_two'); |
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
902 |
*) |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
903 |
|
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
904 |
// everyone love debugging |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
905 |
AddFileLog('OpenGL-- Renderer: ' + shortstring(pchar(glGetString(GL_RENDERER)))); |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
906 |
AddFileLog(' |----- Vendor: ' + shortstring(pchar(glGetString(GL_VENDOR)))); |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
907 |
AddFileLog(' |----- Version: ' + shortstring(pchar(glGetString(GL_VERSION)))); |
6885 | 908 |
AddFileLog(' |----- Texture Size: ' + inttostr(MaxTextureSize)); |
7635
7a8b2f04c7dd
don't query/print GL_AUX_BUFFERS if video recording is disabled
sheepluva
parents:
7634
diff
changeset
|
909 |
{$IFDEF USE_VIDEO_RECORDING} |
7a8b2f04c7dd
don't query/print GL_AUX_BUFFERS if video recording is disabled
sheepluva
parents:
7634
diff
changeset
|
910 |
glGetIntegerv(GL_AUX_BUFFERS, @AuxBufNum); |
7a8b2f04c7dd
don't query/print GL_AUX_BUFFERS if video recording is disabled
sheepluva
parents:
7634
diff
changeset
|
911 |
AddFileLog(' |----- Number of auxiliary buffers: ' + inttostr(AuxBufNum)); |
7a8b2f04c7dd
don't query/print GL_AUX_BUFFERS if video recording is disabled
sheepluva
parents:
7634
diff
changeset
|
912 |
{$ENDIF} |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
913 |
{$IFDEF PAS2C} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
914 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
915 |
// doesn't seem to print >256 chars |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
916 |
AddFileLogRaw(PChar(glGetString(GL_EXTENSIONS))); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
917 |
{$ELSE} |
7180 | 918 |
AddFileLog(' \----- Extensions: '); |
7634
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
919 |
// fetch extentions and store them in string |
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
920 |
tmpstr := StrPas(PChar(glGetString(GL_EXTENSIONS))); |
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
921 |
tmpn := WordCount(tmpstr, [' ']); |
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
922 |
tmpint := 1; |
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
923 |
|
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
924 |
repeat |
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
925 |
begin |
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
926 |
// print up to 3 extentions per row |
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
927 |
// ExtractWord will return empty string if index out of range |
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
928 |
AddFileLog(TrimRight( |
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
929 |
ExtractWord(tmpint, tmpstr, [' ']) + ' ' + |
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
930 |
ExtractWord(tmpint+1, tmpstr, [' ']) + ' ' + |
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
931 |
ExtractWord(tmpint+2, tmpstr, [' ']) |
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
932 |
)); |
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
933 |
tmpint := tmpint + 3; |
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
934 |
end; |
ca14ec44b223
print all GL_EXTENSIONS properly to logfile (should a;sp fix build on systems with compiler/lib versions that can't implicity cast PGLubyte to PChar)
sheepluva
parents:
7565
diff
changeset
|
935 |
until (tmpint > tmpn); |
7637
60b213e5ded3
use old approach for printing gl extentions for pas2c (less complex/no StrUtils dependencies)
sheepluva
parents:
7635
diff
changeset
|
936 |
{$ENDIF} |
7180 | 937 |
AddFileLog(''); |
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
938 |
|
7180 | 939 |
defaultFrame:= 0; |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
940 |
{$IFDEF USE_VIDEO_RECORDING} |
7180 | 941 |
if GameType = gmtRecord then |
7371
911b53e8c00a
First try to use framebuffer, instead of auxilary buffer.
Stepan777 <stepik-777@mail.ru>
parents:
7350
diff
changeset
|
942 |
begin |
911b53e8c00a
First try to use framebuffer, instead of auxilary buffer.
Stepan777 <stepik-777@mail.ru>
parents:
7350
diff
changeset
|
943 |
if glLoadExtension('GL_EXT_framebuffer_object') then |
911b53e8c00a
First try to use framebuffer, instead of auxilary buffer.
Stepan777 <stepik-777@mail.ru>
parents:
7350
diff
changeset
|
944 |
begin |
911b53e8c00a
First try to use framebuffer, instead of auxilary buffer.
Stepan777 <stepik-777@mail.ru>
parents:
7350
diff
changeset
|
945 |
CreateFramebuffer(defaultFrame, depthv, texv); |
911b53e8c00a
First try to use framebuffer, instead of auxilary buffer.
Stepan777 <stepik-777@mail.ru>
parents:
7350
diff
changeset
|
946 |
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, defaultFrame); |
911b53e8c00a
First try to use framebuffer, instead of auxilary buffer.
Stepan777 <stepik-777@mail.ru>
parents:
7350
diff
changeset
|
947 |
AddFileLog('Using framebuffer for video recording.'); |
911b53e8c00a
First try to use framebuffer, instead of auxilary buffer.
Stepan777 <stepik-777@mail.ru>
parents:
7350
diff
changeset
|
948 |
end |
911b53e8c00a
First try to use framebuffer, instead of auxilary buffer.
Stepan777 <stepik-777@mail.ru>
parents:
7350
diff
changeset
|
949 |
else if AuxBufNum > 0 then |
7180 | 950 |
begin |
951 |
glDrawBuffer(GL_AUX0); |
|
952 |
glReadBuffer(GL_AUX0); |
|
7635
7a8b2f04c7dd
don't query/print GL_AUX_BUFFERS if video recording is disabled
sheepluva
parents:
7634
diff
changeset
|
953 |
AddFileLog('Using auxiliary buffer for video recording.'); |
7180 | 954 |
end |
955 |
else |
|
956 |
begin |
|
957 |
glDrawBuffer(GL_BACK); |
|
958 |
glReadBuffer(GL_BACK); |
|
959 |
AddFileLog('Warning: off-screen rendering is not supported; using back buffer but it may not work.'); |
|
960 |
end; |
|
961 |
end; |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
962 |
{$ENDIF} |
7180 | 963 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
964 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
965 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
966 |
{$IFDEF PAS2C} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
967 |
err := glewInit(); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
968 |
if err <> GLEW_OK then |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
969 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
970 |
WriteLnToConsole('Failed to initialize GLEW.'); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
971 |
halt; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
972 |
end; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
973 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
974 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
975 |
{$IFNDEF PAS2C} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
976 |
if not Load_GL_VERSION_2_0 then |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
977 |
halt; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
978 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
979 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
980 |
shaderWater:= CompileProgram('water'); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
981 |
glUseProgram(shaderWater); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
982 |
glUniform1i(glGetUniformLocation(shaderWater, pchar('tex0')), 0); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
983 |
uWaterMVPLocation:= glGetUniformLocation(shaderWater, pchar('mvp')); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
984 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
985 |
shaderMain:= CompileProgram('default'); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
986 |
glUseProgram(shaderMain); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
987 |
glUniform1i(glGetUniformLocation(shaderMain, pchar('tex0')), 0); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
988 |
uMainMVPLocation:= glGetUniformLocation(shaderMain, pchar('mvp')); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
989 |
uMainTintLocation:= glGetUniformLocation(shaderMain, pchar('tint')); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
990 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
991 |
uCurrentMVPLocation:= uMainMVPLocation; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
992 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
993 |
Tint(255, 255, 255, 255); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
994 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
995 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
996 |
|
8330 | 997 |
{$IFNDEF USE_S3D_RENDERING} |
3696 | 998 |
if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then |
3692 | 999 |
begin |
1000 |
// prepare left and right frame buffers and associated textures |
|
4347
0ddb100fea61
add a S3D_DISABLED symbol to disable/enable stereo rendering at compilation time
koda
parents:
4343
diff
changeset
|
1001 |
if glLoadExtension('GL_EXT_framebuffer_object') then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1002 |
begin |
7180 | 1003 |
CreateFramebuffer(framel, depthl, texl); |
1004 |
CreateFramebuffer(framer, depthr, texr); |
|
3692 | 1005 |
|
4347
0ddb100fea61
add a S3D_DISABLED symbol to disable/enable stereo rendering at compilation time
koda
parents:
4343
diff
changeset
|
1006 |
// reset |
7180 | 1007 |
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, defaultFrame) |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1008 |
end |
4347
0ddb100fea61
add a S3D_DISABLED symbol to disable/enable stereo rendering at compilation time
koda
parents:
4343
diff
changeset
|
1009 |
else |
0ddb100fea61
add a S3D_DISABLED symbol to disable/enable stereo rendering at compilation time
koda
parents:
4343
diff
changeset
|
1010 |
cStereoMode:= smNone; |
3692 | 1011 |
end; |
2735 | 1012 |
{$ENDIF} |
1013 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1014 |
// set view port to whole window |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1015 |
glViewport(0, 0, cScreenWidth, cScreenHeight); |
2428 | 1016 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1017 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1018 |
uMatrix.initModule; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1019 |
hglMatrixMode(MATRIX_MODELVIEW); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1020 |
// prepare default translation/scaling |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1021 |
hglLoadIdentity(); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1022 |
hglScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1023 |
hglTranslatef(0, -cScreenHeight / 2, 0); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1024 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1025 |
EnableTexture(True); |
8330 | 1026 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1027 |
glEnableVertexAttribArray(aVertex); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1028 |
glEnableVertexAttribArray(aTexCoord); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1029 |
glGenBuffers(1, @vBuffer); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1030 |
glGenBuffers(1, @tBuffer); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1031 |
glGenBuffers(1, @cBuffer); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1032 |
{$ELSE} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1033 |
glMatrixMode(GL_MODELVIEW); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1034 |
// prepare default translation/scaling |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1035 |
glLoadIdentity(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1036 |
glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1037 |
glTranslatef(0, -cScreenHeight / 2, 0); |
2428 | 1038 |
|
5045
f215eb5d4b75
this supposedly makes hwengine work with sdl 1.3 past rev 5296
koda
parents:
5043
diff
changeset
|
1039 |
// disable/lower perspective correction (will not need it anyway) |
3376 | 1040 |
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); |
1041 |
// disable dithering |
|
1042 |
glDisable(GL_DITHER); |
|
3641 | 1043 |
// enable common states by default as they save a lot |
3376 | 1044 |
glEnable(GL_TEXTURE_2D); |
3697 | 1045 |
glEnableClientState(GL_VERTEX_ARRAY); |
1046 |
glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1047 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1048 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1049 |
// enable alpha blending |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1050 |
glEnable(GL_BLEND); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1051 |
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1052 |
// disable/lower perspective correction (will not need it anyway) |
4 | 1053 |
end; |
1054 |
||
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1055 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1056 |
procedure EnableTexture(enable:Boolean); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1057 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1058 |
if enable then |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1059 |
glUniform1i(glGetUniformLocation(shaderMain, pchar('enableTexture')), 1) |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1060 |
else |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1061 |
glUniform1i(glGetUniformLocation(shaderMain, pchar('enableTexture')), 0); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1062 |
end; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1063 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1064 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1065 |
procedure SetTexCoordPointer(p: Pointer; n: Integer); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1066 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1067 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1068 |
glBindBuffer(GL_ARRAY_BUFFER, tBuffer); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1069 |
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * n * 2, p, GL_STATIC_DRAW); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1070 |
glEnableVertexAttribArray(aTexCoord); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1071 |
glVertexAttribPointer(aTexCoord, 2, GL_FLOAT, GL_FALSE, 0, pointer(0)); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1072 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1073 |
glTexCoordPointer(2, GL_FLOAT, 0, p); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1074 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1075 |
end; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1076 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1077 |
procedure SetVertexPointer(p: Pointer; n: Integer); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1078 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1079 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1080 |
glBindBuffer(GL_ARRAY_BUFFER, vBuffer); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1081 |
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * n * 2, p, GL_STATIC_DRAW); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1082 |
glEnableVertexAttribArray(aVertex); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1083 |
glVertexAttribPointer(aVertex, 2, GL_FLOAT, GL_FALSE, 0, pointer(0)); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1084 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1085 |
glVertexPointer(2, GL_FLOAT, 0, p); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1086 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1087 |
end; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1088 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1089 |
procedure SetColorPointer(p: Pointer; n: Integer); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1090 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1091 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1092 |
glBindBuffer(GL_ARRAY_BUFFER, cBuffer); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1093 |
glBufferData(GL_ARRAY_BUFFER, n * 4, p, GL_STATIC_DRAW); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1094 |
glEnableVertexAttribArray(aColor); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1095 |
glVertexAttribPointer(aColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, pointer(0)); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1096 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1097 |
glColorPointer(4, GL_UNSIGNED_BYTE, 0, p); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1098 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1099 |
end; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1100 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1101 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1102 |
procedure UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1103 |
var |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1104 |
mvp: TMatrix4x4f; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1105 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1106 |
//MatrixMultiply(mvp, mProjection, mModelview); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1107 |
hglMVP(mvp); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1108 |
glUniformMatrix4fv(uCurrentMVPLocation, 1, GL_FALSE, @mvp[0, 0]); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1109 |
end; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1110 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1111 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1112 |
(* |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1113 |
procedure UpdateProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1114 |
var |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1115 |
s: GLfloat; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1116 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1117 |
s:=cScaleFactor; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1118 |
mProjection[0,0]:= s/cScreenWidth; mProjection[0,1]:= 0.0; mProjection[0,2]:=0.0; mProjection[0,3]:= 0.0; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1119 |
mProjection[1,0]:= 0.0; mProjection[1,1]:= -s/cScreenHeight; mProjection[1,2]:=0.0; mProjection[1,3]:= 0.0; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1120 |
mProjection[2,0]:= 0.0; mProjection[2,1]:= 0.0; mProjection[2,2]:=1.0; mProjection[2,3]:= 0.0; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1121 |
mProjection[3,0]:= cStereoDepth; mProjection[3,1]:= s/2; mProjection[3,2]:=0.0; mProjection[3,3]:= 1.0; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1122 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1123 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1124 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1125 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1126 |
glMatrixMode(GL_PROJECTION); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1127 |
glLoadMatrixf(@mProjection[0, 0]); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1128 |
glMatrixMode(GL_MODELVIEW); |
8330 | 1129 |
{$ENDIF} |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1130 |
end; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1131 |
*) |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1132 |
|
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2154
diff
changeset
|
1133 |
procedure SetScale(f: GLfloat); |
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2154
diff
changeset
|
1134 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1135 |
// leave immediately if scale factor did not change |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1136 |
if f = cScaleFactor then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1137 |
exit; |
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2154
diff
changeset
|
1138 |
|
3523 | 1139 |
if f = cDefaultZoomLevel then |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1140 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1141 |
hglPopMatrix // "return" to default scaling |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1142 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1143 |
glPopMatrix |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1144 |
{$ENDIF} |
3523 | 1145 |
else // other scaling |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1146 |
begin |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1147 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1148 |
hglPushMatrix; // save default scaling |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1149 |
hglLoadIdentity; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1150 |
hglScalef(f / cScreenWidth, -f / cScreenHeight, 1.0); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1151 |
hglTranslatef(0, -cScreenHeight / 2, 0); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1152 |
{$ELSE} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1153 |
glPushMatrix; // save default scaling |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1154 |
glLoadIdentity; |
3922
44804043b691
iPad Video Out support (+less warnings +code update for latest SDL)
koda
parents:
3906
diff
changeset
|
1155 |
glScalef(f / cScreenWidth, -f / cScreenHeight, 1.0); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1156 |
glTranslatef(0, -cScreenHeight / 2, 0); |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1157 |
{$ENDIF} |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1158 |
end; |
2258 | 1159 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1160 |
cScaleFactor:= f; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1161 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1162 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1163 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1164 |
{$ENDIF} |
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2154
diff
changeset
|
1165 |
end; |
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2154
diff
changeset
|
1166 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1167 |
procedure BeginWater; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1168 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1169 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1170 |
glUseProgram(shaderWater); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1171 |
uCurrentMVPLocation:=uWaterMVPLocation; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1172 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1173 |
glDisableVertexAttribArray(aTexCoord); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1174 |
glEnableVertexAttribArray(aColor); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1175 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1176 |
glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1177 |
glEnableClientState(GL_COLOR_ARRAY); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1178 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1179 |
end; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1180 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1181 |
procedure EndWater; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1182 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1183 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1184 |
glUseProgram(shaderMain); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1185 |
uCurrentMVPLocation:=uMainMVPLocation; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1186 |
UpdateModelviewProjection; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1187 |
glDisableVertexAttribArray(aColor); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1188 |
glEnableVertexAttribArray(aTexCoord); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1189 |
{$ELSE} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1190 |
glDisableClientState(GL_COLOR_ARRAY); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1191 |
glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1192 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1193 |
end; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1194 |
|
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1195 |
|
510 | 1196 |
//////////////////////////////////////////////////////////////////////////////// |
1197 |
procedure AddProgress; |
|
1198 |
var r: TSDL_Rect; |
|
766 | 1199 |
texsurf: PSDL_Surface; |
510 | 1200 |
begin |
8027
e5ba3dd12531
make stats-only mode work headless. also skip a few things to save time/memory.
nemo
parents:
7866
diff
changeset
|
1201 |
if cOnlyStats then exit; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1202 |
if Step = 0 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1203 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1204 |
WriteToConsole(msgLoading + 'progress sprite: '); |
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
1205 |
texsurf:= LoadDataImage(ptGraphics, 'Progress', ifCritical or ifTransparent); |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2705
diff
changeset
|
1206 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1207 |
ProgrTex:= Surface2Tex(texsurf, false); |
3697 | 1208 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1209 |
squaresize:= texsurf^.w shr 1; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1210 |
numsquares:= texsurf^.h div squaresize; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1211 |
SDL_FreeSurface(texsurf); |
8204 | 1212 |
with mobileRecord do |
1213 |
if GameLoading <> nil then |
|
1214 |
GameLoading(); |
|
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
3922
diff
changeset
|
1215 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1216 |
end; |
1045 | 1217 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1218 |
TryDo(ProgrTex <> nil, 'Error - Progress Texure is nil!', true); |
2284 | 1219 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1220 |
glClear(GL_COLOR_BUFFER_BIT); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1221 |
if Step < numsquares then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1222 |
r.x:= 0 |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1223 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1224 |
r.x:= squaresize; |
3697 | 1225 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1226 |
r.y:= (Step mod numsquares) * squaresize; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1227 |
r.w:= squaresize; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1228 |
r.h:= squaresize; |
3697 | 1229 |
|
6999 | 1230 |
DrawTextureFromRect( -squaresize div 2, (cScreenHeight - squaresize) shr 1, @r, ProgrTex); |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2705
diff
changeset
|
1231 |
|
7049 | 1232 |
SwapBuffers; |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1233 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1234 |
inc(Step); |
510 | 1235 |
end; |
1236 |
||
1237 |
procedure FinishProgress; |
|
1238 |
begin |
|
8204 | 1239 |
with mobileRecord do |
1240 |
if GameLoaded <> nil then |
|
1241 |
GameLoaded(); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1242 |
WriteLnToConsole('Freeing progress surface... '); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1243 |
FreeTexture(ProgrTex); |
6394
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
1244 |
ProgrTex:= nil; |
5714 | 1245 |
Step:= 0 |
510 | 1246 |
end; |
1247 |
||
2905 | 1248 |
function RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture; |
2747 | 1249 |
var tmpsurf: PSDL_SURFACE; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1250 |
w, h, i, j: LongInt; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1251 |
font: THWFont; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1252 |
r, r2: TSDL_Rect; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1253 |
wa, ha: LongInt; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1254 |
tmpline, tmpline2, tmpdesc: ansistring; |
2747 | 1255 |
begin |
2843 | 1256 |
// make sure there is a caption as well as a sub caption - description is optional |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1257 |
if caption = '' then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1258 |
caption:= '???'; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1259 |
if subcaption = '' then |
7134 | 1260 |
subcaption:= _S' '; |
2843 | 1261 |
|
2841 | 1262 |
font:= CheckCJKFont(caption,fnt16); |
1263 |
font:= CheckCJKFont(subcaption,font); |
|
1264 |
font:= CheckCJKFont(description,font); |
|
1265 |
font:= CheckCJKFont(extra,font); |
|
2747 | 1266 |
|
1267 |
w:= 0; |
|
1268 |
h:= 0; |
|
6982 | 1269 |
wa:= cFontBorder * 2 + 4; |
1270 |
ha:= cFontBorder * 2; |
|
2747 | 1271 |
|
3407 | 1272 |
i:= 0; j:= 0; // avoid compiler hints |
1273 |
||
2747 | 1274 |
// TODO: Recheck height/position calculation |
1275 |
||
1276 |
// get caption's dimensions |
|
6286
835392304f81
and while we are giving SDLh.pas all this love, let's fix the signature of one SDL_ttf calls
koda
parents:
6089
diff
changeset
|
1277 |
TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(caption), @i, @j); |
2747 | 1278 |
// width adds 36 px (image + space) |
1279 |
w:= i + 36 + wa; |
|
1280 |
h:= j + ha; |
|
1281 |
||
1282 |
// get sub caption's dimensions |
|
6286
835392304f81
and while we are giving SDLh.pas all this love, let's fix the signature of one SDL_ttf calls
koda
parents:
6089
diff
changeset
|
1283 |
TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(subcaption), @i, @j); |
2747 | 1284 |
// width adds 36 px (image + space) |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1285 |
if w < (i + 36 + wa) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1286 |
w:= i + 36 + wa; |
2747 | 1287 |
inc(h, j + ha); |
1288 |
||
1289 |
// get description's dimensions |
|
1290 |
tmpdesc:= description; |
|
1291 |
while tmpdesc <> '' do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1292 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1293 |
tmpline:= tmpdesc; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1294 |
SplitByChar(tmpline, tmpdesc, '|'); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1295 |
if tmpline <> '' then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1296 |
begin |
6286
835392304f81
and while we are giving SDLh.pas all this love, let's fix the signature of one SDL_ttf calls
koda
parents:
6089
diff
changeset
|
1297 |
TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(tmpline), @i, @j); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1298 |
if w < (i + wa) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1299 |
w:= i + wa; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1300 |
inc(h, j + ha) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1301 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1302 |
end; |
2747 | 1303 |
|
1304 |
if extra <> '' then |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1305 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1306 |
// get extra label's dimensions |
6286
835392304f81
and while we are giving SDLh.pas all this love, let's fix the signature of one SDL_ttf calls
koda
parents:
6089
diff
changeset
|
1307 |
TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(extra), @i, @j); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1308 |
if w < (i + wa) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1309 |
w:= i + wa; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1310 |
inc(h, j + ha); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1311 |
end; |
3697 | 1312 |
|
2747 | 1313 |
// add borders space |
1314 |
inc(w, wa); |
|
1315 |
inc(h, ha + 8); |
|
1316 |
||
1317 |
tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask); |
|
1318 |
TryDo(tmpsurf <> nil, 'RenderHelpWindow: fail to create surface', true); |
|
1319 |
||
1320 |
// render border and background |
|
1321 |
r.x:= 0; |
|
1322 |
r.y:= 0; |
|
1323 |
r.w:= w; |
|
1324 |
r.h:= h; |
|
1325 |
DrawRoundRect(@r, cWhiteColor, cNearBlackColor, tmpsurf, true); |
|
1326 |
||
1327 |
// render caption |
|
6982 | 1328 |
r:= WriteInRect(tmpsurf, 36 + cFontBorder + 2, ha, $ffffffff, font, caption); |
2747 | 1329 |
// render sub caption |
6982 | 1330 |
r:= WriteInRect(tmpsurf, 36 + cFontBorder + 2, r.y + r.h, $ffc7c7c7, font, subcaption); |
2747 | 1331 |
|
1332 |
// render all description lines |
|
1333 |
tmpdesc:= description; |
|
1334 |
while tmpdesc <> '' do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1335 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1336 |
tmpline:= tmpdesc; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1337 |
SplitByChar(tmpline, tmpdesc, '|'); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1338 |
r2:= r; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1339 |
if tmpline <> '' then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1340 |
begin |
6982 | 1341 |
r:= WriteInRect(tmpsurf, cFontBorder + 2, r.y + r.h, $ff707070, font, tmpline); |
3697 | 1342 |
|
5518 | 1343 |
// render highlighted caption (if there is a ':') |
7134 | 1344 |
tmpline2:= _S''; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1345 |
SplitByChar(tmpline, tmpline2, ':'); |
7134 | 1346 |
if tmpline2 <> _S'' then |
6982 | 1347 |
WriteInRect(tmpsurf, cFontBorder + 2, r2.y + r2.h, $ffc7c7c7, font, tmpline + ':'); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1348 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1349 |
end; |
2747 | 1350 |
|
1351 |
if extra <> '' then |
|
6982 | 1352 |
r:= WriteInRect(tmpsurf, cFontBorder + 2, r.y + r.h, extracolor, font, extra); |
2747 | 1353 |
|
6982 | 1354 |
r.x:= cFontBorder + 6; |
1355 |
r.y:= cFontBorder + 4; |
|
2747 | 1356 |
r.w:= 32; |
1357 |
r.h:= 32; |
|
1358 |
SDL_FillRect(tmpsurf, @r, $ffffffff); |
|
1359 |
SDL_UpperBlit(iconsurf, iconrect, tmpsurf, @r); |
|
3697 | 1360 |
|
2747 | 1361 |
RenderHelpWindow:= Surface2Tex(tmpsurf, true); |
1362 |
SDL_FreeSurface(tmpsurf) |
|
1363 |
end; |
|
1364 |
||
1365 |
procedure RenderWeaponTooltip(atype: TAmmoType); |
|
1366 |
var r: TSDL_Rect; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1367 |
i: LongInt; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1368 |
extra: ansistring; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1369 |
extracolor: LongInt; |
2747 | 1370 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1371 |
// don't do anything if the window shouldn't be shown |
3634 | 1372 |
if (cReducedQuality and rqTooltipsOff) <> 0 then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1373 |
begin |
3634 | 1374 |
WeaponTooltipTex:= nil; |
1375 |
exit |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1376 |
end; |
2747 | 1377 |
|
1378 |
// free old texture |
|
1379 |
FreeWeaponTooltip; |
|
1380 |
||
1381 |
// image region |
|
1382 |
i:= LongInt(atype) - 1; |
|
3853 | 1383 |
r.x:= (i shr 4) * 32; |
1384 |
r.y:= (i mod 16) * 32; |
|
2747 | 1385 |
r.w:= 32; |
1386 |
r.h:= 32; |
|
1387 |
||
1388 |
// default (no extra text) |
|
7134 | 1389 |
extra:= _S''; |
2747 | 1390 |
extracolor:= 0; |
1391 |
||
1392 |
if (CurrentTeam <> nil) and (Ammoz[atype].SkipTurns >= CurrentTeam^.Clan^.TurnNumber) then // weapon or utility is not yet available |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1393 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1394 |
extra:= trmsg[sidNotYetAvailable]; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1395 |
extracolor:= LongInt($ffc77070); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1396 |
end |
5518 | 1397 |
else if (Ammoz[atype].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then // weapon or utility will not end your turn |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1398 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1399 |
extra:= trmsg[sidNoEndTurn]; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1400 |
extracolor:= LongInt($ff70c770); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1401 |
end |
3697 | 1402 |
else |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1403 |
begin |
7134 | 1404 |
extra:= _S''; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1405 |
extracolor:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1406 |
end; |
2747 | 1407 |
|
1408 |
// render window and return the texture |
|
1409 |
WeaponTooltipTex:= RenderHelpWindow(trammo[Ammoz[atype].NameId], trammoc[Ammoz[atype].NameId], trammod[Ammoz[atype].NameId], extra, extracolor, SpritesData[sprAMAmmos].Surface, @r) |
|
2753 | 1410 |
end; |
2747 | 1411 |
|
1412 |
procedure ShowWeaponTooltip(x, y: LongInt); |
|
1413 |
begin |
|
1414 |
// draw the texture if it exists |
|
1415 |
if WeaponTooltipTex <> nil then |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2910
diff
changeset
|
1416 |
DrawTexture(x, y, WeaponTooltipTex) |
2747 | 1417 |
end; |
1418 |
||
1419 |
procedure FreeWeaponTooltip; |
|
1420 |
begin |
|
5045
f215eb5d4b75
this supposedly makes hwengine work with sdl 1.3 past rev 5296
koda
parents:
5043
diff
changeset
|
1421 |
// free the existing texture (if there is any) |
2747 | 1422 |
FreeTexture(WeaponTooltipTex); |
1423 |
WeaponTooltipTex:= nil |
|
1424 |
end; |
|
1425 |
||
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
1426 |
{$IFDEF USE_VIDEO_RECORDING} |
7350
1dbf3f4340e0
When compiling with sdl2 use it instead of glut for creating hidden window (as suggested by koda).
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
1427 |
{$IFDEF SDL13} |
1dbf3f4340e0
When compiling with sdl2 use it instead of glut for creating hidden window (as suggested by koda).
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
1428 |
procedure InitOffscreenOpenGL; |
1dbf3f4340e0
When compiling with sdl2 use it instead of glut for creating hidden window (as suggested by koda).
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
1429 |
begin |
1dbf3f4340e0
When compiling with sdl2 use it instead of glut for creating hidden window (as suggested by koda).
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
1430 |
// create hidden window |
1dbf3f4340e0
When compiling with sdl2 use it instead of glut for creating hidden window (as suggested by koda).
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
1431 |
SDLwindow:= SDL_CreateWindow('hedgewars (you don''t see this)', |
1dbf3f4340e0
When compiling with sdl2 use it instead of glut for creating hidden window (as suggested by koda).
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
1432 |
SDL_WINDOWPOS_CENTERED_MASK, SDL_WINDOWPOS_CENTERED_MASK, |
1dbf3f4340e0
When compiling with sdl2 use it instead of glut for creating hidden window (as suggested by koda).
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
1433 |
cScreenWidth, cScreenHeight, |
1dbf3f4340e0
When compiling with sdl2 use it instead of glut for creating hidden window (as suggested by koda).
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
1434 |
SDL_WINDOW_HIDDEN or SDL_WINDOW_OPENGL); |
1dbf3f4340e0
When compiling with sdl2 use it instead of glut for creating hidden window (as suggested by koda).
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
1435 |
SDLTry(SDLwindow <> nil, true); |
1dbf3f4340e0
When compiling with sdl2 use it instead of glut for creating hidden window (as suggested by koda).
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
1436 |
SetupOpenGL(); |
1dbf3f4340e0
When compiling with sdl2 use it instead of glut for creating hidden window (as suggested by koda).
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
1437 |
end; |
1dbf3f4340e0
When compiling with sdl2 use it instead of glut for creating hidden window (as suggested by koda).
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
1438 |
{$ELSE} |
7180 | 1439 |
procedure InitOffscreenOpenGL; |
1440 |
var ArgCount: LongInt; |
|
1441 |
PrgName: pchar; |
|
1442 |
begin |
|
1443 |
ArgCount:= 1; |
|
1444 |
PrgName:= 'hwengine'; |
|
1445 |
glutInit(@ArgCount, @PrgName); |
|
1446 |
glutInitWindowSize(cScreenWidth, cScreenHeight); |
|
7350
1dbf3f4340e0
When compiling with sdl2 use it instead of glut for creating hidden window (as suggested by koda).
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
1447 |
glutCreateWindow('hedgewars (you don''t see this)'); // we don't need a window, but if this function is not called then OpenGL will not be initialized |
7180 | 1448 |
glutHideWindow(); |
7866
58d10edc5d21
apparently we are forced to use a (dummy) callback for glut 3.0 compatibility
koda
parents:
7754
diff
changeset
|
1449 |
glutDisplayFunc(@SwapBuffers); // we don't need a callback, but it's required for GLUT3 |
7180 | 1450 |
SetupOpenGL(); |
1451 |
end; |
|
7350
1dbf3f4340e0
When compiling with sdl2 use it instead of glut for creating hidden window (as suggested by koda).
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
1452 |
{$ENDIF} // SDL13 |
1dbf3f4340e0
When compiling with sdl2 use it instead of glut for creating hidden window (as suggested by koda).
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
1453 |
{$ENDIF} // USE_VIDEO_RECORDING |
7180 | 1454 |
|
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4390
diff
changeset
|
1455 |
procedure chFullScr(var s: shortstring); |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4390
diff
changeset
|
1456 |
var flags: Longword = 0; |
6072 | 1457 |
reinit: boolean = false; |
1458 |
{$IFNDEF DARWIN}ico: PSDL_Surface;{$ENDIF} |
|
5052 | 1459 |
{$IFDEF SDL13}x, y: LongInt;{$ENDIF} |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4390
diff
changeset
|
1460 |
begin |
8027
e5ba3dd12531
make stats-only mode work headless. also skip a few things to save time/memory.
nemo
parents:
7866
diff
changeset
|
1461 |
if cOnlyStats then |
e5ba3dd12531
make stats-only mode work headless. also skip a few things to save time/memory.
nemo
parents:
7866
diff
changeset
|
1462 |
begin |
e5ba3dd12531
make stats-only mode work headless. also skip a few things to save time/memory.
nemo
parents:
7866
diff
changeset
|
1463 |
MaxTextureSize:= 1024; |
e5ba3dd12531
make stats-only mode work headless. also skip a few things to save time/memory.
nemo
parents:
7866
diff
changeset
|
1464 |
exit |
e5ba3dd12531
make stats-only mode work headless. also skip a few things to save time/memory.
nemo
parents:
7866
diff
changeset
|
1465 |
end; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1466 |
if Length(s) = 0 then |
8027
e5ba3dd12531
make stats-only mode work headless. also skip a few things to save time/memory.
nemo
parents:
7866
diff
changeset
|
1467 |
cFullScreen:= (not cFullScreen) |
e5ba3dd12531
make stats-only mode work headless. also skip a few things to save time/memory.
nemo
parents:
7866
diff
changeset
|
1468 |
else cFullScreen:= s = '1'; |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8309
diff
changeset
|
1469 |
|
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8309
diff
changeset
|
1470 |
if cFullScreen then |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8309
diff
changeset
|
1471 |
begin |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8309
diff
changeset
|
1472 |
cScreenWidth:= cFullscreenWidth; |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8309
diff
changeset
|
1473 |
cScreenHeight:= cFullscreenHeight; |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8309
diff
changeset
|
1474 |
end |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8309
diff
changeset
|
1475 |
else |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8309
diff
changeset
|
1476 |
begin |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8309
diff
changeset
|
1477 |
cScreenWidth:= cWindowedWidth; |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8309
diff
changeset
|
1478 |
cScreenHeight:= cWindowedHeight; |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8309
diff
changeset
|
1479 |
end; |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4390
diff
changeset
|
1480 |
|
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1481 |
AddFileLog('Preparing to change video parameters...'); |
6611 | 1482 |
{$IFDEF SDL13} |
6598
fa518383563b
added pause/resume functionality for android, android need the opengl context to be recreated along with textures and whatnot
Xeli
parents:
6580
diff
changeset
|
1483 |
if SDLwindow = nil then |
6611 | 1484 |
{$ELSE} |
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1485 |
if SDLPrimSurface = nil then |
6611 | 1486 |
{$ENDIF} |
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1487 |
begin |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1488 |
// set window title |
7151 | 1489 |
{$IFNDEF SDL13}SDL_WM_SetCaption(_P'Hedgewars', nil);{$ENDIF} |
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1490 |
WriteToConsole('Init SDL_image... '); |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1491 |
SDLTry(IMG_Init(IMG_INIT_PNG) <> 0, true); |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1492 |
WriteLnToConsole(msgOK); |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1493 |
// load engine icon |
6598
fa518383563b
added pause/resume functionality for android, android need the opengl context to be recreated along with textures and whatnot
Xeli
parents:
6580
diff
changeset
|
1494 |
{$IFNDEF DARWIN} |
7640
e9e6b4d740f6
clean up LoadImage and UserPathz/AltPath/etc related redundancy by introducing 3 new functions in uStore.pas
sheepluva
parents:
7637
diff
changeset
|
1495 |
ico:= LoadDataImage(ptGraphics, 'hwengine', ifIgnoreCaps); |
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1496 |
if ico <> nil then |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1497 |
begin |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1498 |
SDL_WM_SetIcon(ico, 0); |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1499 |
SDL_FreeSurface(ico) |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1500 |
end; |
6598
fa518383563b
added pause/resume functionality for android, android need the opengl context to be recreated along with textures and whatnot
Xeli
parents:
6580
diff
changeset
|
1501 |
{$ENDIF} |
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1502 |
end |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1503 |
else |
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1504 |
begin |
6675
dab56311daa5
tipped by xeli, ammomenu texture needs to be redrawn on resize to update its position
koda
parents:
6674
diff
changeset
|
1505 |
AmmoMenuInvalidated:= true; |
6611 | 1506 |
{$IFDEF IPHONEOS} |
1507 |
// chFullScr is called when there is a rotation event and needs the SetScale and SetupOpenGL to set up the new resolution |
|
1508 |
// this 6 gl functions are the relevant ones and are hacked together here for optimisation |
|
1509 |
glMatrixMode(GL_MODELVIEW); |
|
1510 |
glPopMatrix; |
|
1511 |
glLoadIdentity(); |
|
1512 |
glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); |
|
1513 |
glTranslatef(0, -cScreenHeight / 2, 0); |
|
1514 |
glViewport(0, 0, cScreenWidth, cScreenHeight); |
|
1515 |
exit; |
|
1516 |
{$ELSE} |
|
5847 | 1517 |
SetScale(cDefaultZoomLevel); |
6674 | 1518 |
{$IFDEF USE_CONTEXT_RESTORE} |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
1519 |
reinit:= true; |
6394
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
1520 |
StoreRelease(true); |
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
1521 |
ResetLand; |
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
1522 |
ResetWorldTex; |
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
1523 |
//uTextures.freeModule; //DEBUG ONLY |
6598
fa518383563b
added pause/resume functionality for android, android need the opengl context to be recreated along with textures and whatnot
Xeli
parents:
6580
diff
changeset
|
1524 |
{$ENDIF} |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4390
diff
changeset
|
1525 |
AddFileLog('Freeing old primary surface...'); |
8330 | 1526 |
{$IFNDEF SDL13} |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1527 |
{$IFNDEF WEBGL} |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4390
diff
changeset
|
1528 |
SDL_FreeSurface(SDLPrimSurface); |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4390
diff
changeset
|
1529 |
SDLPrimSurface:= nil; |
7085 | 1530 |
{$ENDIF} |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1531 |
{$ENDIF} |
6611 | 1532 |
{$ENDIF} |
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1533 |
end; |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4390
diff
changeset
|
1534 |
|
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1535 |
// these attributes must be set up before creating the sdl window |
5883
a6d764786905
Disable GL SetAttributes for Windows due to many testers with problems. This restores .15 behaviour.
nemo
parents:
5847
diff
changeset
|
1536 |
{$IFNDEF WIN32} |
a6d764786905
Disable GL SetAttributes for Windows due to many testers with problems. This restores .15 behaviour.
nemo
parents:
5847
diff
changeset
|
1537 |
(* On a large number of testers machines, SDL default to software rendering when opengl attributes were set. |
a6d764786905
Disable GL SetAttributes for Windows due to many testers with problems. This restores .15 behaviour.
nemo
parents:
5847
diff
changeset
|
1538 |
These attributes were "set" after CreateWindow in .15, which probably did nothing. |
a6d764786905
Disable GL SetAttributes for Windows due to many testers with problems. This restores .15 behaviour.
nemo
parents:
5847
diff
changeset
|
1539 |
IMO we should rely on the gl_config defaults from SDL, and use SDL_GL_GetAttribute to possibly post warnings if any |
a6d764786905
Disable GL SetAttributes for Windows due to many testers with problems. This restores .15 behaviour.
nemo
parents:
5847
diff
changeset
|
1540 |
bad values are set. *) |
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1541 |
SetupOpenGLAttributes(); |
5883
a6d764786905
Disable GL SetAttributes for Windows due to many testers with problems. This restores .15 behaviour.
nemo
parents:
5847
diff
changeset
|
1542 |
{$ENDIF} |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4390
diff
changeset
|
1543 |
{$IFDEF SDL13} |
5187 | 1544 |
// these values in x and y make the window appear in the center |
1545 |
x:= SDL_WINDOWPOS_CENTERED_MASK; |
|
1546 |
y:= SDL_WINDOWPOS_CENTERED_MASK; |
|
6624
e049b5bb0ad1
BUUUUURN OBJC AMMOMENU BUUUURNhg diff! (on a separate note, this reduces the codesize by ~37k)
koda
parents:
6614
diff
changeset
|
1547 |
// SDL_WINDOW_RESIZABLE makes the window respond to rotation events on mobile devices |
e049b5bb0ad1
BUUUUURN OBJC AMMOMENU BUUUURNhg diff! (on a separate note, this reduces the codesize by ~37k)
koda
parents:
6614
diff
changeset
|
1548 |
flags:= SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN or SDL_WINDOW_RESIZABLE; |
5187 | 1549 |
|
6598
fa518383563b
added pause/resume functionality for android, android need the opengl context to be recreated along with textures and whatnot
Xeli
parents:
6580
diff
changeset
|
1550 |
{$IFDEF MOBILE} |
6611 | 1551 |
if isPhone() then |
1552 |
SDL_SetHint('SDL_IOS_ORIENTATIONS','LandscapeLeft LandscapeRight'); |
|
6624
e049b5bb0ad1
BUUUUURN OBJC AMMOMENU BUUUURNhg diff! (on a separate note, this reduces the codesize by ~37k)
koda
parents:
6614
diff
changeset
|
1553 |
// no need for borders on mobile devices |
e049b5bb0ad1
BUUUUURN OBJC AMMOMENU BUUUURNhg diff! (on a separate note, this reduces the codesize by ~37k)
koda
parents:
6614
diff
changeset
|
1554 |
flags:= flags or SDL_WINDOW_BORDERLESS; |
6598
fa518383563b
added pause/resume functionality for android, android need the opengl context to be recreated along with textures and whatnot
Xeli
parents:
6580
diff
changeset
|
1555 |
{$ENDIF} |
5187 | 1556 |
|
6021 | 1557 |
if SDLwindow = nil then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1558 |
if cFullScreen then |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8309
diff
changeset
|
1559 |
SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags or SDL_WINDOW_FULLSCREEN) |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1560 |
else |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8309
diff
changeset
|
1561 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1562 |
SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags); |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8309
diff
changeset
|
1563 |
end; |
5187 | 1564 |
SDLTry(SDLwindow <> nil, true); |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4390
diff
changeset
|
1565 |
{$ELSE} |
5670
e01f0b6f1969
enable window resizing (tested only on linux) - fix issue 103
koda
parents:
5662
diff
changeset
|
1566 |
flags:= SDL_OPENGL or SDL_RESIZABLE; |
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1567 |
if cFullScreen then |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8309
diff
changeset
|
1568 |
begin |
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1569 |
flags:= flags or SDL_FULLSCREEN; |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8309
diff
changeset
|
1570 |
end; |
5130
3602ede67ec5
Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents:
5109
diff
changeset
|
1571 |
if not cOnlyStats then |
3602ede67ec5
Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents:
5109
diff
changeset
|
1572 |
begin |
6598
fa518383563b
added pause/resume functionality for android, android need the opengl context to be recreated along with textures and whatnot
Xeli
parents:
6580
diff
changeset
|
1573 |
{$IFDEF WIN32} |
5565 | 1574 |
s:= SDL_getenv('SDL_VIDEO_CENTERED'); |
1575 |
SDL_putenv('SDL_VIDEO_CENTERED=1'); |
|
6598
fa518383563b
added pause/resume functionality for android, android need the opengl context to be recreated along with textures and whatnot
Xeli
parents:
6580
diff
changeset
|
1576 |
{$ENDIF} |
8309 | 1577 |
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, 0, flags); |
5130
3602ede67ec5
Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents:
5109
diff
changeset
|
1578 |
SDLTry(SDLPrimSurface <> nil, true); |
6598
fa518383563b
added pause/resume functionality for android, android need the opengl context to be recreated along with textures and whatnot
Xeli
parents:
6580
diff
changeset
|
1579 |
{$IFDEF WIN32}SDL_putenv(str2pchar('SDL_VIDEO_CENTERED=' + s));{$ENDIF} |
5130
3602ede67ec5
Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents:
5109
diff
changeset
|
1580 |
end; |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4390
diff
changeset
|
1581 |
{$ENDIF} |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4390
diff
changeset
|
1582 |
|
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4390
diff
changeset
|
1583 |
SetupOpenGL(); |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1584 |
|
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
1585 |
if reinit then |
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
1586 |
begin |
6394
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
1587 |
// clean the window from any previous content |
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
1588 |
glClear(GL_COLOR_BUFFER_BIT); |
5704 | 1589 |
if SuddenDeathDmg then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1590 |
glClearColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255, 0.99) |
8330 | 1591 |
else if ((cReducedQuality and rqNoBackground) = 0) then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1592 |
glClearColor(SkyColor.r / 255, SkyColor.g / 255, SkyColor.b / 255, 0.99) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1593 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6515
diff
changeset
|
1594 |
glClearColor(RQSkyColor.r / 255, RQSkyColor.g / 255, RQSkyColor.b / 255, 0.99); |
5704 | 1595 |
|
6394
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
1596 |
// reload everything we had before |
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
1597 |
ReloadCaptions(false); |
6382
0e76c5cd4250
move the order of reloading texture to workaround buggy drivers
koda
parents:
6380
diff
changeset
|
1598 |
ReloadLines; |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
1599 |
StoreLoad(true); |
6394
f0a9042e7387
yay, finally osx (and likely windows) fullscreen switch works like on linux! ALL textures had to be destroyed and recreated only after the new window got created. In other news, the new window must be cleaned with glClear to skip a first frame of garbage and AddProgress is only called the first time.
koda
parents:
6382
diff
changeset
|
1600 |
// redraw all land |
7170
84ac6c6d2d8e
Only create textures for non-empty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents:
7151
diff
changeset
|
1601 |
UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT, false); |
5608
1e5d925dde9d
Attempt to recreate all textures if using Windows or OSX which lose textures on context recreation.
nemo
parents:
5565
diff
changeset
|
1602 |
end; |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4390
diff
changeset
|
1603 |
end; |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4390
diff
changeset
|
1604 |
|
3038 | 1605 |
procedure initModule; |
4925 | 1606 |
var ai: TAmmoType; |
1607 |
i: LongInt; |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
1608 |
begin |
6898 | 1609 |
RegisterVariable('fullscr', @chFullScr, true); |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4390
diff
changeset
|
1610 |
|
7121
ce5e70fe4eb3
http://www.demoties.com/wp-content/uploads/2011/03/mar-01-6.jpg
nemo
parents:
7102
diff
changeset
|
1611 |
cScaleFactor:= 2.0; |
3394
47b51e22e670
Henek's patch - adds a column to ammoMenu and removes the F* column in iphone version
koda
parents:
3390
diff
changeset
|
1612 |
Step:= 0; |
47b51e22e670
Henek's patch - adds a column to ammoMenu and removes the F* column in iphone version
koda
parents:
3390
diff
changeset
|
1613 |
ProgrTex:= nil; |
5660
1647244b3ffe
set gl attributes before creating the window, or some of them might be ignored (like vsync on osx); also don't skip some reloads when switching to fullscreen and back; finally did a little code re-organisation
koda
parents:
5654
diff
changeset
|
1614 |
SupportNPOTT:= false; |
4925 | 1615 |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1616 |
{$IFDEF WEBGL} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1617 |
OpenGLSetupedBefore := false; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1618 |
{$ENDIF} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1619 |
|
4925 | 1620 |
// init all ammo name texture pointers |
1621 |
for ai:= Low(TAmmoType) to High(TAmmoType) do |
|
1622 |
begin |
|
1623 |
Ammoz[ai].NameTex := nil; |
|
1624 |
end; |
|
1625 |
// init all count texture pointers |
|
1626 |
for i:= Low(CountTexz) to High(CountTexz) do |
|
1627 |
CountTexz[i] := nil; |
|
7027 | 1628 |
{$IFDEF SDL13} |
7049 | 1629 |
SDLwindow:= nil; |
1630 |
SDLGLcontext:= nil; |
|
1631 |
{$ELSE} |
|
1632 |
SDLPrimSurface:= nil; |
|
7027 | 1633 |
{$ENDIF} |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
1634 |
end; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2698
diff
changeset
|
1635 |
|
3038 | 1636 |
procedure freeModule; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2705
diff
changeset
|
1637 |
begin |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1638 |
{$IFDEF GL2} |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1639 |
glDeleteProgram(shaderMain); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1640 |
glDeleteProgram(shaderWater); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1641 |
glDeleteBuffers(1, @vBuffer); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1642 |
glDeleteBuffers(1, @tBuffer); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1643 |
glDeleteBuffers(1, @cBuffer); |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7866
diff
changeset
|
1644 |
{$ENDIF} |
7026
8d1724e1337e
split OnDestroy across the appropriate modules (this doen't cause leaks on mobile, right?)
koda
parents:
7013
diff
changeset
|
1645 |
StoreRelease(false); |
8d1724e1337e
split OnDestroy across the appropriate modules (this doen't cause leaks on mobile, right?)
koda
parents:
7013
diff
changeset
|
1646 |
TTF_Quit(); |
8d1724e1337e
split OnDestroy across the appropriate modules (this doen't cause leaks on mobile, right?)
koda
parents:
7013
diff
changeset
|
1647 |
{$IFDEF SDL13} |
8d1724e1337e
split OnDestroy across the appropriate modules (this doen't cause leaks on mobile, right?)
koda
parents:
7013
diff
changeset
|
1648 |
SDL_GL_DeleteContext(SDLGLcontext); |
8d1724e1337e
split OnDestroy across the appropriate modules (this doen't cause leaks on mobile, right?)
koda
parents:
7013
diff
changeset
|
1649 |
SDL_DestroyWindow(SDLwindow); |
8d1724e1337e
split OnDestroy across the appropriate modules (this doen't cause leaks on mobile, right?)
koda
parents:
7013
diff
changeset
|
1650 |
{$ENDIF} |
8d1724e1337e
split OnDestroy across the appropriate modules (this doen't cause leaks on mobile, right?)
koda
parents:
7013
diff
changeset
|
1651 |
SDL_Quit(); |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2705
diff
changeset
|
1652 |
end; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2705
diff
changeset
|
1653 |
|
7049 | 1654 |
procedure WarpMouse(x, y: Word); inline; |
1655 |
begin |
|
1656 |
{$IFDEF SDL13} |
|
1657 |
SDL_WarpMouseInWindow(SDLwindow, x, y); |
|
1658 |
{$ELSE} |
|
1659 |
x:= x; y:= y; // avoid hints |
|
1660 |
{$ENDIF} |
|
1661 |
end; |
|
1662 |
||
7866
58d10edc5d21
apparently we are forced to use a (dummy) callback for glut 3.0 compatibility
koda
parents:
7754
diff
changeset
|
1663 |
procedure SwapBuffers; {$IFDEF USE_VIDEO_RECORDING}cdecl{$ELSE}inline{$ENDIF}; |
7049 | 1664 |
begin |
7180 | 1665 |
if GameType = gmtRecord then |
1666 |
exit; |
|
7049 | 1667 |
{$IFDEF SDL13} |
1668 |
SDL_GL_SwapWindow(SDLwindow); |
|
1669 |
{$ELSE} |
|
1670 |
SDL_GL_SwapBuffers(); |
|
1671 |
{$ENDIF} |
|
1672 |
end; |
|
1673 |
||
4 | 1674 |
end. |