2004-12-09 23:39:52 +00:00
# include "quakedef.h"
2004-12-10 21:31:53 +00:00
# include <SDL.h>
2014-02-07 08:38:40 +00:00
# include <SDL_syswm.h>
2004-12-09 23:39:52 +00:00
2017-09-20 11:27:13 +00:00
# ifdef GLQUAKE
# include "glquake.h"
# define OPENGL_SDL
# endif
2014-02-07 08:38:40 +00:00
# if SDL_MAJOR_VERSION >= 2
2017-09-20 11:27:13 +00:00
# if SDL_VERSION_ATLEAST(2,0,6)
# ifdef VKQUAKE
# include <SDL_vulkan.h>
# include "../vk/vkrenderer.h"
# define VULKAN_SDL
# endif
# endif
SDL_Window * sdlwindow ;
# ifdef OPENGL_SDL
static SDL_GLContext * sdlcontext ;
# endif
2014-02-07 08:38:40 +00:00
# else
2017-09-20 11:27:13 +00:00
SDL_Surface * sdlsurf ;
2014-02-07 08:38:40 +00:00
# endif
2004-12-09 23:39:52 +00:00
2021-11-14 00:35:08 +00:00
# include "vr.h"
2014-02-07 08:38:40 +00:00
extern cvar_t vid_vsync ;
2004-12-09 23:39:52 +00:00
extern cvar_t vid_hardwaregamma ;
extern cvar_t gl_lateswap ;
2014-02-07 08:38:40 +00:00
extern cvar_t vid_gl_context_version ;
extern cvar_t vid_gl_context_debug ;
extern cvar_t vid_gl_context_forwardcompatible ;
extern cvar_t vid_gl_context_es ;
extern cvar_t vid_gl_context_compatibility ;
2016-07-12 00:40:13 +00:00
extern qboolean gammaworks ;
2004-12-09 23:39:52 +00:00
# ifdef _WIN32 //half the rest of the code uses windows apis to focus windows. Should be fixed, but it's not too important.
HWND mainwindow ;
# endif
extern qboolean vid_isfullscreen ;
2014-02-07 08:38:40 +00:00
# if SDL_MAJOR_VERSION < 2
2004-12-09 23:39:52 +00:00
unsigned short intitialgammaramps [ 3 ] [ 256 ] ;
2014-02-07 08:38:40 +00:00
# endif
2004-12-09 23:39:52 +00:00
2020-11-03 15:52:26 +00:00
extern qboolean mouseactive ;
2004-12-09 23:39:52 +00:00
extern qboolean mouseusedforgui ;
2017-09-20 11:27:13 +00:00
# ifdef OPENGL_SDL
2012-10-14 09:00:49 +00:00
static void * GLVID_getsdlglfunction ( char * functionname )
{
2013-08-06 02:20:56 +00:00
# ifdef GL_STATIC
//this reduces dependancies in the webgl build (removing warnings about emulation being poo)
return NULL ;
# else
2012-10-14 09:00:49 +00:00
return SDL_GL_GetProcAddress ( functionname ) ;
2013-08-06 02:20:56 +00:00
# endif
2012-10-14 09:00:49 +00:00
}
2017-09-20 11:27:13 +00:00
# endif
2004-12-09 23:39:52 +00:00
2015-09-18 20:30:10 +00:00
# if SDL_MAJOR_VERSION >= 2
2018-10-23 07:09:06 +00:00
void * GLVID_CreateCursor ( const qbyte * imagedata , int width , int height , uploadfmt_t format , float hotx , float hoty , float scale )
2015-09-18 20:30:10 +00:00
{
SDL_Cursor * curs ;
SDL_Surface * surf ;
2019-07-29 16:33:59 +00:00
Uint32 r , g , b , a ;
2018-10-23 07:09:06 +00:00
if ( ! imagedata )
2015-09-18 20:30:10 +00:00
return NULL ;
2019-07-29 16:33:59 +00:00
switch ( format )
{
# if SDL_BYTEORDER == SDL_BIG_ENDIAN
case PTI_LLLX8 :
case PTI_RGBX8 :
r = 0xff000000 ;
g = 0x00ff0000 ;
b = 0x0000ff00 ;
a = 0x00000000 ;
break ;
case PTI_LLLA8 :
case PTI_RGBA8 :
r = 0xff000000 ;
g = 0x00ff0000 ;
b = 0x0000ff00 ;
a = 0x000000ff ;
break ;
case PTI_BGRX8 :
b = 0xff000000 ;
g = 0x00ff0000 ;
r = 0x0000ff00 ;
a = 0x00000000 ;
break ;
case PTI_BGRA8 :
b = 0xff000000 ;
g = 0x00ff0000 ;
r = 0x0000ff00 ;
a = 0x000000ff ;
break ;
# else
case PTI_LLLX8 :
case PTI_RGBX8 :
r = 0x000000ff ;
g = 0x0000ff00 ;
b = 0x00ff0000 ;
a = 0x00000000 ;
break ;
case PTI_LLLA8 :
case PTI_RGBA8 :
r = 0x000000ff ;
g = 0x0000ff00 ;
b = 0x00ff0000 ;
a = 0xff000000 ;
break ;
case PTI_BGRX8 :
b = 0x000000ff ;
g = 0x0000ff00 ;
r = 0x00ff0000 ;
a = 0x00000000 ;
break ;
case PTI_BGRA8 :
b = 0x000000ff ;
g = 0x0000ff00 ;
r = 0x00ff0000 ;
a = 0xff000000 ;
break ;
# endif
case PTI_A2BGR10 :
r = 0x000003ff ;
g = 0x000ffc00 ;
b = 0x3ff00000 ;
a = 0xc0000000 ;
break ;
default :
return NULL ;
}
2015-09-18 20:30:10 +00:00
if ( scale ! = 1 )
{
int nw , nh ;
qbyte * nd ;
nw = width * scale ;
nh = height * scale ;
if ( nw < = 0 | | nh < = 0 | | nw > 128 | | nh > 128 ) //don't go crazy.
return NULL ;
2019-07-29 16:33:59 +00:00
nd = Image_ResampleTexture ( format , imagedata , width , height , NULL , nw , nh ) ;
surf = SDL_CreateRGBSurfaceFrom ( nd , nw , nh , 32 , nw * 4 , r , g , b , a ) ;
2018-10-23 07:09:06 +00:00
curs = SDL_CreateColorCursor ( surf , hotx , hoty ) ;
SDL_FreeSurface ( surf ) ;
BZ_Free ( nd ) ;
}
else
{
2019-07-29 16:33:59 +00:00
surf = SDL_CreateRGBSurfaceFrom ( ( void * ) imagedata , width , height , 32 , width * 4 , r , g , b , a ) ;
2018-10-23 07:09:06 +00:00
curs = SDL_CreateColorCursor ( surf , hotx , hoty ) ;
SDL_FreeSurface ( surf ) ;
}
2015-09-18 20:30:10 +00:00
return curs ;
}
qboolean GLVID_SetCursor ( void * cursor )
{
SDL_SetCursor ( cursor ) ;
return ! ! cursor ;
}
void GLVID_DestroyCursor ( void * cursor )
{
SDL_FreeCursor ( cursor ) ;
}
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
static void GLVID_SetIcon ( void )
{
SDL_Surface * iconsurf = NULL ;
size_t filesize = 0 ;
qbyte * filedata = NULL ;
qbyte * imagedata = NULL ;
# ifdef IMAGEFMT_PNG
if ( ! filedata )
filedata = FS_LoadMallocFile ( " icon.png " , & filesize ) ;
# endif
if ( ! filedata )
filedata = FS_LoadMallocFile ( " icon.tga " , & filesize ) ;
# ifdef IMAGEFMT_JPG
if ( ! filedata )
filedata = FS_LoadMallocFile ( " icon.jpg " , & filesize ) ;
# endif
# ifdef IMAGEFMT_BMP
if ( ! filedata )
filedata = FS_LoadMallocFile ( " icon.ico " , & filesize ) ;
# endif
# ifdef HAVE_LEGACY
if ( ! filedata )
filedata = FS_LoadMallocFile ( " darkplaces-icon.tga " , & filesize ) ;
# endif
if ( filedata )
{
int imagewidth , imageheight ;
uploadfmt_t format = PTI_INVALID ;
imagedata = ReadRawImageFile ( filedata , filesize , & imagewidth , & imageheight , & format , true , " icon.* " ) ;
Z_Free ( filedata ) ;
if ( imagedata )
{
/* hopefully SDL can resize as appropriate
qbyte * resized = Image_ResampleTexture ( format , imagedata , imagewidth , imageheight , NULL , 64 , 64 ) ;
if ( resized )
{
Z_Free ( imagedata ) ;
imagedata = resized ;
imagewidth = 64 ;
imageheight = 64 ;
} */
switch ( format )
{
case PTI_LLLA8 : //fallthrough
case PTI_RGBA8 : iconsurf = SDL_CreateRGBSurfaceFrom ( imagedata , imagewidth , imageheight , 32 , 4 * imagewidth , 0x000000FF , 0x0000FF00 , 0x00FF0000 , 0xFF000000 ) ; break ;
case PTI_LLLX8 : //fallthrough
case PTI_RGBX8 : iconsurf = SDL_CreateRGBSurfaceFrom ( imagedata , imagewidth , imageheight , 32 , 4 * imagewidth , 0x000000FF , 0x0000FF00 , 0x00FF0000 , 0x00000000 ) ; break ;
case PTI_BGRA8 : iconsurf = SDL_CreateRGBSurfaceFrom ( imagedata , imagewidth , imageheight , 32 , 4 * imagewidth , 0x00FF0000 , 0x0000FF00 , 0x000000FF , 0xFF000000 ) ; break ;
case PTI_BGRX8 : iconsurf = SDL_CreateRGBSurfaceFrom ( imagedata , imagewidth , imageheight , 32 , 4 * imagewidth , 0x00FF0000 , 0x0000FF00 , 0x000000FF , 0x00000000 ) ; break ;
case PTI_A2BGR10 : iconsurf = SDL_CreateRGBSurfaceFrom ( imagedata , imagewidth , imageheight , 32 , 4 * imagewidth , 0x3FF00000 , 0x000FFC00 , 0x000003FF , 0xC0000000 ) ; break ;
default : //others shouldn't happen.
break ;
}
}
}
if ( ! iconsurf )
{
# include "fte_eukara64.h"
// #include "bymorphed.h"
iconsurf = SDL_CreateRGBSurfaceFrom ( ( void * ) icon . pixel_data , icon . width , icon . height , 32 , 4 * icon . width , 0x000000FF , 0x0000FF00 , 0x00FF0000 , 0xFF000000 ) ; //RGBA byte order on a little endian machine, at least...
}
SDL_SetWindowIcon ( sdlwindow , iconsurf ) ;
SDL_FreeSurface ( iconsurf ) ;
Z_Free ( imagedata ) ;
}
//converts an output device name/number to an index.
//So we can use eg VGA-0 on linux and get the proper device.
static int SDLVID_GetVideoDevice ( const char * devicename )
{
char * end ;
int display = strtol ( devicename , & end , 0 ) ;
if ( * end )
{ //okay, so its not purely a number. scan by name
display = SDL_GetNumVideoDisplays ( ) ;
if ( display )
{
while ( display - - > 0 )
{
const char * dname = SDL_GetDisplayName ( display ) ;
if ( dname & & ! Q_strcasecmp ( dname , devicename ) )
break ;
}
}
}
else
{
if ( display < 0 | | display > = SDL_GetNumVideoDisplays ( ) )
display = 0 ;
}
return display ;
}
static qboolean SDLVID_GetVideoMode ( rendererstate_t * info , int * display , SDL_DisplayMode * mode )
{
SDL_DisplayMode targ ;
* display = SDLVID_GetVideoDevice ( info - > devicename ) ;
if ( info - > fullscreen ! = 1 )
return false ;
targ . w = info - > width ;
targ . h = info - > height ;
if ( info - > bpp = = 30 )
targ . format = SDL_PIXELFORMAT_ARGB2101010 ;
else
targ . format = SDL_PIXELFORMAT_UNKNOWN ;
targ . driverdata = NULL ;
targ . refresh_rate = info - > rate ;
if ( SDL_GetClosestDisplayMode ( * display , & targ , mode ) )
{
info - > width = targ . w ;
info - > height = targ . h ;
return true ; //yay
}
return false ; //fail
}
static void SDLVID_EnumerateVideoModes ( const char * driver , const char * output , void ( * cb ) ( int w , int h ) )
{
SDL_DisplayMode modeinfo ;
int modes , m ;
int display = SDLVID_GetVideoDevice ( output ) ;
modes = SDL_GetNumDisplayModes ( display ) ;
for ( m = 0 ; m < modes ; m + + )
{
if ( 0 = = SDL_GetDisplayMode ( display , m , & modeinfo ) )
cb ( modeinfo . w , modeinfo . h ) ;
}
}
2015-09-18 20:30:10 +00:00
# endif
2017-09-20 11:27:13 +00:00
static qboolean SDLVID_Init ( rendererstate_t * info , unsigned char * palette , r_qrenderer_t qrenderer )
2004-12-09 23:39:52 +00:00
{
2014-02-07 08:38:40 +00:00
int flags = 0 ;
2020-11-04 10:19:30 +00:00
# if SDL_MAJOR_VERSION >= 2
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
int display = - 1 ;
SDL_DisplayMode modeinfo , * usemode ;
2020-11-04 10:19:30 +00:00
# endif
2004-12-09 23:39:52 +00:00
SDL_Init ( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE ) ;
2014-02-07 08:38:40 +00:00
# if !defined(FTE_TARGET_WEB) && SDL_MAJOR_VERSION < 2
SDL_SetVideoMode ( 0 , 0 , 0 , 0 ) ; //to get around some SDL bugs
# endif
# if SDL_MAJOR_VERSION >= 2
2021-11-14 00:35:08 +00:00
switch ( qrenderer )
{
default :
return false ;
# ifdef OPENGL_SDL
case QR_OPENGL :
# if SDL_MAJOR_VERSION >= 2
2017-09-20 11:27:13 +00:00
SDL_GL_LoadLibrary ( NULL ) ;
2021-11-14 00:35:08 +00:00
# endif
2004-12-09 23:39:52 +00:00
2017-09-20 11:27:13 +00:00
if ( info - > bpp > = 32 )
{
SDL_GL_SetAttribute ( SDL_GL_RED_SIZE , 8 ) ;
SDL_GL_SetAttribute ( SDL_GL_GREEN_SIZE , 8 ) ;
SDL_GL_SetAttribute ( SDL_GL_BLUE_SIZE , 8 ) ;
SDL_GL_SetAttribute ( SDL_GL_ALPHA_SIZE , 0 ) ;
SDL_GL_SetAttribute ( SDL_GL_STENCIL_SIZE , 8 ) ; //technically we don't always need stencil support.
}
else
{
SDL_GL_SetAttribute ( SDL_GL_RED_SIZE , 5 ) ;
SDL_GL_SetAttribute ( SDL_GL_GREEN_SIZE , 5 ) ;
SDL_GL_SetAttribute ( SDL_GL_BLUE_SIZE , 5 ) ;
SDL_GL_SetAttribute ( SDL_GL_ALPHA_SIZE , 0 ) ;
SDL_GL_SetAttribute ( SDL_GL_STENCIL_SIZE , 0 ) ;
}
SDL_GL_SetAttribute ( SDL_GL_DEPTH_SIZE , 16 ) ;
SDL_GL_SetAttribute ( SDL_GL_DOUBLEBUFFER , 1 ) ;
2004-12-09 23:39:52 +00:00
2017-09-20 11:27:13 +00:00
if ( info - > stereo )
SDL_GL_SetAttribute ( SDL_GL_STEREO , 1 ) ;
2006-03-15 20:11:37 +00:00
2021-11-14 00:35:08 +00:00
# if SDL_MAJOR_VERSION >= 2
2018-03-04 14:41:16 +00:00
if ( info - > srgb )
SDL_GL_SetAttribute ( SDL_GL_FRAMEBUFFER_SRGB_CAPABLE , 1 ) ;
2017-09-20 11:27:13 +00:00
//FIXME: this stuff isn't part of info.
//this means it shouldn't be exposed to the menu or widely advertised.
if ( * vid_gl_context_version . string )
2014-02-07 08:38:40 +00:00
{
2017-09-20 11:27:13 +00:00
int major , minor ;
char * ver = vid_gl_context_version . string ;
major = strtoul ( ver , & ver , 10 ) ;
if ( * ver = = ' . ' )
{
ver + + ;
minor = strtoul ( ver , & ver , 10 ) ;
}
else
minor = 0 ;
SDL_GL_SetAttribute ( SDL_GL_CONTEXT_MAJOR_VERSION , major ) ;
SDL_GL_SetAttribute ( SDL_GL_CONTEXT_MINOR_VERSION , minor ) ;
2014-02-07 08:38:40 +00:00
}
2017-09-20 11:27:13 +00:00
SDL_GL_SetAttribute ( SDL_GL_CONTEXT_FLAGS ,
( vid_gl_context_debug . ival ? SDL_GL_CONTEXT_DEBUG_FLAG : 0 ) |
( vid_gl_context_forwardcompatible . ival ? SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG : 0 ) |
0 ) ;
if ( vid_gl_context_es . ival )
SDL_GL_SetAttribute ( SDL_GL_CONTEXT_PROFILE_MASK , SDL_GL_CONTEXT_PROFILE_ES ) ;
else if ( vid_gl_context_compatibility . ival )
SDL_GL_SetAttribute ( SDL_GL_CONTEXT_PROFILE_MASK , SDL_GL_CONTEXT_PROFILE_COMPATIBILITY ) ;
2014-02-07 08:38:40 +00:00
else
2017-09-20 11:27:13 +00:00
SDL_GL_SetAttribute ( SDL_GL_CONTEXT_PROFILE_MASK , SDL_GL_CONTEXT_PROFILE_CORE ) ;
2021-11-14 00:35:08 +00:00
# endif
2017-09-20 11:27:13 +00:00
if ( info - > multisample )
{
SDL_GL_SetAttribute ( SDL_GL_MULTISAMPLESAMPLES , info - > multisample ) ;
SDL_GL_SetAttribute ( SDL_GL_MULTISAMPLEBUFFERS , 1 ) ;
}
2006-03-15 20:11:37 +00:00
2017-09-20 11:27:13 +00:00
flags | = SDL_WINDOW_OPENGL ;
break ;
# endif
# ifdef VULKAN_SDL
2021-11-14 00:35:08 +00:00
case QR_VULKAN :
2017-09-20 11:27:13 +00:00
flags | = SDL_WINDOW_VULKAN ;
break ;
# endif
}
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
flags | = SDL_WINDOW_RESIZABLE ;
2014-02-07 08:38:40 +00:00
flags | = SDL_WINDOW_INPUT_GRABBED ;
# if SDL_PATCHLEVEL >= 1
flags | = SDL_WINDOW_ALLOW_HIGHDPI ;
# endif
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
usemode = NULL ;
if ( SDLVID_GetVideoMode ( info , & display , & modeinfo ) )
usemode = & modeinfo ;
rf - > VID_EnumerateVideoModes = SDLVID_EnumerateVideoModes ;
sdlwindow = SDL_CreateWindow ( FULLENGINENAME , SDL_WINDOWPOS_CENTERED_DISPLAY ( display ) , SDL_WINDOWPOS_CENTERED_DISPLAY ( display ) , info - > width , info - > height , flags ) ;
2014-02-07 08:38:40 +00:00
if ( ! sdlwindow )
{
2018-06-18 16:44:29 +00:00
Con_Printf ( " SDL_CreateWindow failed: %s \n " , SDL_GetError ( ) ) ;
2014-02-07 08:38:40 +00:00
return false ;
}
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
SDL_SetWindowMinimumSize ( sdlwindow , 320 , 200 ) ;
if ( usemode )
{
SDL_SetWindowDisplayMode ( sdlwindow , usemode ) ;
SDL_SetWindowFullscreen ( sdlwindow , SDL_WINDOW_FULLSCREEN ) ;
}
else if ( info - > fullscreen )
SDL_SetWindowFullscreen ( sdlwindow , SDL_WINDOW_FULLSCREEN_DESKTOP ) ;
SDL_ShowWindow ( sdlwindow ) ;
# ifdef __linux__
if ( usemode )
{ //try to work around an nvidia bug.
//if the user pans then they might get stuck with x11 at the wrong resolution, so try to back out if it would fail.
int w , h ;
SDL_GetWindowSize ( sdlwindow , & w , & h ) ;
Sys_SendKeyEvents ( ) ;
SDL_GetWindowSize ( sdlwindow , & vid . pixelwidth , & vid . pixelheight ) ;
if ( w ! = vid . pixelwidth | | h ! = vid . pixelheight )
{
Con_Printf ( CON_ERROR " Video mode change didn't stick (Nvidia bug?). Resorting to fullscreen-desktop mode. \n " ) ;
SDL_SetWindowFullscreen ( sdlwindow , SDL_WINDOW_FULLSCREEN_DESKTOP ) ;
SDL_ShowWindow ( sdlwindow ) ;
}
}
# endif
# if SDL_PATCHLEVEL >= 4
SDL_GetDisplayDPI ( display , NULL , & vid . dpi_x , & vid . dpi_y ) ;
# endif
2015-09-18 20:30:10 +00:00
CL_UpdateWindowTitle ( ) ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
GLVID_SetIcon ( ) ;
2017-09-20 11:27:13 +00:00
switch ( qrenderer )
{
# ifdef OPENGL_SDL
# if SDL_PATCHLEVEL >= 1
case QR_OPENGL :
2014-02-07 08:38:40 +00:00
SDL_GL_GetDrawableSize ( sdlwindow , & vid . pixelwidth , & vid . pixelheight ) ; //get the proper physical size.
2017-09-20 11:27:13 +00:00
break ;
# endif
# endif
# ifdef VULKAN_SDL
case QR_VULKAN :
SDL_Vulkan_GetDrawableSize ( sdlwindow , & vid . pixelwidth , & vid . pixelheight ) ;
break ;
# endif
default :
2014-02-07 08:38:40 +00:00
SDL_GetWindowSize ( sdlwindow , & vid . pixelwidth , & vid . pixelheight ) ;
2017-09-20 11:27:13 +00:00
break ;
}
2014-02-07 08:38:40 +00:00
2017-09-20 11:27:13 +00:00
# ifdef OPENGL_SDL
if ( qrenderer = = QR_OPENGL )
2014-02-07 08:38:40 +00:00
{
2018-03-04 14:41:16 +00:00
int srgb ;
2021-12-20 10:06:17 +00:00
vrsetup_t setup = { sizeof ( setup ) } ;
SDL_SysWMinfo wminfo ;
SDL_VERSION ( & wminfo . version ) ;
SDL_GetWindowWMInfo ( sdlwindow , & wminfo ) ;
switch ( wminfo . subsystem )
{
# if defined(SDL_VIDEO_DRIVER_WINDOWS)
case SDL_SYSWM_WINDOWS :
setup . vrplatform = VR_WIN_WGL ;
break ;
# endif
# if defined(SDL_VIDEO_DRIVER_X11)
case SDL_SYSWM_X11 :
setup . vrplatform = VR_X11_GLX ;
break ;
# endif
// case SDL_SYSWM_WAYLAND:
// setup.vrplatform = VR_EGL;
// break;
default :
setup . vrplatform = VR_HEADLESS ; //unsupported platform...
break ;
}
if ( info - > vr & & ! info - > vr - > Prepare ( & setup ) )
info - > vr = NULL ;
2017-09-20 11:27:13 +00:00
sdlcontext = SDL_GL_CreateContext ( sdlwindow ) ;
if ( ! sdlcontext )
{
2018-03-04 14:41:16 +00:00
SDL_GL_SetAttribute ( SDL_GL_CONTEXT_MAJOR_VERSION , 1 ) ;
SDL_GL_SetAttribute ( SDL_GL_CONTEXT_MINOR_VERSION , 1 ) ;
SDL_GL_SetAttribute ( SDL_GL_CONTEXT_FLAGS , 0 ) ;
SDL_GL_SetAttribute ( SDL_GL_CONTEXT_PROFILE_MASK , 0 ) ;
sdlcontext = SDL_GL_CreateContext ( sdlwindow ) ;
if ( ! sdlcontext )
{
Con_Printf ( " Couldn't initialize GL context: %s \n " , SDL_GetError ( ) ) ;
return false ;
}
2017-09-20 11:27:13 +00:00
}
2018-03-04 14:41:16 +00:00
srgb = 0 ;
SDL_GL_GetAttribute ( SDL_GL_FRAMEBUFFER_SRGB_CAPABLE , & srgb ) ;
if ( srgb )
vid . flags | = VID_SRGB_CAPABLE ;
2021-12-20 10:06:17 +00:00
//now fill it in properly, now that we have a context.
switch ( wminfo . subsystem )
{
# if defined(SDL_VIDEO_DRIVER_WINDOWS)
case SDL_SYSWM_WINDOWS :
setup . wgl . hdc = wminfo . info . win . hdc ;
setup . wgl . hglrc = SDL_GL_GetCurrentContext ( ) ;
break ;
# endif
# if defined(SDL_VIDEO_DRIVER_X11)
case SDL_SYSWM_X11 :
setup . x11_glx . display = wminfo . info . x11 . display ;
setup . x11_glx . drawable = wminfo . info . x11 . window ;
setup . x11_glx . visualid = 0 ; //???
setup . x11_glx . glxfbconfig = 0 ; //???
setup . x11_glx . glxcontext = SDL_GL_GetCurrentContext ( ) ;
break ;
# endif
default :
setup . vrplatform = VR_HEADLESS ; //unsupported platform...
break ;
}
if ( info - > vr & & ! info - > vr - > Init ( & setup , info ) )
{
info - > vr - > Shutdown ( ) ;
vid . vr = NULL ;
}
else
vid . vr = info - > vr ;
2014-02-07 08:38:40 +00:00
}
2017-09-20 11:27:13 +00:00
# endif
2004-12-09 23:39:52 +00:00
2014-02-07 08:38:40 +00:00
# else
SDL_GetGammaRamp ( intitialgammaramps [ 0 ] , intitialgammaramps [ 1 ] , intitialgammaramps [ 2 ] ) ;
2004-12-09 23:39:52 +00:00
if ( info - > fullscreen )
{
flags = SDL_FULLSCREEN ;
vid_isfullscreen = true ;
}
else
{
flags = SDL_RESIZABLE ;
vid_isfullscreen = false ;
}
2010-08-11 23:55:35 +00:00
sdlsurf = SDL_SetVideoMode ( vid . pixelwidth = info - > width , vid . pixelheight = info - > height , info - > bpp , flags | SDL_OPENGL ) ;
2004-12-09 23:39:52 +00:00
if ( ! sdlsurf )
{
2010-08-11 23:55:35 +00:00
Con_Printf ( " Couldn't set GL mode: %s \n " , SDL_GetError ( ) ) ;
2004-12-09 23:39:52 +00:00
return false ;
}
2014-02-07 08:38:40 +00:00
# endif
2016-02-10 23:23:43 +00:00
vid . activeapp = true ;
2004-12-09 23:39:52 +00:00
mouseactive = false ;
if ( vid_isfullscreen )
IN_ActivateMouse ( ) ;
2014-02-07 08:38:40 +00:00
# if SDL_MAJOR_VERSION < 2
SDL_EnableKeyRepeat ( SDL_DEFAULT_REPEAT_DELAY , SDL_DEFAULT_REPEAT_INTERVAL ) ;
2014-02-09 09:25:28 +00:00
# else
SDL_DisableScreenSaver ( ) ;
2014-02-07 08:38:40 +00:00
# endif
vid_vsync . modified = true ;
# ifdef _WIN32
{ //win32 apis are very insistant upon having a window context for things that have nothing to do with windowing system stuff.
# if SDL_MAJOR_VERSION >= 2
SDL_SysWMinfo info ;
SDL_GetWindowWMInfo ( sdlwindow , & info ) ;
if ( info . subsystem = = SDL_SYSWM_WINDOWS )
mainwindow = info . info . win . window ;
else
mainwindow = NULL ; //if we're using an x11 subsystem but running in windows then don't feck up... here, at least.
# else
SDL_SysWMinfo wmInfo ;
SDL_GetWMInfo ( & wmInfo ) ;
mainwindow = wmInfo . window ; //note that this is usually still null
# endif
}
# endif
2015-09-18 20:30:10 +00:00
# if SDL_MAJOR_VERSION >= 2
rf - > VID_CreateCursor = GLVID_CreateCursor ;
rf - > VID_DestroyCursor = GLVID_DestroyCursor ;
rf - > VID_SetCursor = GLVID_SetCursor ;
# endif
2004-12-09 23:39:52 +00:00
return true ;
}
2017-09-20 11:27:13 +00:00
# ifdef OPENGL_SDL
qboolean GLVID_Init ( rendererstate_t * info , unsigned char * palette )
{
if ( SDLVID_Init ( info , palette , QR_OPENGL ) )
{
return GL_Init ( info , GLVID_getsdlglfunction ) ;
}
return false ;
}
# endif
2004-12-09 23:39:52 +00:00
void GLVID_DeInit ( void )
{
2016-02-10 23:23:43 +00:00
vid . activeapp = false ;
2004-12-09 23:39:52 +00:00
IN_DeactivateMouse ( ) ;
2014-02-07 08:38:40 +00:00
# if SDL_MAJOR_VERSION >= 2
SDL_SetWindowGammaRamp ( sdlwindow , NULL , NULL , NULL ) ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
2017-09-20 11:27:13 +00:00
switch ( qrenderer )
{
# ifdef OPENGL_SDL
case QR_OPENGL :
SDL_GL_DeleteContext ( sdlcontext ) ;
break ;
# endif
# ifdef VULKAN_SDL
case QR_VULKAN :
2021-11-14 00:35:08 +00:00
VK_Shutdown ( ) ;
2017-09-20 11:27:13 +00:00
break ;
# endif
default :
break ;
}
2014-02-07 08:38:40 +00:00
SDL_DestroyWindow ( sdlwindow ) ;
2014-02-07 09:36:04 +00:00
sdlwindow = NULL ;
2014-02-07 08:38:40 +00:00
# else
2004-12-09 23:39:52 +00:00
SDL_SetGammaRamp ( intitialgammaramps [ 0 ] , intitialgammaramps [ 1 ] , intitialgammaramps [ 2 ] ) ;
2014-02-07 08:38:40 +00:00
# endif
2004-12-09 23:39:52 +00:00
SDL_QuitSubSystem ( SDL_INIT_VIDEO ) ;
2018-06-18 16:44:29 +00:00
# ifdef OPENGL_SDL
2018-04-27 16:40:50 +00:00
GL_ForgetPointers ( ) ;
2018-06-18 16:44:29 +00:00
# endif
2004-12-09 23:39:52 +00:00
}
2014-03-30 00:39:37 +00:00
void GLVID_SwapBuffers ( void )
2004-12-09 23:39:52 +00:00
{
2017-09-20 11:27:13 +00:00
switch ( qrenderer )
2014-02-07 08:38:40 +00:00
{
2017-09-20 11:27:13 +00:00
# ifdef OPENGL_SDL
case QR_OPENGL :
# if SDL_MAJOR_VERSION >= 2
if ( vid_vsync . modified )
2014-02-07 08:38:40 +00:00
{
2017-09-20 11:27:13 +00:00
if ( * vid_vsync . string )
{
//if swap_tear isn't supported, try without.
if ( SDL_GL_SetSwapInterval ( vid_vsync . ival ) = = - 1 & & vid_vsync . ival < 0 )
SDL_GL_SetSwapInterval ( - vid_vsync . ival ) ;
}
vid_vsync . modified = false ;
2014-02-07 08:38:40 +00:00
}
2017-09-20 11:27:13 +00:00
SDL_GL_SwapWindow ( sdlwindow ) ;
2014-02-07 08:38:40 +00:00
# else
2017-09-20 11:27:13 +00:00
SDL_GL_SwapBuffers ( ) ;
# endif
break ;
2014-02-07 08:38:40 +00:00
# endif
2017-09-20 11:27:13 +00:00
default :
break ;
}
2004-12-09 23:39:52 +00:00
if ( ! vid_isfullscreen )
{
2019-04-15 18:43:42 +00:00
if ( ! in_windowed_mouse . value )
2004-12-09 23:39:52 +00:00
{
2013-10-08 14:28:11 +00:00
IN_DeactivateMouse ( ) ;
2004-12-09 23:39:52 +00:00
}
else
{
2016-02-10 23:23:43 +00:00
if ( ! Key_MouseShouldBeFree ( ) & & vid . activeapp )
2004-12-09 23:39:52 +00:00
IN_ActivateMouse ( ) ;
2013-10-08 14:28:11 +00:00
else
2004-12-09 23:39:52 +00:00
IN_DeactivateMouse ( ) ;
}
}
}
2016-07-28 15:57:22 +00:00
qboolean GLVID_ApplyGammaRamps ( unsigned int gammarampsize , unsigned short * ramps )
2004-12-09 23:39:52 +00:00
{
2014-02-07 08:38:40 +00:00
# if SDL_MAJOR_VERSION >= 2
2016-07-28 15:57:22 +00:00
if ( ramps & & gammarampsize = = 256 )
2014-02-07 08:38:40 +00:00
{
2017-08-29 02:29:06 +00:00
switch ( vid_hardwaregamma . ival )
2014-02-07 08:38:40 +00:00
{
2017-08-29 02:29:06 +00:00
case 0 : //never use hardware/glsl gamma
case 2 : //ALWAYS use glsl gamma
return false ;
default :
case 1 : //no hardware gamma when windowed
if ( ! vid_isfullscreen )
return false ;
break ;
case 3 : //ALWAYS try to use hardware gamma, even when it fails...
break ;
2014-02-07 08:38:40 +00:00
}
2017-08-29 02:29:06 +00:00
gammaworks | = ! SDL_SetWindowGammaRamp ( sdlwindow , & ramps [ 0 ] , & ramps [ 256 ] , & ramps [ 512 ] ) ;
2014-02-07 08:38:40 +00:00
return gammaworks ;
}
2017-08-29 02:29:06 +00:00
else if ( gammaworks )
2014-02-07 08:38:40 +00:00
{
SDL_SetWindowGammaRamp ( sdlwindow , NULL , NULL , NULL ) ;
return true ;
}
# else
2016-07-28 15:57:22 +00:00
if ( ramps & & gammarampsize = = 256 )
2004-12-09 23:39:52 +00:00
{
2017-08-29 02:29:06 +00:00
switch ( vid_hardwaregamma . ival )
2004-12-09 23:39:52 +00:00
{
2017-08-29 02:29:06 +00:00
case 0 : //never use hardware/glsl gamma
case 2 : //ALWAYS use glsl gamma
return false ;
default :
case 1 : //no hardware gamma when windowed
if ( ! vid_isfullscreen )
return false ;
break ;
case 3 : //ALWAYS try to use hardware gamma, even when it fails...
break ;
2004-12-09 23:39:52 +00:00
}
2017-08-29 02:29:06 +00:00
gammaworks | = ! SDL_SetGammaRamp ( & ramps [ 0 ] , & ramps [ 256 ] , & ramps [ 512 ] ) ;
2013-05-14 06:01:02 +00:00
return gammaworks ;
2004-12-09 23:39:52 +00:00
}
2013-05-14 06:01:02 +00:00
else
2004-12-09 23:39:52 +00:00
{
2013-05-14 06:01:02 +00:00
SDL_SetGammaRamp ( intitialgammaramps [ 0 ] , intitialgammaramps [ 1 ] , intitialgammaramps [ 2 ] ) ;
return true ;
2004-12-09 23:39:52 +00:00
}
2014-02-07 08:38:40 +00:00
# endif
2017-09-20 11:27:13 +00:00
return false ;
2004-12-09 23:39:52 +00:00
}
2016-07-12 00:40:13 +00:00
void GLVID_SetCaption ( const char * text )
2009-04-06 14:19:29 +00:00
{
2014-02-07 08:38:40 +00:00
# if SDL_MAJOR_VERSION >= 2
SDL_SetWindowTitle ( sdlwindow , text ) ;
# else
SDL_WM_SetCaption ( text , NULL ) ;
# endif
2009-04-06 14:19:29 +00:00
}
2004-12-09 23:39:52 +00:00
2017-09-20 11:27:13 +00:00
# ifdef VULKAN_SDL
static qboolean VKSDL_CreateSurface ( void )
{
return SDL_Vulkan_CreateSurface ( sdlwindow , vk . instance , & vk . surface ) ;
}
static qboolean VKVID_Init ( rendererstate_t * info , unsigned char * palette )
{
unsigned extcount ;
const char * * extnames ;
if ( ! SDLVID_Init ( info , palette , QR_VULKAN ) )
return false ;
if ( ! SDL_Vulkan_GetInstanceExtensions ( sdlwindow , & extcount , NULL ) )
return false ;
extnames = alloca ( sizeof ( * extnames ) * ( extcount + 1 ) ) ;
if ( ! SDL_Vulkan_GetInstanceExtensions ( sdlwindow , & extcount , extnames ) )
return false ;
2019-05-10 09:31:21 +00:00
extnames [ extcount ] = 0 ;
2017-09-20 11:27:13 +00:00
vkGetInstanceProcAddr = SDL_Vulkan_GetVkGetInstanceProcAddr ( ) ;
if ( ! VK_Init ( info , extnames , VKSDL_CreateSurface , NULL ) )
{
SDL_ShowSimpleMessageBox ( 0 , " FTEQuake " , extnames [ 1 ] , sdlwindow ) ;
return false ;
}
return true ;
}
rendererinfo_t vkrendererinfo =
{
" Vulkan-SDL " ,
{
" vk " ,
" Vulkan "
} ,
QR_VULKAN ,
VK_Draw_Init ,
VK_Draw_Shutdown ,
VK_UpdateFiltering ,
VK_LoadTextureMips ,
VK_DestroyTexture ,
VK_R_Init ,
VK_R_DeInit ,
VK_R_RenderView ,
VKVID_Init ,
GLVID_DeInit ,
GLVID_SwapBuffers ,
GLVID_ApplyGammaRamps ,
NULL ,
NULL ,
NULL ,
GLVID_SetCaption ,
VKVID_GetRGBInfo ,
VK_SCR_UpdateScreen ,
VKBE_SelectMode ,
VKBE_DrawMesh_List ,
VKBE_DrawMesh_Single ,
VKBE_SubmitBatch ,
VKBE_GetTempBatch ,
VKBE_DrawWorld ,
VKBE_Init ,
VKBE_GenBrushModelVBO ,
VKBE_ClearVBO ,
VKBE_UploadAllLightmaps ,
VKBE_SelectEntity ,
VKBE_SelectDLight ,
VKBE_Scissor ,
VKBE_LightCullModel ,
VKBE_VBO_Begin ,
VKBE_VBO_Data ,
VKBE_VBO_Finish ,
VKBE_VBO_Destroy ,
VKBE_RenderToTextureUpdate2d ,
" no more "
} ;
# else
rendererinfo_t vkrendererinfo ;
# endif