53 procedure RenderHealth(var Hedgehog: THedgehog); |
53 procedure RenderHealth(var Hedgehog: THedgehog); |
54 procedure AddProgress; |
54 procedure AddProgress; |
55 procedure FinishProgress; |
55 procedure FinishProgress; |
56 function LoadImage(const filename: string; hasAlpha, critical, setTransparent: boolean): PSDL_Surface; |
56 function LoadImage(const filename: string; hasAlpha, critical, setTransparent: boolean): PSDL_Surface; |
57 procedure SetupOpenGL; |
57 procedure SetupOpenGL; |
|
58 procedure SetScale(f: GLfloat); |
|
59 |
58 |
60 |
59 var PixelFormat: PSDL_PixelFormat = nil; |
61 var PixelFormat: PSDL_PixelFormat = nil; |
60 SDLPrimSurface: PSDL_Surface = nil; |
62 SDLPrimSurface: PSDL_Surface = nil; |
61 PauseTexture, |
63 PauseTexture, |
62 ConfirmTexture: PTexture; |
64 ConfirmTexture: PTexture; |
|
65 cScaleFactor: GLfloat = 2.0; |
63 |
66 |
64 implementation |
67 implementation |
65 uses uMisc, uConsole, uLand, uLocale; |
68 uses uMisc, uConsole, uLand, uLocale, uWorld; |
66 |
69 |
67 var |
70 var |
68 HHTexture: PTexture; |
71 HHTexture: PTexture; |
69 MaxTextureSize: Integer; |
72 MaxTextureSize: Integer; |
70 |
73 |
908 LoadImage:= tmpsurf //Result |
911 LoadImage:= tmpsurf //Result |
909 end; |
912 end; |
910 |
913 |
911 procedure SetupOpenGL; |
914 procedure SetupOpenGL; |
912 begin |
915 begin |
913 glLoadIdentity; |
916 SetScale(2.0); |
914 glViewport(0, 0, cScreenWidth, cScreenHeight); |
|
915 glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); |
|
916 glTranslatef(-cScreenWidth / 2, -cScreenHeight / 2, 0); |
|
917 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
917 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
918 glMatrixMode(GL_MODELVIEW); |
918 glMatrixMode(GL_MODELVIEW); |
919 |
919 |
920 glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize); |
920 glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize); |
921 {$IFDEF DEBUGFILE} |
921 {$IFDEF DEBUGFILE} |
922 AddFileLog('GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize)); |
922 AddFileLog('GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize)); |
923 {$ENDIF} |
923 {$ENDIF} |
|
924 end; |
|
925 |
|
926 procedure SetScale(f: GLfloat); |
|
927 begin |
|
928 cScaleFactor:= f; |
|
929 cWaterSprCount:= 1 + round(cScreenWidth * 2 / cScaleFactor / SpritesData[sprWater].Width); |
|
930 |
|
931 glLoadIdentity; |
|
932 glViewport(0, 0, cScreenWidth, cScreenHeight); |
|
933 glScalef(f / cScreenWidth, -f / cScreenHeight, 1.0); |
|
934 //glTranslatef(-cScreenWidth / 2, -cScreenHeight / 2, 0); |
|
935 glTranslatef(0, -cScreenHeight / 2, 0); |
924 end; |
936 end; |
925 |
937 |
926 //////////////////////////////////////////////////////////////////////////////// |
938 //////////////////////////////////////////////////////////////////////////////// |
927 var ProgrTex: PTexture = nil; |
939 var ProgrTex: PTexture = nil; |
928 Step: integer = 0; |
940 Step: integer = 0; |
943 glEnable(GL_TEXTURE_2D); |
955 glEnable(GL_TEXTURE_2D); |
944 r.x:= 0; |
956 r.x:= 0; |
945 r.w:= ProgrTex^.w; |
957 r.w:= ProgrTex^.w; |
946 r.h:= ProgrTex^.w; |
958 r.h:= ProgrTex^.w; |
947 r.y:= (Step mod (ProgrTex^.h div ProgrTex^.w)) * ProgrTex^.w; |
959 r.y:= (Step mod (ProgrTex^.h div ProgrTex^.w)) * ProgrTex^.w; |
948 DrawFromRect((cScreenWidth - ProgrTex^.w) div 2, |
960 DrawFromRect( -ProgrTex^.w div 2, |
949 (cScreenHeight - ProgrTex^.w) div 2, @r, ProgrTex); |
961 (cScreenHeight - ProgrTex^.w) div 2, @r, ProgrTex); |
950 glDisable(GL_TEXTURE_2D); |
962 glDisable(GL_TEXTURE_2D); |
951 SDL_GL_SwapBuffers(); |
963 SDL_GL_SwapBuffers(); |
952 inc(Step); |
964 inc(Step); |
953 end; |
965 end; |