Skip to content

Commit

Permalink
Merge pull request #609 from w23/vulkan-upstream-merge-20231017
Browse files Browse the repository at this point in the history
Merge from upstream
  • Loading branch information
w23 authored Oct 17, 2023
2 parents 2f365b7 + bd07444 commit 2f7b9d5
Show file tree
Hide file tree
Showing 38 changed files with 2,762 additions and 405 deletions.
5 changes: 4 additions & 1 deletion engine/client/cl_efx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1236,12 +1236,15 @@ R_BloodStream
particle spray 2
===============
*/
void GAME_EXPORT R_BloodStream( const vec3_t org, const vec3_t dir, int pcolor, int speed )
void GAME_EXPORT R_BloodStream( const vec3_t org, const vec3_t ndir, int pcolor, int speed )
{
particle_t *p;
int i, j;
float arc;
int accel = speed; // must be integer due to bug in GoldSrc
vec3_t dir;

VectorNormalize2( ndir, dir );

for( arc = 0.05f, i = 0; i < 100; i++ )
{
Expand Down
2 changes: 1 addition & 1 deletion engine/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2341,7 +2341,7 @@ void CL_ReadPackets( void )
// decide the simulation time
cl.oldtime = cl.time;

if( cls.demoplayback != DEMO_XASH3D && !cl.paused )
if( !cl.paused )
cl.time += host.frametime;

// demo time
Expand Down
12 changes: 11 additions & 1 deletion engine/client/cl_parse_48.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,18 @@ void CL_LegacyParseResourceList( sizebuf_t *msg )
}

if( CL_IsPlaybackDemo() )
{
return;

if( !cl_allow_download.value )
{
Con_DPrintf( "Refusing new resource, cl_allow_download set to 0\n" );
reslist.rescount = 0;
}

if( cls.state == ca_active && !cl_download_ingame.value )
{
Con_DPrintf( "Refusing new resource, cl_download_ingame set to 0\n" );
reslist.rescount = 0;
}

HTTP_ResetProcessState();
Expand Down
14 changes: 6 additions & 8 deletions engine/client/cl_tent.c
Original file line number Diff line number Diff line change
Expand Up @@ -2629,7 +2629,7 @@ void CL_UpdateFlashlight( cl_entity_t *ent )
vec3_t forward, view_ofs;
vec3_t vecSrc, vecEnd;
float falloff;
pmtrace_t *trace;
pmtrace_t trace;
cl_entity_t *hit;
dlight_t *dl;

Expand Down Expand Up @@ -2660,28 +2660,26 @@ void CL_UpdateFlashlight( cl_entity_t *ent )
VectorAdd( ent->origin, view_ofs, vecSrc );
VectorMA( vecSrc, FLASHLIGHT_DISTANCE, forward, vecEnd );

trace = CL_VisTraceLine( vecSrc, vecEnd, PM_STUDIO_BOX );
trace = CL_TraceLine( vecSrc, vecEnd, PM_STUDIO_BOX );

// update flashlight endpos
dl = CL_AllocDlight( ent->index );
#if 1
hit = CL_GetEntityByIndex( clgame.pmove->visents[trace->ent].info );
hit = CL_GetEntityByIndex( clgame.pmove->visents[trace.ent].info );
if( hit && hit->model && ( hit->model->type == mod_alias || hit->model->type == mod_studio ))
VectorCopy( hit->origin, dl->origin );
else VectorCopy( trace->endpos, dl->origin );
else VectorCopy( trace.endpos, dl->origin );
#else
VectorCopy( trace->endpos, dl->origin );
#endif
// compute falloff
falloff = trace->fraction * FLASHLIGHT_DISTANCE;
falloff = trace.fraction * FLASHLIGHT_DISTANCE;
if( falloff < 500.0f ) falloff = 1.0f;
else falloff = 500.0f / falloff;
falloff *= falloff;

// apply brigthness to dlight
dl->color.r = bound( 0, falloff * 255, 255 );
dl->color.g = bound( 0, falloff * 255, 255 );
dl->color.b = bound( 0, falloff * 255, 255 );
dl->color.r = dl->color.g = dl->color.b = bound( 0, falloff * 255, 255 );
dl->die = cl.time + 0.01f; // die on next frame
dl->radius = 80;
}
Expand Down
2 changes: 1 addition & 1 deletion engine/client/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ compute string width and height in screen pixels
*/
void GAME_EXPORT Con_DrawStringLen( const char *pText, int *length, int *height )
{
return CL_DrawStringLen( con.curFont, pText, length, height, FONT_DRAW_UTF8 );
CL_DrawStringLen( con.curFont, pText, length, height, FONT_DRAW_UTF8 );
}

/*
Expand Down
12 changes: 4 additions & 8 deletions engine/client/ref_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,21 +555,17 @@ static void SetWidthAndHeightFromCommandLine( void )
return;
}

R_SaveVideoMode( width, height, width, height );
R_SaveVideoMode( width, height, width, height, false );
}

static void SetFullscreenModeFromCommandLine( void )
{
#if !XASH_MOBILE_PLATFORM
if( Sys_CheckParm( "-fullscreen" ))
{
if( Sys_CheckParm( "-borderless" ))
Cvar_DirectSet( &vid_fullscreen, "2" );
else if( Sys_CheckParm( "-fullscreen" ))
Cvar_DirectSet( &vid_fullscreen, "1" );
}
else if( Sys_CheckParm( "-windowed" ))
{
Cvar_DirectSet( &vid_fullscreen, "0" );
}
#endif
}

static void R_CollectRendererNames( void )
Expand Down
9 changes: 6 additions & 3 deletions engine/client/vid_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ static CVAR_DEFINE_AUTO( vid_rotate, "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "sc
static CVAR_DEFINE_AUTO( vid_scale, "1.0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "pixel scale" );

CVAR_DEFINE_AUTO( vid_highdpi, "1", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable High-DPI mode" );
CVAR_DEFINE( vid_fullscreen, "fullscreen", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable fullscreen mode" );
CVAR_DEFINE_AUTO( vid_maximized, "0", FCVAR_RENDERINFO, "window maximized state, read-only" );
CVAR_DEFINE( vid_fullscreen, "fullscreen", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "fullscreen state (0 windowed, 1 fullscreen, 2 borderless)" );
CVAR_DEFINE( window_xpos, "_window_xpos", "-1", FCVAR_RENDERINFO, "window position by horizontal" );
CVAR_DEFINE( window_ypos, "_window_ypos", "-1", FCVAR_RENDERINFO, "window position by vertical" );

Expand Down Expand Up @@ -66,7 +67,7 @@ void VID_InitDefaultResolution( void )
R_SaveVideoMode
=================
*/
void R_SaveVideoMode( int w, int h, int render_w, int render_h )
void R_SaveVideoMode( int w, int h, int render_w, int render_h, qboolean maximized )
{
if( !w || !h || !render_w || !render_h )
{
Expand All @@ -79,6 +80,7 @@ void R_SaveVideoMode( int w, int h, int render_w, int render_h )

Cvar_SetValue( "width", w );
Cvar_SetValue( "height", h );
Cvar_DirectSet( &vid_maximized, maximized ? "1" : "0" );

// immediately drop changed state or we may trigger
// video subsystem to reapply settings
Expand Down Expand Up @@ -207,7 +209,7 @@ static void VID_Mode_f( void )
return;
}

R_ChangeDisplaySettings( w, h, !!vid_fullscreen.value );
R_ChangeDisplaySettings( w, h, bound( 0, vid_fullscreen.value, WINDOW_MODE_COUNT - 1 ));
}

void VID_Init( void )
Expand All @@ -221,6 +223,7 @@ void VID_Init( void )
Cvar_RegisterVariable( &vid_rotate );
Cvar_RegisterVariable( &vid_scale );
Cvar_RegisterVariable( &vid_fullscreen );
Cvar_RegisterVariable( &vid_maximized );
Cvar_RegisterVariable( &vid_brightness );
Cvar_RegisterVariable( &vid_gamma );
Cvar_RegisterVariable( &window_xpos );
Expand Down
10 changes: 9 additions & 1 deletion engine/client/vid_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ typedef struct vidmode_s
int height;
} vidmode_t;

typedef enum window_mode_e
{
WINDOW_MODE_WINDOWED = 0,
WINDOW_MODE_FULLSCREEN,
WINDOW_MODE_BORDERLESS,
WINDOW_MODE_COUNT,
} window_mode_t;

typedef struct
{
Expand All @@ -29,12 +36,13 @@ extern glwstate_t glw_state;
#define VID_MIN_WIDTH 320

extern convar_t vid_fullscreen;
extern convar_t vid_maximized;
extern convar_t vid_highdpi;
extern convar_t window_xpos;
extern convar_t window_ypos;
extern convar_t gl_msaa_samples;

void R_SaveVideoMode( int w, int h, int render_w, int render_h );
void R_SaveVideoMode( int w, int h, int render_w, int render_h, qboolean maximized );
void VID_SetDisplayTransform( int *render_w, int *render_h );
void VID_CheckChanges( void );
const char *VID_GetModeString( int vid_mode );
Expand Down
1 change: 1 addition & 0 deletions engine/common/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ void Sys_PrintUsage( void )
O("-oldfont ", "enable unused Quake font in Half-Life")
O("-width <n> ", "set window width")
O("-height <n> ", "set window height")
O("-borderless ", "run engine in fullscreen borderless mode")
O("-fullscreen ", "run engine in fullscreen mode")
O("-windowed ", "run engine in windowed mode")
O("-ref <name> ", "use selected renderer dll")
Expand Down
4 changes: 2 additions & 2 deletions engine/platform/dos/vid_dos.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ void R_Free_Video( void )

qboolean VID_SetMode( void )
{
R_ChangeDisplaySettings( 0, 0, false ); // width and height are ignored anyway
R_ChangeDisplaySettings( 0, 0, WINDOW_MODE_FULLSCREEN ); // width and height are ignored anyway

return true;
}

rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen )
rserr_t R_ChangeDisplaySettings( int width, int height, window_mode_t window_mode )
{
int render_w, render_h;
uint rotate = vid_rotate->value;
Expand Down
4 changes: 2 additions & 2 deletions engine/platform/linux/vid_fbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ qboolean VID_SetMode( void )
{
if( fb.tty_fd > 0 )
ioctl( fb.tty_fd, KDSETMODE, KD_GRAPHICS );
R_ChangeDisplaySettings( 0, 0, false ); // width and height are ignored anyway
R_ChangeDisplaySettings( 0, 0, WINDOW_MODE_FULLSCREEN ); // width and height are ignored anyway

return true;
}

rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen )
rserr_t R_ChangeDisplaySettings( int width, int height, window_mode_t window_mode )
{
int render_w, render_h;

Expand Down
3 changes: 2 additions & 1 deletion engine/platform/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,12 @@ typedef enum
} rserr_t;

struct vidmode_s;
typedef enum window_mode_e window_mode_t;
// Window
qboolean R_Init_Video( const int type );
void R_Free_Video( void );
qboolean VID_SetMode( void );
rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen );
rserr_t R_ChangeDisplaySettings( int width, int height, window_mode_t window_mode );
int R_MaxVideoModes( void );
struct vidmode_s *R_GetVideoMode( int num );
void* GL_GetProcAddress( const char *name ); // RenderAPI requirement
Expand Down
25 changes: 16 additions & 9 deletions engine/platform/sdl/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ static void SDLash_ActiveEvent( int gain )
SNDDMA_Activate( true );
}
host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME;
if( vid_fullscreen.value )
if( vid_fullscreen.value == WINDOW_MODE_FULLSCREEN )
VID_SetMode();
}
else
Expand Down Expand Up @@ -622,7 +622,7 @@ static void SDLash_EventFilter( SDL_Event *event )
switch( event->window.event )
{
case SDL_WINDOWEVENT_MOVED:
if( !vid_fullscreen.value )
if( vid_fullscreen.value == WINDOW_MODE_WINDOWED )
{
char val[32];

Expand All @@ -631,16 +631,20 @@ static void SDLash_EventFilter( SDL_Event *event )

Q_snprintf( val, sizeof( val ), "%d", event->window.data2 );
Cvar_DirectSet( &window_ypos, val );

Cvar_DirectSet( &vid_maximized, "0" );
}
break;
case SDL_WINDOWEVENT_MINIMIZED:
host.status = HOST_SLEEP;
Cvar_DirectSet( &vid_maximized, "0" );
VID_RestoreScreenResolution( );
break;
case SDL_WINDOWEVENT_RESTORED:
host.status = HOST_FRAME;
host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME;
if( vid_fullscreen.value )
Cvar_DirectSet( &vid_maximized, "0" );
if( vid_fullscreen.value == WINDOW_MODE_FULLSCREEN )
VID_SetMode();
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
Expand All @@ -650,13 +654,16 @@ static void SDLash_EventFilter( SDL_Event *event )
SDLash_ActiveEvent( false );
break;
case SDL_WINDOWEVENT_RESIZED:
{
if( vid_fullscreen.value )
break;

VID_SaveWindowSize( event->window.data1, event->window.data2 );
if( vid_fullscreen.value == WINDOW_MODE_WINDOWED )
{
SDL_Window *wnd = SDL_GetWindowFromID( event->window.windowID );
VID_SaveWindowSize( event->window.data1, event->window.data2,
FBitSet( SDL_GetWindowFlags( wnd ), SDL_WINDOW_MAXIMIZED ) != 0 );
}
break;
case SDL_WINDOWEVENT_MAXIMIZED:
Cvar_DirectSet( &vid_maximized, "1" );
break;
}
default:
break;
}
Expand Down
4 changes: 2 additions & 2 deletions engine/platform/sdl/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ GNU General Public License for more details.

// window management
void VID_RestoreScreenResolution( void );
qboolean VID_CreateWindow( int width, int height, qboolean fullscreen );
qboolean VID_CreateWindow( int width, int height, window_mode_t window_mode );
void VID_DestroyWindow( void );
void GL_InitExtensions( void );
qboolean GL_DeleteContext( void );
void VID_SaveWindowSize( int width, int height );
void VID_SaveWindowSize( int width, int height, qboolean maximized );

// joystick events
extern SDL_Joystick *g_joy;
Expand Down
Loading

0 comments on commit 2f7b9d5

Please sign in to comment.