changeset 7082 | 17b0892ac794 |
parent 7049 | 35d762458d66 |
child 7084 | a471de309dcc |
7080:dbf43c07a507 | 7082:17b0892ac794 |
---|---|
41 procedure FreeWeaponTooltip; |
41 procedure FreeWeaponTooltip; |
42 procedure MakeCrossHairs; |
42 procedure MakeCrossHairs; |
43 |
43 |
44 procedure WarpMouse(x, y: Word); inline; |
44 procedure WarpMouse(x, y: Word); inline; |
45 procedure SwapBuffers; inline; |
45 procedure SwapBuffers; inline; |
46 procedure UpdateProjection; |
|
46 |
47 |
47 implementation |
48 implementation |
48 uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands, |
49 uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands, |
49 uDebug{$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF}; |
50 uDebug{$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF}; |
50 |
51 |
727 // set view port to whole window |
728 // set view port to whole window |
728 glViewport(0, 0, cScreenWidth, cScreenHeight); |
729 glViewport(0, 0, cScreenWidth, cScreenHeight); |
729 |
730 |
730 glMatrixMode(GL_MODELVIEW); |
731 glMatrixMode(GL_MODELVIEW); |
731 // prepare default translation/scaling |
732 // prepare default translation/scaling |
732 glLoadIdentity(); |
733 SetScale(2.0); |
733 glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); |
|
734 glTranslatef(0, -cScreenHeight / 2, 0); |
|
735 |
734 |
736 // enable alpha blending |
735 // enable alpha blending |
737 glEnable(GL_BLEND); |
736 glEnable(GL_BLEND); |
738 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
737 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
739 // disable/lower perspective correction (will not need it anyway) |
738 // disable/lower perspective correction (will not need it anyway) |
744 glEnable(GL_TEXTURE_2D); |
743 glEnable(GL_TEXTURE_2D); |
745 glEnableClientState(GL_VERTEX_ARRAY); |
744 glEnableClientState(GL_VERTEX_ARRAY); |
746 glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
745 glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
747 end; |
746 end; |
748 |
747 |
748 procedure UpdateProjection; |
|
749 var mat: array[0..15] of GLfloat; |
|
750 s: GLfloat; |
|
751 begin |
|
752 s:=cScaleFactor; |
|
753 glMatrixMode(GL_PROJECTION); |
|
754 mat[ 0]:= s/cScreenWidth; mat[ 1]:= 0.0; mat[ 2]:=0.0; mat[ 3]:= 0.0; |
|
755 mat[ 4]:= 0.0; mat[ 5]:= -s/cScreenHeight; mat[ 6]:=0.0; mat[ 7]:= 0.0; |
|
756 mat[ 8]:= 0.0; mat[ 9]:= 0.0; mat[10]:=1.0; mat[11]:= 0.0; |
|
757 mat[12]:= cStereoDepth; mat[13]:= s/2; mat[14]:=0.0; mat[15]:= 1.0; |
|
758 glLoadMatrixf(@mat); |
|
759 glMatrixMode(GL_MODELVIEW); |
|
760 end; |
|
761 |
|
749 procedure SetScale(f: GLfloat); |
762 procedure SetScale(f: GLfloat); |
750 begin |
763 begin |
751 // leave immediately if scale factor did not change |
764 cScaleFactor:=f; |
752 if f = cScaleFactor then |
765 UpdateProjection; |
753 exit; |
|
754 |
|
755 if f = cDefaultZoomLevel then |
|
756 glPopMatrix // "return" to default scaling |
|
757 else // other scaling |
|
758 begin |
|
759 glPushMatrix; // save default scaling |
|
760 glLoadIdentity; |
|
761 glScalef(f / cScreenWidth, -f / cScreenHeight, 1.0); |
|
762 glTranslatef(0, -cScreenHeight / 2, 0); |
|
763 end; |
|
764 |
|
765 cScaleFactor:= f; |
|
766 end; |
766 end; |
767 |
767 |
768 //////////////////////////////////////////////////////////////////////////////// |
768 //////////////////////////////////////////////////////////////////////////////// |
769 procedure AddProgress; |
769 procedure AddProgress; |
770 var r: TSDL_Rect; |
770 var r: TSDL_Rect; |
1031 AmmoMenuInvalidated:= true; |
1031 AmmoMenuInvalidated:= true; |
1032 {$IFDEF IPHONEOS} |
1032 {$IFDEF IPHONEOS} |
1033 // chFullScr is called when there is a rotation event and needs the SetScale and SetupOpenGL to set up the new resolution |
1033 // chFullScr is called when there is a rotation event and needs the SetScale and SetupOpenGL to set up the new resolution |
1034 // this 6 gl functions are the relevant ones and are hacked together here for optimisation |
1034 // this 6 gl functions are the relevant ones and are hacked together here for optimisation |
1035 glMatrixMode(GL_MODELVIEW); |
1035 glMatrixMode(GL_MODELVIEW); |
1036 glPopMatrix; |
1036 SetScale(2.0); |
1037 glLoadIdentity(); |
|
1038 glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); |
|
1039 glTranslatef(0, -cScreenHeight / 2, 0); |
|
1040 glViewport(0, 0, cScreenWidth, cScreenHeight); |
|
1041 exit; |
1037 exit; |
1042 {$ELSE} |
1038 {$ELSE} |
1043 SetScale(cDefaultZoomLevel); |
1039 SetScale(cDefaultZoomLevel); |
1044 {$IFDEF USE_CONTEXT_RESTORE} |
1040 {$IFDEF USE_CONTEXT_RESTORE} |
1045 reinit:= true; |
1041 reinit:= true; |