Skip to content

Commit 47beea0

Browse files
committed
spearmint: Clean up (unused) cl_flexibleDisplay
1 parent 333b5dc commit 47beea0

4 files changed

Lines changed: 94 additions & 18 deletions

File tree

code/client/cl_cgame.c

Lines changed: 72 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
9498
void 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
}

code/client/cl_main.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3267,15 +3267,13 @@ void CL_DrawLoadingScreen( void ) {
32673267
}
32683268
}
32693269

3270+
#ifdef USE_FLEXIBLE_DISPLAY
32703271
/*
32713272
============
32723273
CL_WindowResized
32733274
============
32743275
*/
3275-
void CL_WindowResized( int width, int height ) {
3276-
cls.glconfig.vidWidth = width;
3277-
cls.glconfig.vidHeight = height;
3278-
3276+
void CL_WindowResized( void ) {
32793277
//
32803278
// Scaling factors and offsets for SCR_AdjustFrom640()
32813279
//
@@ -3300,6 +3298,7 @@ void CL_WindowResized( int width, int height ) {
33003298
cls.screenXBias = 0;
33013299
}
33023300
}
3301+
#endif
33033302

33043303
/*
33053304
============
@@ -3315,9 +3314,9 @@ void CL_InitRenderer( void ) {
33153314
#ifdef USE_FLEXIBLE_DISPLAY
33163315
// update latched value at vid_restart
33173316
cl_flexibleDisplay = Cvar_Get ("cl_flexibleDisplay", "1", CVAR_ARCHIVE | CVAR_LATCH);
3318-
#endif
33193317

3320-
CL_WindowResized( cls.glconfig.vidWidth, cls.glconfig.vidHeight );
3318+
CL_WindowResized();
3319+
#endif
33213320

33223321
// draw loading screen when the game is starting up
33233322
if (!cls.drawnLoadingScreen) {
@@ -3335,7 +3334,9 @@ void CL_GlconfigChanged( const glconfig_t *glconfig ) {
33353334
cls.glconfig = *glconfig;
33363335
CL_UpdateGlconfig();
33373336

3338-
CL_WindowResized( cls.glconfig.vidWidth, cls.glconfig.vidHeight );
3337+
#ifdef USE_FLEXIBLE_DISPLAY
3338+
CL_WindowResized();
3339+
#endif
33393340
}
33403341

33413342
/*
@@ -3574,6 +3575,8 @@ static void CL_PrintViewMode( void ) {
35743575
}
35753576
}
35763577

3578+
extern void CL_GameCommand( void );
3579+
35773580
/*
35783581
=================
35793582
CL_SizeDown_f
@@ -3593,8 +3596,8 @@ static void CL_SizeUp_f (void) {
35933596
}
35943597
} else {
35953598
// run command in cgame
3596-
if ( com_cl_running && com_cl_running->integer && CL_GameCommand() ) {
3597-
return;
3599+
if ( com_cl_running && com_cl_running->integer ) {
3600+
CL_GameCommand();
35983601
}
35993602
}
36003603
}
@@ -3614,8 +3617,8 @@ static void CL_SizeDown_f (void) {
36143617
}
36153618
} else {
36163619
// run command in cgame
3617-
if ( com_cl_running && com_cl_running->integer && CL_GameCommand() ) {
3618-
return;
3620+
if ( com_cl_running && com_cl_running->integer ) {
3621+
CL_GameCommand();
36193622
}
36203623
}
36213624
}

code/client/cl_scrn.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,18 @@ Suite 120, Rockville, Maryland 20850 USA.
3232
#include "client.h"
3333

3434
qboolean scr_initialized; // ready to draw
35+
#ifdef USE_FLEXIBLE_DISPLAY
3536
int scr_placement;
3637
float scr_nativeScale = 1.0f;
38+
#endif
3739

3840
cvar_t *cl_timegraph;
3941
cvar_t *cl_debuggraph;
4042
cvar_t *cl_graphheight;
4143
cvar_t *cl_graphscale;
4244
cvar_t *cl_graphshift;
4345

46+
#ifdef USE_FLEXIBLE_DISPLAY
4447
/*
4548
================
4649
SCR_SetScreenPlacement
@@ -224,6 +227,7 @@ void SCR_AdjustTo640( float *x, float *y, float *w, float *h ) {
224227
}
225228
}
226229
}
230+
#endif
227231

228232

229233

code/client/client.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,15 @@ typedef struct {
374374
qboolean drawnLoadingScreen;
375375
qhandle_t whiteShader;
376376

377+
#ifdef USE_FLEXIBLE_DISPLAY
377378
// for scaling from 640x480
378379
float screenXScaleStretch;
379380
float screenYScaleStretch;
380381
float screenXScale;
381382
float screenYScale;
382383
float screenXBias;
383384
float screenYBias;
385+
#endif
384386
} clientStatic_t;
385387

386388
extern clientStatic_t cls;
@@ -589,6 +591,7 @@ void SCR_UpdateScreen (void);
589591

590592
void SCR_DebugGraph (float value);
591593

594+
#ifdef USE_FLEXIBLE_DISPLAY
592595
// horizontal and vertical alignment flags
593596
// for SCR_SetScreenPlacement() / SCR_AdjustFrom640()
594597
#define SCR_HOR_CENTER 0x01
@@ -609,6 +612,7 @@ void SCR_SetScreenPlacement( int placement );
609612
void SCR_SetNativeScale( float scale );
610613
void SCR_AdjustFrom640( float *x, float *y, float *w, float *h );
611614
void SCR_AdjustTo640( float *x, float *y, float *w, float *h );
615+
#endif
612616

613617

614618
//

0 commit comments

Comments
 (0)