branch | flibqtfrontend |
changeset 8208 | 171da01bd04d |
parent 8204 | 9a6030d96273 |
child 8309 | edcfb5e43245 |
8141:6482875b0d97 | 8208:171da01bd04d |
---|---|
31 procedure RenderHealth(var Hedgehog: THedgehog); |
31 procedure RenderHealth(var Hedgehog: THedgehog); |
32 procedure AddProgress; |
32 procedure AddProgress; |
33 procedure FinishProgress; |
33 procedure FinishProgress; |
34 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
34 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
35 |
35 |
36 // loads an image from the game's data files |
36 // loads an image from the games data files |
37 function LoadDataImage(const path: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
37 function LoadDataImage(const path: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
38 // like LoadDataImage but uses altPath as fallback-path if file not found/loadable in path |
38 // like LoadDataImage but uses altPath as fallback-path if file not found/loadable in path |
39 function LoadDataImageAltPath(const path, altPath: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
39 function LoadDataImageAltPath(const path, altPath: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
40 // like LoadDataImage but uses altFile as fallback-filename if file cannot be loaded |
40 // like LoadDataImage but uses altFile as fallback-filename if file cannot be loaded |
41 function LoadDataImageAltFile(const path: TPathType; const filename, altFile: shortstring; imageFlags: LongInt): PSDL_Surface; |
41 function LoadDataImageAltFile(const path: TPathType; const filename, altFile: shortstring; imageFlags: LongInt): PSDL_Surface; |
54 |
54 |
55 procedure WarpMouse(x, y: Word); inline; |
55 procedure WarpMouse(x, y: Word); inline; |
56 procedure SwapBuffers; {$IFDEF USE_VIDEO_RECORDING}cdecl{$ELSE}inline{$ENDIF}; |
56 procedure SwapBuffers; {$IFDEF USE_VIDEO_RECORDING}cdecl{$ELSE}inline{$ENDIF}; |
57 |
57 |
58 implementation |
58 implementation |
59 uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands |
59 uses uMisc, uConsole, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands |
60 , uPhysFSLayer |
60 , uPhysFSLayer |
61 , uDebug |
61 , uDebug |
62 {$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF} |
62 {$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF} |
63 {$IF NOT DEFINED(SDL13) AND DEFINED(USE_VIDEO_RECORDING)}, glut {$ENDIF}; |
63 {$IF NOT DEFINED(SDL13) AND DEFINED(USE_VIDEO_RECORDING)}, glut {$ENDIF}; |
64 |
64 |
69 SDLwindow: PSDL_Window; |
69 SDLwindow: PSDL_Window; |
70 SDLGLcontext: PSDL_GLContext; |
70 SDLGLcontext: PSDL_GLContext; |
71 {$ELSE} |
71 {$ELSE} |
72 SDLPrimSurface: PSDL_Surface; |
72 SDLPrimSurface: PSDL_Surface; |
73 {$ENDIF} |
73 {$ENDIF} |
74 squaresize : LongInt; |
|
75 numsquares : LongInt; |
|
76 ProgrTex: PTexture; |
|
77 |
|
78 const |
|
79 cHHFileName = 'Hedgehog'; |
|
80 cCHFileName = 'Crosshair'; |
|
74 |
81 |
75 function WriteInRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect; |
82 function WriteInRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect; |
76 var w, h: LongInt; |
83 var w, h: LongInt; |
77 tmpsurf: PSDL_Surface; |
84 tmpsurf: PSDL_Surface; |
78 clr: TSDL_Color; |
85 clr: TSDL_Color; |
435 if not reload then |
442 if not reload then |
436 AddProgress; |
443 AddProgress; |
437 IMG_Quit(); |
444 IMG_Quit(); |
438 end; |
445 end; |
439 |
446 |
440 {$IF NOT DEFINED(S3D_DISABLED) OR DEFINED(USE_VIDEO_RECORDING)} |
447 {$IF DEFINED(USE_S3D_RENDERING) OR DEFINED(USE_VIDEO_RECORDING)} |
441 procedure CreateFramebuffer(var frame, depth, tex: GLuint); |
448 procedure CreateFramebuffer(var frame, depth, tex: GLuint); |
442 begin |
449 begin |
443 glGenFramebuffersEXT(1, @frame); |
450 glGenFramebuffersEXT(1, @frame); |
444 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frame); |
451 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frame); |
445 glGenRenderbuffersEXT(1, @depth); |
452 glGenRenderbuffersEXT(1, @depth); |
537 end; |
544 end; |
538 {$IFDEF USE_VIDEO_RECORDING} |
545 {$IFDEF USE_VIDEO_RECORDING} |
539 if defaultFrame <> 0 then |
546 if defaultFrame <> 0 then |
540 DeleteFramebuffer(defaultFrame, depthv, texv); |
547 DeleteFramebuffer(defaultFrame, depthv, texv); |
541 {$ENDIF} |
548 {$ENDIF} |
542 {$IFNDEF S3D_DISABLED} |
549 {$IFDEF USE_S3D_RENDERING} |
543 if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then |
550 if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then |
544 begin |
551 begin |
545 DeleteFramebuffer(framel, depthl, texl); |
552 DeleteFramebuffer(framel, depthl, texl); |
546 DeleteFramebuffer(framer, depthr, texr); |
553 DeleteFramebuffer(framer, depthr, texr); |
547 end |
554 end |
803 AddFileLog('Warning: off-screen rendering is not supported; using back buffer but it may not work.'); |
810 AddFileLog('Warning: off-screen rendering is not supported; using back buffer but it may not work.'); |
804 end; |
811 end; |
805 end; |
812 end; |
806 {$ENDIF} |
813 {$ENDIF} |
807 |
814 |
808 {$IFNDEF S3D_DISABLED} |
815 {$IFDEF USE_S3D_RENDERING} |
809 if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then |
816 if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then |
810 begin |
817 begin |
811 // prepare left and right frame buffers and associated textures |
818 // prepare left and right frame buffers and associated textures |
812 if glLoadExtension('GL_EXT_framebuffer_object') then |
819 if glLoadExtension('GL_EXT_framebuffer_object') then |
813 begin |
820 begin |
877 ProgrTex:= Surface2Tex(texsurf, false); |
884 ProgrTex:= Surface2Tex(texsurf, false); |
878 |
885 |
879 squaresize:= texsurf^.w shr 1; |
886 squaresize:= texsurf^.w shr 1; |
880 numsquares:= texsurf^.h div squaresize; |
887 numsquares:= texsurf^.h div squaresize; |
881 SDL_FreeSurface(texsurf); |
888 SDL_FreeSurface(texsurf); |
882 |
889 with mobileRecord do |
883 uMobile.GameLoading(); |
890 if GameLoading <> nil then |
891 GameLoading(); |
|
892 |
|
884 end; |
893 end; |
885 |
894 |
886 TryDo(ProgrTex <> nil, 'Error - Progress Texure is nil!', true); |
895 TryDo(ProgrTex <> nil, 'Error - Progress Texure is nil!', true); |
887 |
896 |
888 glClear(GL_COLOR_BUFFER_BIT); |
897 glClear(GL_COLOR_BUFFER_BIT); |
901 inc(Step); |
910 inc(Step); |
902 end; |
911 end; |
903 |
912 |
904 procedure FinishProgress; |
913 procedure FinishProgress; |
905 begin |
914 begin |
906 uMobile.GameLoaded(); |
915 with mobileRecord do |
916 if GameLoaded <> nil then |
|
917 GameLoaded(); |
|
907 WriteLnToConsole('Freeing progress surface... '); |
918 WriteLnToConsole('Freeing progress surface... '); |
908 FreeTexture(ProgrTex); |
919 FreeTexture(ProgrTex); |
909 ProgrTex:= nil; |
920 ProgrTex:= nil; |
910 Step:= 0 |
921 Step:= 0 |
911 end; |
922 end; |