34 procedure RenderHealth(var Hedgehog: THedgehog); |
34 procedure RenderHealth(var Hedgehog: THedgehog); |
35 procedure AddProgress; |
35 procedure AddProgress; |
36 procedure FinishProgress; |
36 procedure FinishProgress; |
37 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
37 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
38 |
38 |
39 // loads an image from the game's data files |
39 // loads an image from the games data files |
40 function LoadDataImage(const path: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
40 function LoadDataImage(const path: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
41 // like LoadDataImage but uses altPath as fallback-path if file not found/loadable in path |
41 // like LoadDataImage but uses altPath as fallback-path if file not found/loadable in path |
42 function LoadDataImageAltPath(const path, altPath: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
42 function LoadDataImageAltPath(const path, altPath: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
43 // like LoadDataImage but uses altFile as fallback-filename if file cannot be loaded |
43 // like LoadDataImage but uses altFile as fallback-filename if file cannot be loaded |
44 function LoadDataImageAltFile(const path: TPathType; const filename, altFile: shortstring; imageFlags: LongInt): PSDL_Surface; |
44 function LoadDataImageAltFile(const path: TPathType; const filename, altFile: shortstring; imageFlags: LongInt): PSDL_Surface; |
68 procedure SetColorPointer(p: Pointer;n: Integer); |
68 procedure SetColorPointer(p: Pointer;n: Integer); |
69 procedure BeginWater; |
69 procedure BeginWater; |
70 procedure EndWater; |
70 procedure EndWater; |
71 |
71 |
72 implementation |
72 implementation |
73 uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands |
73 uses uMisc, uConsole, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands |
74 , uPhysFSLayer |
74 , uPhysFSLayer |
75 , uDebug |
75 , uDebug |
76 {$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF} |
76 {$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF} |
77 {$IF NOT DEFINED(SDL13) AND DEFINED(USE_VIDEO_RECORDING)}, glut {$ENDIF}; |
77 {$IF NOT DEFINED(SDL13) AND DEFINED(USE_VIDEO_RECORDING)}, glut {$ENDIF}; |
78 |
78 |
217 if (Gear <> nil) and (BotLevel > 0) then |
224 if (Gear <> nil) and (BotLevel > 0) then |
218 begin |
225 begin |
219 foundBot:= true; |
226 foundBot:= true; |
220 // initially was going to do the highest botlevel of the team, but for now, just apply if entire team has same bot level |
227 // initially was going to do the highest botlevel of the team, but for now, just apply if entire team has same bot level |
221 if maxLevel = -1 then maxLevel:= BotLevel |
228 if maxLevel = -1 then maxLevel:= BotLevel |
222 else if (maxLevel > 0) and (maxLevel <> BotLevel) then maxLevel:= 0; |
229 else if (maxLevel > 0) and (maxLevel <> BotLevel) then maxLevel:= 0; |
223 //if (maxLevel > 0) and (BotLevel < maxLevel) then maxLevel:= BotLevel |
230 //if (maxLevel > 0) and (BotLevel < maxLevel) then maxLevel:= BotLevel |
224 end |
231 end |
225 else if Gear <> nil then maxLevel:= 0; |
232 else if Gear <> nil then maxLevel:= 0; |
226 |
233 |
227 if foundBot then |
234 if foundBot then |
228 begin |
235 begin |
229 // disabled the plain flag - I think it looks ok even w/ full bars obscuring CPU |
236 // disabled the plain flag - I think it looks ok even w/ full bars obscuring CPU |
230 //if (maxLevel > 0) and (maxLevel < 3) then Flag:= 'cpu_plain' else |
237 //if (maxLevel > 0) and (maxLevel < 3) then Flag:= 'cpu_plain' else |
231 Flag:= 'cpu' |
238 Flag:= 'cpu' |
232 end |
239 end |
233 else if (Flag = 'cpu') or (Flag = 'cpu_plain') then |
240 else if (Flag = 'cpu') or (Flag = 'cpu_plain') then |
234 Flag:= 'hedgewars'; |
241 Flag:= 'hedgewars'; |
235 |
242 |
236 flagsurf:= LoadDataImageAltFile(ptFlags, Flag, 'hedgewars', ifNone); |
243 flagsurf:= LoadDataImageAltFile(ptFlags, Flag, 'hedgewars', ifNone); |
237 TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true); |
244 TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true); |
238 |
245 |
239 case maxLevel of |
246 case maxLevel of |
240 1: copyToXY(SpritesData[sprBotlevels].Surface, flagsurf, 0, 0); |
247 1: copyToXY(SpritesData[sprBotlevels].Surface, flagsurf, 0, 0); |
241 2: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 5, 2, 17, 13, 5, 2); |
248 2: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 5, 2, 17, 13, 5, 2); |
242 3: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 9, 5, 13, 10, 9, 5); |
249 3: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 9, 5, 13, 10, 9, 5); |
243 4: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 13, 9, 9, 6, 13, 9); |
250 4: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 13, 9, 9, 6, 13, 9); |
244 5: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 17, 11, 5, 4, 17, 11) |
251 5: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 17, 11, 5, 4, 17, 11) |
245 end; |
252 end; |
246 |
253 |
247 copyToXY(flagsurf, texsurf, 2, 2); |
254 copyToXY(flagsurf, texsurf, 2, 2); |
248 SDL_FreeSurface(flagsurf); |
255 SDL_FreeSurface(flagsurf); |
462 IMG_Quit(); |
469 IMG_Quit(); |
463 |
470 |
464 WriteLnToConsole('Leaving StoreLoad'); |
471 WriteLnToConsole('Leaving StoreLoad'); |
465 end; |
472 end; |
466 |
473 |
467 {$IF NOT DEFINED(S3D_DISABLED) OR DEFINED(USE_VIDEO_RECORDING)} |
474 {$IF DEFINED(USE_S3D_RENDERING) OR DEFINED(USE_VIDEO_RECORDING)} |
468 procedure CreateFramebuffer(var frame, depth, tex: GLuint); |
475 procedure CreateFramebuffer(var frame, depth, tex: GLuint); |
469 begin |
476 begin |
470 glGenFramebuffersEXT(1, @frame); |
477 glGenFramebuffersEXT(1, @frame); |
471 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frame); |
478 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frame); |
472 glGenRenderbuffersEXT(1, @depth); |
479 glGenRenderbuffersEXT(1, @depth); |
564 end; |
571 end; |
565 {$IFDEF USE_VIDEO_RECORDING} |
572 {$IFDEF USE_VIDEO_RECORDING} |
566 if defaultFrame <> 0 then |
573 if defaultFrame <> 0 then |
567 DeleteFramebuffer(defaultFrame, depthv, texv); |
574 DeleteFramebuffer(defaultFrame, depthv, texv); |
568 {$ENDIF} |
575 {$ENDIF} |
569 {$IFNDEF S3D_DISABLED} |
576 {$IFDEF USE_S3D_RENDERING} |
570 if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then |
577 if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then |
571 begin |
578 begin |
572 DeleteFramebuffer(framel, depthl, texl); |
579 DeleteFramebuffer(framel, depthl, texl); |
573 DeleteFramebuffer(framer, depthr, texr); |
580 DeleteFramebuffer(framer, depthr, texr); |
574 end |
581 end |
1015 hglLoadIdentity(); |
1022 hglLoadIdentity(); |
1016 hglScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); |
1023 hglScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); |
1017 hglTranslatef(0, -cScreenHeight / 2, 0); |
1024 hglTranslatef(0, -cScreenHeight / 2, 0); |
1018 |
1025 |
1019 EnableTexture(True); |
1026 EnableTexture(True); |
1020 |
1027 |
1021 glEnableVertexAttribArray(aVertex); |
1028 glEnableVertexAttribArray(aVertex); |
1022 glEnableVertexAttribArray(aTexCoord); |
1029 glEnableVertexAttribArray(aTexCoord); |
1023 glGenBuffers(1, @vBuffer); |
1030 glGenBuffers(1, @vBuffer); |
1024 glGenBuffers(1, @tBuffer); |
1031 glGenBuffers(1, @tBuffer); |
1025 glGenBuffers(1, @cBuffer); |
1032 glGenBuffers(1, @cBuffer); |
1201 ProgrTex:= Surface2Tex(texsurf, false); |
1208 ProgrTex:= Surface2Tex(texsurf, false); |
1202 |
1209 |
1203 squaresize:= texsurf^.w shr 1; |
1210 squaresize:= texsurf^.w shr 1; |
1204 numsquares:= texsurf^.h div squaresize; |
1211 numsquares:= texsurf^.h div squaresize; |
1205 SDL_FreeSurface(texsurf); |
1212 SDL_FreeSurface(texsurf); |
1206 |
1213 with mobileRecord do |
1207 uMobile.GameLoading(); |
1214 if GameLoading <> nil then |
|
1215 GameLoading(); |
|
1216 |
1208 end; |
1217 end; |
1209 |
1218 |
1210 TryDo(ProgrTex <> nil, 'Error - Progress Texure is nil!', true); |
1219 TryDo(ProgrTex <> nil, 'Error - Progress Texure is nil!', true); |
1211 |
1220 |
1212 glClear(GL_COLOR_BUFFER_BIT); |
1221 glClear(GL_COLOR_BUFFER_BIT); |
1562 begin |
1573 begin |
1563 // clean the window from any previous content |
1574 // clean the window from any previous content |
1564 glClear(GL_COLOR_BUFFER_BIT); |
1575 glClear(GL_COLOR_BUFFER_BIT); |
1565 if SuddenDeathDmg then |
1576 if SuddenDeathDmg then |
1566 glClearColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255, 0.99) |
1577 glClearColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255, 0.99) |
1567 else if ((cReducedQuality and rqNoBackground) = 0) then |
1578 else if ((cReducedQuality and rqNoBackground) = 0) then |
1568 glClearColor(SkyColor.r / 255, SkyColor.g / 255, SkyColor.b / 255, 0.99) |
1579 glClearColor(SkyColor.r / 255, SkyColor.g / 255, SkyColor.b / 255, 0.99) |
1569 else |
1580 else |
1570 glClearColor(RQSkyColor.r / 255, RQSkyColor.g / 255, RQSkyColor.b / 255, 0.99); |
1581 glClearColor(RQSkyColor.r / 255, RQSkyColor.g / 255, RQSkyColor.b / 255, 0.99); |
1571 |
1582 |
1572 // reload everything we had before |
1583 // reload everything we had before |