@@ -76,9 +76,13 @@ void CL_GetGlconfig( glconfig_t *glconfig, int size ) {
7676 Com_Memcpy2 ( glconfig , size , & cls .glconfig , sizeof ( glconfig_t ) );
7777
7878#ifdef USE_FLEXIBLE_DISPLAY
79- if ( cl_flexibleDisplay -> integer ) {
79+ if ( cl_flexibleDisplay -> integer
80+ && size >= offsetof( glconfig_t , vidWidth ) + sizeof ( int )
81+ && size >= offsetof( glconfig_t , vidHeight ) + sizeof ( int )
82+ && size >= offsetof( glconfig_t , windowAspect ) + sizeof ( float ) ) {
8083 glconfig -> vidWidth = 640 ;
8184 glconfig -> vidHeight = 480 ;
85+ glconfig -> windowAspect = (float )glconfig -> vidWidth / (float )glconfig -> vidHeight ;
8286 }
8387#endif
8488}
@@ -92,6 +96,25 @@ This is only called if cl_flexibleDisplay is enabled.
9296====================
9397*/
9498void CL_AdjustFromCGame ( float * x , float * y , float * w , float * h ) {
99+ #if 1
100+ int placement ;
101+
102+ if ( cl_viewmode -> integer <= 3 ) {
103+ placement = SCR_VERT_CENTER | SCR_HOR_CENTER ;
104+ } else {
105+ placement = SCR_VERT_STRETCH | SCR_HOR_STRETCH ;
106+ }
107+
108+ // TODO?: Restore expanded HUD for cl_viewmode == 3? Currently it breaks the console and menu.
109+
110+ SCR_SetScreenPlacement ( placement );
111+ SCR_AdjustFrom640 ( x , y , w , h );
112+ #else
113+ #define SCREEN_WIDTH 640
114+ #define SCREEN_HEIGHT 480
115+ #define TINYCHAR_HEIGHT 8
116+ #define BIGCHAR_HEIGHT 16
117+
95118 if ( * y == SCREEN_HEIGHT - 48 && * x == SCREEN_WIDTH - 48 && * w == 48 && * h == 48 ) {
96119 // always treat osp lagometer as new draw (should be fine for baseq3 as well)
97120 cl_drewLagometer = qtrue ;
@@ -173,8 +196,8 @@ void CL_AdjustFromCGame( float *x, float *y, float *w, float *h ) {
173196 placement = SCR_VERT_CENTER | SCR_HOR_CENTER ;
174197 }
175198 // these are very game-specific
176- else if ( cl_conXOffset -> integer && cl_originx + cl_originw <= cl_conXOffset -> integer
177- && cl_originy + cl_originh <= cl_conXOffset -> integer ) {
199+ else if ( cl_originx + cl_originw <= 72
200+ && cl_originy + cl_originh <= 72 ) {
178201 // Team Arena voicechat head
179202 placement = SCR_VERT_TOP | SCR_HOR_LEFT ;
180203 } else if ( * y >= 240 - 16 && * y < 240 + 64 && ( cl_originy > 253 || cl_originx > 128 )
@@ -260,6 +283,7 @@ void CL_AdjustFromCGame( float *x, float *y, float *w, float *h ) {
260283
261284 SCR_SetScreenPlacement ( placement );
262285 SCR_AdjustFrom640 ( x , y , w , h );
286+ #endif
263287}
264288#endif
265289
@@ -1623,6 +1647,7 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
16231647 return 0 ;
16241648 case CG_R_RENDERSCENE :
16251649#ifdef USE_FLEXIBLE_DISPLAY
1650+ #define DF_FIXED_FOV 16
16261651 if ( cl_flexibleDisplay -> integer ) {
16271652 refdef_t fd ;
16281653 float x , y , width , height ;
@@ -1671,6 +1696,46 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
16711696 // restore underwater effect
16721697 fd .fov_y -= water_fov_y ;
16731698 }
1699+
1700+ //
1701+ // weapon fov
1702+ //
1703+
1704+ // find underwater view fov_y offset
1705+ x = 640 / tan ( fd .weapon_fov_x / 360 * M_PI );
1706+ expected_fov_y = atan2 ( 480 , x );
1707+ expected_fov_y = expected_fov_y * 360 / M_PI ;
1708+
1709+ water_fov_y = expected_fov_y - fd .weapon_fov_y ;
1710+
1711+ if ( cl_viewmode -> integer == 5 || ( clc .dmflags & DF_FIXED_FOV ) ) {
1712+ // stretch fov
1713+ // this is common for 4:3 video mode on a widescreen monitor.
1714+ } else if ( cl_viewmode -> integer <= 4 ) {
1715+ // apply underwater effect after fov change
1716+ // this doesn't matter much but it matches setting cg_fov manually
1717+ // without cl_flexibleDisplay
1718+ fd .weapon_fov_x -= water_fov_y ;
1719+
1720+ // Based on LordHavoc's code for Darkplaces
1721+ // http://www.quakeworld.nu/forum/topic/53/what-does-your-qw-look-like/page/30
1722+ const float baseAspect = 0.75f ; // 3/4
1723+ const float aspect = (float )fd .width /(float )fd .height ;
1724+ const float desiredFov = fd .weapon_fov_x ;
1725+
1726+ fd .weapon_fov_x = atan ( tan ( desiredFov * M_PI / 360.0f ) * baseAspect * aspect )* 360.0f / M_PI ;
1727+
1728+ fd .weapon_fov_x += water_fov_y ;
1729+ } else {
1730+ // use vert- to match original Quake 3 widescreen
1731+ // find vert- fov_y
1732+ x = fd .width / tan ( fd .weapon_fov_x / 360 * M_PI );
1733+ fd .weapon_fov_y = atan2 ( fd .height , x );
1734+ fd .weapon_fov_y = fd .weapon_fov_y * 360 / M_PI ;
1735+
1736+ // restore underwater effect
1737+ fd .weapon_fov_y -= water_fov_y ;
1738+ }
16741739 } else {
16751740 x = fd .x ;
16761741 y = fd .y ;
@@ -1719,17 +1784,17 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
17191784 if ( cl_viewmode -> integer <= 3 ) {
17201785 float value ;
17211786
1722- if ( x + width > SCREEN_WIDTH ) {
1723- value = SCREEN_WIDTH - x ;
1787+ if ( x + width > 640 ) {
1788+ value = 640 - x ;
17241789 if ( value < 0 ) {
17251790 value = 0 ;
17261791 }
17271792 s1 = ( s1 - s0 ) * ( value / width ) + s0 ;
17281793 width = value ;
17291794 }
17301795 // clamp other sides as well
1731- if ( y + height > SCREEN_HEIGHT ) {
1732- value = SCREEN_HEIGHT - y ;
1796+ if ( y + height > 480 ) {
1797+ value = 480 - y ;
17331798 if ( value < 0 ) {
17341799 value = 0 ;
17351800 }
0 commit comments