Browse Source

Merge sdl12-port into master

pull/2/head
Alibek Omarov 5 years ago
parent
commit
0cb591821a
  1. 6
      common/backends.h
  2. 8
      common/com_model.h
  3. 1
      common/const.h
  4. 35
      common/defaults.h
  5. 3
      common/r_efx.h
  6. 4
      engine/client/cl_game.c
  7. 2
      engine/client/cl_main.c
  8. 4
      engine/client/cl_netgraph.c
  9. 4
      engine/client/client.h
  10. 18
      engine/client/input.c
  11. 20
      engine/client/keys.c
  12. 6
      engine/client/vgui/vgui_draw.c
  13. 1
      engine/client/vid_common.h
  14. 6
      engine/client/vox.h
  15. 1
      engine/common/common.c
  16. 12
      engine/common/common.h
  17. 8
      engine/common/filesystem.c
  18. 15
      engine/common/host.c
  19. 5
      engine/common/mod_local.h
  20. 4
      engine/common/net_buffer.h
  21. 46
      engine/common/net_encode.h
  22. 4
      engine/common/soundlib/soundlib.h
  23. 2
      engine/common/system.c
  24. 2
      engine/platform/android/android.c
  25. 6
      engine/platform/linux/in_evdev.c
  26. 4
      engine/platform/linux/vid_fbdev.c
  27. 25
      engine/platform/magx/sys_magx.cpp
  28. 15
      engine/platform/platform.h
  29. 2
      engine/platform/posix/sys_posix.c
  30. 289
      engine/platform/sdl/events.c
  31. 33
      engine/platform/sdl/in_sdl.c
  32. 27
      engine/platform/sdl/s_sdl.c
  33. 2
      engine/platform/sdl/sys_sdl.c
  34. 284
      engine/platform/sdl/vid_sdl.c
  35. 4
      engine/platform/win32/sys_win.c
  36. 2
      engine/ref_api.h
  37. 35
      engine/wscript
  38. 3
      game_launch/game.cpp
  39. 8
      public/build.h
  40. 10
      ref_gl/gl_image.c
  41. 9
      ref_gl/gl_local.h
  42. 6
      ref_gl/gl_opengl.c

6
common/backends.h

@ -47,4 +47,10 @@ GNU General Public License for more details. @@ -47,4 +47,10 @@ GNU General Public License for more details.
#define TIMER_LINUX 2
#define TIMER_WIN32 3
// messageboxes (XASH_MESSAGEBOX)
#define MSGBOX_STDERR 0
#define MSGBOX_SDL 1
#define MSGBOX_ANDROID 2
#define MSGBOX_WIN32 3
#endif /* BACKENDS_H */

8
common/com_model.h

@ -16,11 +16,9 @@ GNU General Public License for more details. @@ -16,11 +16,9 @@ GNU General Public License for more details.
#ifndef COM_MODEL_H
#define COM_MODEL_H
#include "xash3d_types.h"
#include "bspfile.h" // we need some declarations from it
typedef vec_t vec2_t[2];
typedef vec_t vec4_t[4];
/*
==============================================================================
@ -232,7 +230,7 @@ typedef struct mextrasurf_s @@ -232,7 +230,7 @@ typedef struct mextrasurf_s
int reserved[32]; // just for future expansions or mod-makers
} mextrasurf_t;
typedef struct msurface_s
struct msurface_s
{
int visframe; // should be drawn when node is crossed
@ -264,7 +262,7 @@ typedef struct msurface_s @@ -264,7 +262,7 @@ typedef struct msurface_s
color24 *samples; // note: this is the actual lightmap data for this surface
decal_t *pdecals;
} msurface_t;
};
typedef struct hull_s
{

1
common/const.h

@ -729,7 +729,6 @@ enum @@ -729,7 +729,6 @@ enum
typedef int func_t;
typedef int string_t;
typedef unsigned char byte;
typedef unsigned short word;
#include "xash3d_types.h"

35
common/defaults.h

@ -27,17 +27,30 @@ SETUP BACKENDS DEFINITIONS @@ -27,17 +27,30 @@ SETUP BACKENDS DEFINITIONS
*/
#ifndef XASH_DEDICATED
#ifdef XASH_SDL
#if XASH_SDL == 2
#ifndef XASH_TIMER
#define XASH_TIMER TIMER_SDL
#endif
#ifndef XASH_MESSAGEBOX
#define XASH_MESSAGEBOX MSGBOX_SDL
#endif
#else
#ifndef XASH_TIMER
#define XASH_TIMER TIMER_LINUX
#endif
#ifndef XASH_MESSAGEBOX
#define XASH_MESSAGEBOX MSGBOX_STDERR
#endif
#endif
#ifdef XASH_SDL
// by default, use SDL subsystems
#ifndef XASH_VIDEO
#define XASH_VIDEO VIDEO_SDL
#endif // XASH_VIDEO
#ifndef XASH_TIMER
#define XASH_TIMER TIMER_SDL
#endif
#ifndef XASH_INPUT
#define XASH_INPUT INPUT_SDL
#endif
@ -65,6 +78,10 @@ SETUP BACKENDS DEFINITIONS @@ -65,6 +78,10 @@ SETUP BACKENDS DEFINITIONS
#ifndef XASH_SOUND
#define XASH_SOUND SOUND_OPENSLES
#endif
#ifndef XASH_MESSAGEBOX
#define XASH_MESSAGEBOX MSGBOX_ANDROID
#endif
#endif // android case
#ifdef XASH_FBDEV
@ -83,6 +100,10 @@ SETUP BACKENDS DEFINITIONS @@ -83,6 +100,10 @@ SETUP BACKENDS DEFINITIONS
#ifndef XASH_SOUND
#define XASH_SOUND SOUND_ALSA
#endif
#ifndef XASH_MESSAGEBOX
#define XASH_MESSAGEBOX MSGBOX_STDERR
#endif
#define XASH_USE_EVDEV
#endif // android case
@ -125,6 +146,10 @@ SETUP BACKENDS DEFINITIONS @@ -125,6 +146,10 @@ SETUP BACKENDS DEFINITIONS
#define XASH_INPUT INPUT_NULL
#endif
#ifndef XASH_MESSAGEBOX
#define XASH_MESSAGEBOX MSGBOX_STDERR
#endif
/*
=========================================================================

3
common/r_efx.h

@ -84,7 +84,6 @@ color24 gTracerColors[] = @@ -84,7 +84,6 @@ color24 gTracerColors[] =
#define FTENT_CLIENTCUSTOM 0x00080000 // Must specify callback. Callback function is responsible for killing tempent and updating fields ( unless other flags specify how to do things )
#define FTENT_SCALE 0x00100000 // An experiment
typedef struct tempent_s TEMPENTITY;
struct pmtrace_s;
typedef struct tempent_s
{
@ -99,7 +98,7 @@ typedef struct tempent_s @@ -99,7 +98,7 @@ typedef struct tempent_s
int hitSound;
void (*hitcallback)( struct tempent_s *ent, struct pmtrace_s *ptr );
void (*callback)( struct tempent_s *ent, float frametime, float currenttime );
TEMPENTITY *next;
struct tempent_s *next;
int priority;
short clientIndex; // if attached, this is the index of the client to stick to
// if COLLIDEALL, this is the index of the client to ignore

4
engine/client/cl_game.c

@ -1988,7 +1988,7 @@ static int pfnGetWindowCenterX( void ) @@ -1988,7 +1988,7 @@ static int pfnGetWindowCenterX( void )
}
#endif
#ifdef XASH_SDL
#if XASH_SDL == 2
SDL_GetWindowPosition( host.hWnd, &x, NULL );
#endif
@ -2013,7 +2013,7 @@ static int pfnGetWindowCenterY( void ) @@ -2013,7 +2013,7 @@ static int pfnGetWindowCenterY( void )
}
#endif
#ifdef XASH_SDL
#if XASH_SDL == 2
SDL_GetWindowPosition( host.hWnd, NULL, &y );
#endif

2
engine/client/cl_main.c

@ -1938,7 +1938,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) @@ -1938,7 +1938,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
return;
}
#ifdef XASH_SDL
#if XASH_SDL == 2
SDL_ShowWindow( host.hWnd );
#endif
args = MSG_ReadString( msg );

4
engine/client/cl_netgraph.c

@ -16,7 +16,11 @@ GNU General Public License for more details. @@ -16,7 +16,11 @@ GNU General Public License for more details.
#include "common.h"
#include "client.h"
#if XASH_LOW_MEMORY
#define NET_TIMINGS 1024
#else
#define NET_TIMINGS 64
#endif
#define NET_TIMINGS_MASK (NET_TIMINGS - 1)
#define LATENCY_AVG_FRAC 0.5f
#define FRAMERATE_AVG_FRAC 0.5f

4
engine/client/client.h

@ -16,6 +16,7 @@ GNU General Public License for more details. @@ -16,6 +16,7 @@ GNU General Public License for more details.
#ifndef CLIENT_H
#define CLIENT_H
#include "xash3d_types.h"
#include "mathlib.h"
#include "cdll_int.h"
#include "menu_int.h"
@ -38,8 +39,6 @@ GNU General Public License for more details. @@ -38,8 +39,6 @@ GNU General Public License for more details.
#define SPR_HUDSPRITE 1 // hud sprite
#define SPR_MAPSPRITE 2 // contain overview.bmp that diced into frames 128x128
typedef int sound_t;
//=============================================================================
typedef struct netbandwithgraph_s
{
@ -1137,6 +1136,7 @@ int Key_GetKey( const char *binding ); @@ -1137,6 +1136,7 @@ int Key_GetKey( const char *binding );
void Key_EnumCmds_f( void );
void Key_SetKeyDest( int key_dest );
void Key_EnableTextInput( qboolean enable, qboolean force );
int Key_ToUpper( int key );
void OSK_Draw( void );
extern rgba_t g_color_table[8];

18
engine/client/input.c

@ -194,28 +194,30 @@ void IN_ToggleClientMouse( int newstate, int oldstate ) @@ -194,28 +194,30 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
else if( newstate == key_game )
{
// reset mouse pos, so cancel effect in game
#ifdef XASH_SDL
if( CVAR_TO_BOOL(touch_enable) )
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( CVAR_TO_BOOL( touch_enable ) )
{
SDL_SetRelativeMouseMode( SDL_FALSE );
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
}
else
#endif
{
Platform_SetMousePos( host.window_center_x, host.window_center_y );
SDL_SetWindowGrab( host.hWnd, SDL_TRUE );
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( clgame.dllFuncs.pfnLookEvent )
SDL_SetRelativeMouseMode( SDL_TRUE );
#endif
}
#endif // XASH_SDL
if( cls.initialized )
clgame.dllFuncs.IN_ActivateMouse();
}
if( ( newstate == key_menu || newstate == key_console || newstate == key_message ) && ( !CL_IsBackgroundMap() || CL_IsBackgroundDemo( )))
{
#ifdef XASH_SDL
SDL_SetWindowGrab(host.hWnd, SDL_FALSE);
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( clgame.dllFuncs.pfnLookEvent )
SDL_SetRelativeMouseMode( SDL_FALSE );
#endif
@ -316,9 +318,7 @@ void IN_DeactivateMouse( void ) @@ -316,9 +318,7 @@ void IN_DeactivateMouse( void )
}
in_mouseactive = false;
#ifdef XASH_SDL
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
#endif
}
/*
@ -416,10 +416,12 @@ void IN_MouseEvent( void ) @@ -416,10 +416,12 @@ void IN_MouseEvent( void )
}
else
{
#if defined(XASH_SDL) && !defined(_WIN32)
#if XASH_SDL && !defined(_WIN32)
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_SetRelativeMouseMode( SDL_FALSE );
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_ShowCursor( SDL_TRUE );
#endif
#endif // XASH_SDL && !defined(_WIN32)
IN_MouseMove();
}
}

20
engine/client/keys.c

@ -815,8 +815,7 @@ void Key_EnableTextInput( qboolean enable, qboolean force ) @@ -815,8 +815,7 @@ void Key_EnableTextInput( qboolean enable, qboolean force )
else if( !enable )
Platform_EnableTextInput( false );
if( !force )
host.textmode = enable;
host.textmode = enable;
}
/*
@ -907,6 +906,23 @@ void CL_CharEvent( int key ) @@ -907,6 +906,23 @@ void CL_CharEvent( int key )
}
}
/*
============
Key_ToUpper
A helper function if platform input doesn't support text mode properly
============
*/
int Key_ToUpper( int keynum )
{
keynum = Q_toupper( keynum );
if( keynum == '-' )
keynum = '_';
if( keynum == '=' )
keynum = '+';
return keynum;
}
/* On-screen keyboard:
*

6
engine/client/vgui/vgui_draw.c

@ -25,7 +25,7 @@ GNU General Public License for more details. @@ -25,7 +25,7 @@ GNU General Public License for more details.
#include "ref_common.h"
#include "input.h"
#ifdef XASH_SDL
#include <SDL_events.h>
#include <SDL.h>
static SDL_Cursor* s_pDefaultCursor[20];
#endif
#include "platform/platform.h"
@ -72,7 +72,7 @@ void GAME_EXPORT VGUI_GetMousePos( int *_x, int *_y ) @@ -72,7 +72,7 @@ void GAME_EXPORT VGUI_GetMousePos( int *_x, int *_y )
void VGUI_InitCursors( void )
{
// load up all default cursors
#ifdef XASH_SDL
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
s_pDefaultCursor[dc_none] = NULL;
s_pDefaultCursor[dc_arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
s_pDefaultCursor[dc_ibeam] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
@ -108,7 +108,7 @@ void GAME_EXPORT VGUI_CursorSelect(enum VGUI_DefaultCursor cursor ) @@ -108,7 +108,7 @@ void GAME_EXPORT VGUI_CursorSelect(enum VGUI_DefaultCursor cursor )
break;
}
#ifdef XASH_SDL
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
/// TODO: platform cursors
if( CVAR_TO_BOOL( touch_emulate ) )

1
engine/client/vid_common.h

@ -16,7 +16,6 @@ typedef struct @@ -16,7 +16,6 @@ typedef struct
int safe;
int desktopBitsPixel;
int desktopWidth;
int desktopHeight;
qboolean initialized; // OpenGL subsystem started

6
engine/client/vox.h

@ -41,8 +41,8 @@ typedef struct @@ -41,8 +41,8 @@ typedef struct
float length;
} sentence_t;
typedef struct channel_s channel_t;
void VOX_LoadWord( channel_t *pchan );
void VOX_FreeWord( channel_t *pchan );
struct channel_s;
void VOX_LoadWord( struct channel_s *pchan );
void VOX_FreeWord( struct channel_s *pchan );
#endif

1
engine/common/common.c

@ -19,6 +19,7 @@ GNU General Public License for more details. @@ -19,6 +19,7 @@ GNU General Public License for more details.
#include "const.h"
#include "client.h"
#include "library.h"
#include "sequence.h"
static const char *file_exts[] =
{

12
engine/common/common.h

@ -832,7 +832,7 @@ void HPAK_FlushHostQueue( void ); @@ -832,7 +832,7 @@ void HPAK_FlushHostQueue( void );
// shared calls
struct physent_s;
typedef struct sv_client_s sv_client_t;
struct sv_client_s;
typedef struct sizebuf_s sizebuf_t;
qboolean CL_IsInGame( void );
qboolean CL_IsInMenu( void );
@ -861,7 +861,7 @@ void SV_CreateDecal( sizebuf_t *msg, const float *origin, int decalIndex, int en @@ -861,7 +861,7 @@ void SV_CreateDecal( sizebuf_t *msg, const float *origin, int decalIndex, int en
void Log_Printf( const char *fmt, ... ) _format( 1 );
void SV_BroadcastCommand( const char *fmt, ... ) _format( 1 );
qboolean SV_RestoreCustomDecal( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent );
void SV_BroadcastPrintf( sv_client_t *ignore, char *fmt, ... ) _format( 2 );
void SV_BroadcastPrintf( struct sv_client_s *ignore, char *fmt, ... ) _format( 2 );
int R_CreateDecalList( struct decallist_s *pList );
void R_ClearAllDecals( void );
void CL_ClearStaticEntities( void );
@ -963,14 +963,6 @@ void ID_Init( void ); @@ -963,14 +963,6 @@ void ID_Init( void );
const char *ID_GetMD5( void );
void GAME_EXPORT ID_SetCustomClientID( const char *id );
//
// sequence.c
//
typedef struct sequenceEntry_ sequenceEntry_s;
typedef struct sentenceEntry_ sentenceEntry_s;
sequenceEntry_s *Sequence_Get( const char *fileName, const char *entryName );
sentenceEntry_s *Sequence_PickSentence( const char *groupName, int pickMethod, int *picked );
//
// masterlist.c
//

8
engine/common/filesystem.c

@ -74,7 +74,7 @@ typedef struct wadtype_s @@ -74,7 +74,7 @@ typedef struct wadtype_s
signed char type;
} wadtype_t;
typedef struct file_s
struct file_s
{
int handle; // file descriptor
fs_offset_t real_length; // uncompressed file size (for files opened in "read" mode)
@ -85,9 +85,9 @@ typedef struct file_s @@ -85,9 +85,9 @@ typedef struct file_s
// contents buffer
fs_offset_t buff_ind, buff_len; // buffer current index and length
byte buff[FILE_BUFF_SIZE]; // intermediate buffer
} file_t;
};
typedef struct wfile_s
struct wfile_s
{
string filename;
int infotableofs;
@ -96,7 +96,7 @@ typedef struct wfile_s @@ -96,7 +96,7 @@ typedef struct wfile_s
file_t *handle;
dlumpinfo_t *lumps;
time_t filetime;
} wfile_t;
};
typedef struct pack_s
{

15
engine/common/host.c

@ -733,7 +733,7 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha @@ -733,7 +733,7 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
#if TARGET_OS_IOS
const char *IOS_GetDocsDir();
Q_strncpy( host.rootdir, IOS_GetDocsDir(), sizeof(host.rootdir) );
#elif defined(XASH_SDL)
#elif XASH_SDL == 2
char *szBasePath;
if( !( szBasePath = SDL_GetBasePath() ) )
@ -814,18 +814,21 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha @@ -814,18 +814,21 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
#endif
#ifdef XASH_SDL
// should work even if it failed
SDL_Init( SDL_INIT_TIMER );
#ifndef SDL_INIT_EVENTS
#define SDL_INIT_EVENTS 0
#endif
if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_EVENTS ) )
if( SDL_Init( SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_EVENTS ) )
{
Sys_Warn( "SDL_Init failed: %s", SDL_GetError() );
host.type = HOST_DEDICATED;
}
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
#if XASH_SDL == 2
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
SDL_StopTextInput();
#endif
#endif // XASH_SDL == 2
#endif // XASH_SDL
if ( !host.rootdir[0] || SetCurrentDirectory( host.rootdir ) != 0)
Con_Reportf( "%s is working directory now\n", host.rootdir );

5
engine/common/mod_local.h

@ -20,6 +20,7 @@ GNU General Public License for more details. @@ -20,6 +20,7 @@ GNU General Public License for more details.
#include "edict.h"
#include "eiface.h"
#include "ref_api.h"
#include "studio.h"
#define LM_SAMPLE_SIZE 16
#define LM_SAMPLE_EXTRASIZE 8
@ -172,10 +173,6 @@ void Mod_ReleaseHullPolygons( void ); @@ -172,10 +173,6 @@ void Mod_ReleaseHullPolygons( void );
//
// mod_studio.c
//
typedef struct studiohdr_s studiohdr_t;
typedef struct mstudioseqdesc_s mstudioseqdesc_t;
typedef struct mstudiobone_s mstudiobone_t;
typedef struct mstudioanim_s mstudioanim_t;
void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded );
void Mod_UnloadStudioModel( model_t *mod );
void Mod_InitStudioAPI( void );

4
engine/common/net_buffer.h

@ -35,7 +35,7 @@ _inline int BitByte( int bits ) @@ -35,7 +35,7 @@ _inline int BitByte( int bits )
return PAD_NUMBER( bits, 8 ) >> 3;
}
typedef struct sizebuf_s
struct sizebuf_s
{
qboolean bOverflow; // overflow reading or writing
const char *pDebugName; // buffer name (pointer to const name)
@ -43,7 +43,7 @@ typedef struct sizebuf_s @@ -43,7 +43,7 @@ typedef struct sizebuf_s
byte *pData;
int iCurBit;
int nDataBits;
} sizebuf_t;
};
#define MSG_StartReading MSG_StartWriting
#define MSG_GetNumBytesRead MSG_GetNumBytesWritten

46
engine/common/net_encode.h

@ -16,6 +16,8 @@ GNU General Public License for more details. @@ -16,6 +16,8 @@ GNU General Public License for more details.
#ifndef NET_ENCODE_H
#define NET_ENCODE_H
#include "eiface.h"
#define DT_BYTE BIT( 0 ) // A byte
#define DT_SHORT BIT( 1 ) // 2 byte field
#define DT_FLOAT BIT( 2 ) // A floating point field
@ -62,7 +64,7 @@ typedef struct @@ -62,7 +64,7 @@ typedef struct
} delta_field_t;
// one field
typedef struct delta_s
struct delta_s
{
const char *name;
int offset; // in bytes
@ -72,9 +74,9 @@ typedef struct delta_s @@ -72,9 +74,9 @@ typedef struct delta_s
float post_multiplier; // for DEFINE_DELTA_POST
int bits; // how many bits we send\receive
qboolean bInactive; // unsetted by user request
} delta_t;
};
typedef void (*pfnDeltaEncode)( delta_t *pFields, const byte *from, const byte *to );
typedef void (*pfnDeltaEncode)( struct delta_s *pFields, const byte *from, const byte *to );
typedef struct
{
@ -113,24 +115,24 @@ void Delta_ParseTableField( sizebuf_t *msg ); @@ -113,24 +115,24 @@ void Delta_ParseTableField( sizebuf_t *msg );
// encode routines
typedef struct entity_state_s entity_state_t;
typedef struct usercmd_s usercmd_t;
typedef struct event_args_s event_args_t;
typedef struct movevars_s movevars_t;
typedef struct clientdata_s clientdata_t;
typedef struct weapon_data_s weapon_data_t;
void MSG_WriteDeltaUsercmd( sizebuf_t *msg, usercmd_t *from, usercmd_t *to );
void MSG_ReadDeltaUsercmd( sizebuf_t *msg, usercmd_t *from, usercmd_t *to );
void MSG_WriteDeltaEvent( sizebuf_t *msg, event_args_t *from, event_args_t *to );
void MSG_ReadDeltaEvent( sizebuf_t *msg, event_args_t *from, event_args_t *to );
qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, movevars_t *from, movevars_t *to );
void MSG_ReadDeltaMovevars( sizebuf_t *msg, movevars_t *from, movevars_t *to );
void MSG_WriteClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to, float timebase );
void MSG_ReadClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to, float timebase );
void MSG_WriteWeaponData( sizebuf_t *msg, weapon_data_t *from, weapon_data_t *to, float timebase, int index );
void MSG_ReadWeaponData( sizebuf_t *msg, weapon_data_t *from, weapon_data_t *to, float timebase );
void MSG_WriteDeltaEntity( entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qboolean force, int type, float tbase, int ofs );
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state_t *to, int num, int type, float timebase );
int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean player, float timebase );
struct entity_state_s;
struct usercmd_s;
struct event_args_s;
struct movevars_s;
struct clientdata_s;
struct weapon_data_s;
void MSG_WriteDeltaUsercmd( sizebuf_t *msg, struct usercmd_s *from, struct usercmd_s *to );
void MSG_ReadDeltaUsercmd( sizebuf_t *msg, struct usercmd_s *from, struct usercmd_s *to );
void MSG_WriteDeltaEvent( sizebuf_t *msg, struct event_args_s *from, struct event_args_s *to );
void MSG_ReadDeltaEvent( sizebuf_t *msg, struct event_args_s *from, struct event_args_s *to );
qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, struct movevars_s *from, struct movevars_s *to );
void MSG_ReadDeltaMovevars( sizebuf_t *msg, struct movevars_s *from, struct movevars_s *to );
void MSG_WriteClientData( sizebuf_t *msg, struct clientdata_s *from, struct clientdata_s *to, float timebase );
void MSG_ReadClientData( sizebuf_t *msg, struct clientdata_s *from, struct clientdata_s *to, float timebase );
void MSG_WriteWeaponData( sizebuf_t *msg, struct weapon_data_s *from, struct weapon_data_s *to, float timebase, int index );
void MSG_ReadWeaponData( sizebuf_t *msg, struct weapon_data_s *from, struct weapon_data_s *to, float timebase );
void MSG_WriteDeltaEntity( struct entity_state_s *from, struct entity_state_s *to, sizebuf_t *msg, qboolean force, int type, float tbase, int ofs );
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, struct entity_state_s *from, struct entity_state_s *to, int num, int type, float timebase );
int Delta_TestBaseline( struct entity_state_s *from, struct entity_state_s *to, qboolean player, float timebase );
#endif//NET_ENCODE_H

4
engine/common/soundlib/soundlib.h

@ -60,7 +60,7 @@ typedef struct sndlib_s @@ -60,7 +60,7 @@ typedef struct sndlib_s
int cmd_flags;
} sndlib_t;
typedef struct stream_s
struct stream_s
{
const streamfmt_t *format; // streamformat to operate
@ -77,7 +77,7 @@ typedef struct stream_s @@ -77,7 +77,7 @@ typedef struct stream_s
char temp[OUTBUF_SIZE]; // mpeg decoder stuff
size_t pos; // actual track position (or actual buffer remains)
int buffsize; // cached buffer size
} stream_t;
};
/*
========================================================================

2
engine/common/system.c

@ -426,7 +426,7 @@ void Sys_Error( const char *error, ... ) @@ -426,7 +426,7 @@ void Sys_Error( const char *error, ... )
if( !Host_IsDedicated() )
{
#ifdef XASH_SDL
#if XASH_SDL == 2
if( host.hWnd ) SDL_HideWindow( host.hWnd );
#endif
}

2
engine/platform/android/android.c

@ -645,10 +645,12 @@ Android_MessageBox @@ -645,10 +645,12 @@ Android_MessageBox
Show messagebox and wait for OK button press
========================
*/
#if XASH_MESSAGEBOX == MSGBOX_ANDROID
void Platform_MessageBox( const char *title, const char *text, qboolean parentMainWindow )
{
(*jni.env)->CallStaticVoidMethod( jni.env, jni.actcls, jni.messageBox, (*jni.env)->NewStringUTF( jni.env, title ), (*jni.env)->NewStringUTF( jni.env ,text ) );
}
#endif // XASH_MESSAGEBOX == MSGBOX_ANDROID
/*
========================

6
engine/platform/linux/in_evdev.c

@ -378,11 +378,7 @@ void IN_EvdevFrame ( void ) @@ -378,11 +378,7 @@ void IN_EvdevFrame ( void )
{
if( evdev.shift )
{
key = Q_toupper( key );
if( key == '-' )
key = '_';
if( key == '=' )
key = '+';
key = Key_ToUpper( key );
}
CL_CharEvent( key );
}

4
engine/platform/linux/vid_fbdev.c

@ -268,10 +268,6 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * @@ -268,10 +268,6 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *
}
// unrelated stubs
void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow )
{
}
void Platform_GetClipboardText( char *buffer, size_t size )
{

25
engine/platform/magx/sys_magx.cpp

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
/*
sys_magx.cpp - MotoMAGX system utils
Copyright (C) 2019 a1batross
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "platform/platform.h"
#include <ZApplication.h>
typedef void (*pfnChangeGame)( const char *progname );
extern "C" int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func );
extern "C" int EXPORT Platform_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func )
{
ZApplication app( argc, argv );
return Host_Main( argc, argv, progname, bChangeGame, func );
}

15
engine/platform/platform.h

@ -73,6 +73,16 @@ void Platform_PreCreateMove( void ); @@ -73,6 +73,16 @@ void Platform_PreCreateMove( void );
void Platform_GetClipboardText( char *buffer, size_t size );
void Platform_SetClipboardText( const char *buffer, size_t size );
#if XASH_SDL == 12
#define SDL_SetWindowGrab( wnd, state ) SDL_WM_GrabInput( (state) )
#define SDL_MinimizeWindow( wnd ) SDL_WM_IconifyWindow()
#define SDL_IsTextInputActive() host.textmode
#endif
#if !XASH_SDL
#define SDL_VERSION_ATLEAST( x, y, z ) 0
#endif
#ifdef __ANDROID__
void Android_ShowMouse( qboolean show );
void Android_MouseMove( float *x, float *y );
@ -93,15 +103,14 @@ typedef enum @@ -93,15 +103,14 @@ typedef enum
rserr_unknown
} rserr_t;
typedef struct vidmode_s vidmode_t;
struct vidmode_s;
// 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 );
int R_MaxVideoModes( void );
vidmode_t*R_GetVideoMode( int num );
struct vidmode_s *R_GetVideoMode( int num );
void* GL_GetProcAddress( const char *name ); // RenderAPI requirement
void GL_UpdateSwapInterval( void );
int GL_SetAttribute( int attr, int val );

2
engine/platform/posix/sys_posix.c

@ -92,7 +92,7 @@ void Platform_ShellExecute( const char *path, const char *parms ) @@ -92,7 +92,7 @@ void Platform_ShellExecute( const char *path, const char *parms )
}
#endif // __ANDROID__
#ifdef XASH_DEDICATED
#if XASH_MESSAGEBOX == MSGBOX_STDERR
void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow )
{
fprintf( stderr,

289
engine/platform/sdl/events.c

@ -15,6 +15,7 @@ GNU General Public License for more details. @@ -15,6 +15,7 @@ GNU General Public License for more details.
#if defined( XASH_SDL ) && !defined( XASH_DEDICATED )
#include <SDL.h>
#include <ctype.h>
#include "common.h"
#include "keydefs.h"
@ -27,6 +28,71 @@ GNU General Public License for more details. @@ -27,6 +28,71 @@ GNU General Public License for more details.
static int wheelbutton;
#if ! SDL_VERSION_ATLEAST( 2, 0, 0 )
#define SDL_SCANCODE_A SDLK_a
#define SDL_SCANCODE_Z SDLK_z
#define SDL_SCANCODE_1 SDLK_1
#define SDL_SCANCODE_9 SDLK_9
#define SDL_SCANCODE_F1 SDLK_F1
#define SDL_SCANCODE_F12 SDLK_F12
#define SDL_SCANCODE_GRAVE SDLK_BACKQUOTE
#define SDL_SCANCODE_0 SDLK_0
#define SDL_SCANCODE_BACKSLASH SDLK_BACKSLASH
#define SDL_SCANCODE_LEFTBRACKET SDLK_LEFTBRACKET
#define SDL_SCANCODE_RIGHTBRACKET SDLK_RIGHTBRACKET
#define SDL_SCANCODE_EQUALS SDLK_EQUALS
#define SDL_SCANCODE_MINUS SDLK_MINUS
#define SDL_SCANCODE_TAB SDLK_TAB
#define SDL_SCANCODE_RETURN SDLK_RETURN
#define SDL_SCANCODE_ESCAPE SDLK_ESCAPE
#define SDL_SCANCODE_SPACE SDLK_SPACE
#define SDL_SCANCODE_BACKSPACE SDLK_BACKSPACE
#define SDL_SCANCODE_UP SDLK_UP
#define SDL_SCANCODE_LEFT SDLK_LEFT
#define SDL_SCANCODE_DOWN SDLK_DOWN
#define SDL_SCANCODE_RIGHT SDLK_RIGHT
#define SDL_SCANCODE_LALT SDLK_LALT
#define SDL_SCANCODE_RALT SDLK_RALT
#define SDL_SCANCODE_LCTRL SDLK_LCTRL
#define SDL_SCANCODE_RCTRL SDLK_RCTRL
#define SDL_SCANCODE_LSHIFT SDLK_LSHIFT
#define SDL_SCANCODE_RSHIFT SDLK_RSHIFT
#define SDL_SCANCODE_LGUI SDLK_LMETA
#define SDL_SCANCODE_RGUI SDLK_RMETA
#define SDL_SCANCODE_INSERT SDLK_INSERT
#define SDL_SCANCODE_DELETE SDLK_DELETE
#define SDL_SCANCODE_PAGEDOWN SDLK_PAGEDOWN
#define SDL_SCANCODE_PAGEUP SDLK_PAGEUP
#define SDL_SCANCODE_HOME SDLK_HOME
#define SDL_SCANCODE_END SDLK_END
#define SDL_SCANCODE_KP_1 SDLK_KP1
#define SDL_SCANCODE_KP_2 SDLK_KP2
#define SDL_SCANCODE_KP_3 SDLK_KP3
#define SDL_SCANCODE_KP_4 SDLK_KP4
#define SDL_SCANCODE_KP_5 SDLK_KP5
#define SDL_SCANCODE_KP_6 SDLK_KP6
#define SDL_SCANCODE_KP_7 SDLK_KP7
#define SDL_SCANCODE_KP_8 SDLK_KP8
#define SDL_SCANCODE_KP_9 SDLK_KP9
#define SDL_SCANCODE_KP_0 SDLK_KP0
#define SDL_SCANCODE_KP_PERIOD SDLK_KP_PERIOD
#define SDL_SCANCODE_KP_ENTER SDLK_KP_ENTER
#define SDL_SCANCODE_KP_PLUS SDLK_KP_PLUS
#define SDL_SCANCODE_KP_MINUS SDLK_KP_MINUS
#define SDL_SCANCODE_KP_DIVIDE SDLK_KP_DIVIDE
#define SDL_SCANCODE_KP_MULTIPLY SDLK_KP_MULTIPLY
#define SDL_SCANCODE_NUMLOCKCLEAR SDLK_NUMLOCK
#define SDL_SCANCODE_CAPSLOCK SDLK_CAPSLOCK
#define SDL_SCANCODE_SLASH SDLK_SLASH
#define SDL_SCANCODE_PERIOD SDLK_PERIOD
#define SDL_SCANCODE_SEMICOLON SDLK_SEMICOLON
#define SDL_SCANCODE_APOSTROPHE SDLK_QUOTE
#define SDL_SCANCODE_COMMA SDLK_COMMA
#define SDL_SCANCODE_PRINTSCREEN SDLK_PRINT
#define SDL_SCANCODE_UNKNOWN SDLK_UNKNOWN
#define SDL_GetScancodeName( x ) "unknown"
#endif
/*
=============
SDLash_KeyEvent
@ -36,7 +102,11 @@ SDLash_KeyEvent @@ -36,7 +102,11 @@ SDLash_KeyEvent
static void SDLash_KeyEvent( SDL_KeyboardEvent key )
{
int down = key.state != SDL_RELEASED;
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
int keynum = key.keysym.scancode;
#else
int keynum = key.keysym.sym;
#endif
qboolean numLock = SDL_GetModState() & KMOD_NUM;
if( SDL_IsTextInputActive() && down )
@ -51,6 +121,22 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) @@ -51,6 +121,22 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key )
return;
}
#if !SDL_VERSION_ATLEAST( 2, 0, 0 )
if( keynum >= SDLK_KP0 && keynum <= SDLK_KP9 )
keynum -= SDLK_KP0 + '0';
if( isprint( keynum ) )
{
if( SDL_GetModState() & KMOD_SHIFT )
{
keynum = Key_ToUpper( keynum );
}
CL_CharEvent( keynum );
return;
}
#endif
}
#define DECLARE_KEY_RANGE( min, max, repl ) \
@ -62,7 +148,6 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) @@ -62,7 +148,6 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key )
DECLARE_KEY_RANGE( SDL_SCANCODE_A, SDL_SCANCODE_Z, 'a' )
else DECLARE_KEY_RANGE( SDL_SCANCODE_1, SDL_SCANCODE_9, '1' )
else DECLARE_KEY_RANGE( SDL_SCANCODE_F1, SDL_SCANCODE_F12, K_F1 )
#undef DECLARE_KEY_RANGE
else
{
switch( keynum )
@ -115,7 +200,6 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) @@ -115,7 +200,6 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key )
case SDL_SCANCODE_KP_MULTIPLY: keynum = '*'; break;
case SDL_SCANCODE_NUMLOCKCLEAR: keynum = K_KP_NUMLOCK; break;
case SDL_SCANCODE_CAPSLOCK: keynum = K_CAPSLOCK; break;
case SDL_SCANCODE_APPLICATION: keynum = K_WIN; break; // (compose key) ???
case SDL_SCANCODE_SLASH: keynum = '/'; break;
case SDL_SCANCODE_PERIOD: keynum = '.'; break;
case SDL_SCANCODE_SEMICOLON: keynum = ';'; break;
@ -127,6 +211,8 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) @@ -127,6 +211,8 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key )
host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME;
break;
}
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
case SDL_SCANCODE_APPLICATION: keynum = K_WIN; break; // (compose key) ???
// don't console spam on known functional buttons, but not used in engine
case SDL_SCANCODE_MUTE:
case SDL_SCANCODE_VOLUMEUP:
@ -134,6 +220,7 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) @@ -134,6 +220,7 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key )
case SDL_SCANCODE_BRIGHTNESSDOWN:
case SDL_SCANCODE_BRIGHTNESSUP:
return;
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
case SDL_SCANCODE_UNKNOWN:
{
if( down ) Con_Reportf( "SDLash_KeyEvent: Unknown scancode\n" );
@ -145,9 +232,23 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) @@ -145,9 +232,23 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key )
}
}
#undef DECLARE_KEY_RANGE
Key_Event( keynum, down );
}
static void SDLash_MouseKey( int key, int down, int istouch )
{
if( CVAR_TO_BOOL( touch_emulate ) )
{
Touch_KeyEvent( key, down );
}
else if( in_mouseinitialized && !m_ignore->value && !istouch )
{
Key_Event( key, down );
}
}
/*
=============
SDLash_MouseEvent
@ -157,14 +258,41 @@ SDLash_MouseEvent @@ -157,14 +258,41 @@ SDLash_MouseEvent
static void SDLash_MouseEvent( SDL_MouseButtonEvent button )
{
int down = button.state != SDL_RELEASED;
qboolean istouch;
if( CVAR_TO_BOOL( touch_emulate ) )
{
Touch_KeyEvent( K_MOUSE1 - 1 + button.button, down );
}
else if( in_mouseinitialized && !m_ignore->value && button.which != SDL_TOUCH_MOUSEID )
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
istouch = button.which == SDL_TOUCH_MOUSEID;
#else // SDL_VERSION_ATLEAST( 2, 0, 0 )
istouch = false;
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
switch( button.button )
{
Key_Event( K_MOUSE1 - 1 + button.button, down );
case SDL_BUTTON_LEFT:
SDLash_MouseKey( K_MOUSE1, down, istouch );
break;
case SDL_BUTTON_RIGHT:
SDLash_MouseKey( K_MOUSE2, down, istouch );
break;
case SDL_BUTTON_MIDDLE:
SDLash_MouseKey( K_MOUSE3, down, istouch );
break;
case SDL_BUTTON_X1:
SDLash_MouseKey( K_MOUSE4, down, istouch );
break;
case SDL_BUTTON_X2:
SDLash_MouseKey( K_MOUSE5, down, istouch );
break;
#if ! SDL_VERSION_ATLEAST( 2, 0, 0 )
case SDL_BUTTON_WHEELUP:
Key_Event( K_MWHEELUP, down );
break;
case SDL_BUTTON_WHEELDOWN:
Key_Event( K_MWHEELDOWN, down );
break;
#endif // ! SDL_VERSION_ATLEAST( 2, 0, 0 )
default:
Con_Printf( "Unknown mouse button ID: %d\n", button.button );
}
}
@ -174,6 +302,7 @@ SDLash_InputEvent @@ -174,6 +302,7 @@ SDLash_InputEvent
=============
*/
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
static void SDLash_InputEvent( SDL_TextInputEvent input )
{
char *text;
@ -192,6 +321,43 @@ static void SDLash_InputEvent( SDL_TextInputEvent input ) @@ -192,6 +321,43 @@ static void SDLash_InputEvent( SDL_TextInputEvent input )
CL_CharEvent( ch );
}
}
#endif // SDL_VERSION_AT_LEAST( 2, 0, 0 )
static void SDLash_ActiveEvent( int gain )
{
if( gain )
{
host.status = HOST_FRAME;
IN_ActivateMouse(true);
if( snd_mute_losefocus->value )
{
SNDDMA_Activate( true );
}
host.force_draw_version = true;
host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME;
if( vid_fullscreen->value )
VID_SetMode();
}
else
{
#if TARGET_OS_IPHONE
{
// Keep running if ftp server enabled
void IOS_StartBackgroundTask( void );
IOS_StartBackgroundTask();
}
#endif
host.status = HOST_NOFOCUS;
IN_DeactivateMouse();
if( snd_mute_losefocus->value )
{
SNDDMA_Activate( false );
}
host.force_draw_version = true;
host.force_draw_version_time = host.realtime + 2;
VID_RestoreScreenResolution();
}
}
/*
=============
@ -213,27 +379,53 @@ static void SDLash_EventFilter( SDL_Event *event ) @@ -213,27 +379,53 @@ static void SDLash_EventFilter( SDL_Event *event )
{
/* Mouse events */
case SDL_MOUSEMOTION:
if( !host.mouse_visible && event->motion.which != SDL_TOUCH_MOUSEID )
if( !host.mouse_visible
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
&& event->motion.which != SDL_TOUCH_MOUSEID )
#else
)
#endif
IN_MouseEvent();
break;
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN:
SDLash_MouseEvent( event->button );
break;
case SDL_MOUSEWHEEL:
wheelbutton = event->wheel.y < 0 ? K_MWHEELDOWN : K_MWHEELUP;
Key_Event( wheelbutton, true );
break;
/* Keyboard events */
case SDL_KEYDOWN:
case SDL_KEYUP:
SDLash_KeyEvent( event->key );
break;
/* Joystick events */
case SDL_JOYAXISMOTION:
Joy_AxisMotionEvent( event->jaxis.axis, event->jaxis.value );
break;
case SDL_JOYBALLMOTION:
Joy_BallMotionEvent( event->jball.ball, event->jball.xrel, event->jball.yrel );
break;
case SDL_JOYHATMOTION:
Joy_HatMotionEvent( event->jhat.hat, event->jhat.value );
break;
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
Joy_ButtonEvent( event->jbutton.button, event->jbutton.state );
break;
case SDL_QUIT:
Sys_Quit();
break;
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
case SDL_MOUSEWHEEL:
wheelbutton = event->wheel.y < 0 ? K_MWHEELDOWN : K_MWHEELUP;
Key_Event( wheelbutton, true );
break;
/* Touch events */
case SDL_FINGERDOWN:
case SDL_FINGERUP:
@ -247,7 +439,7 @@ static void SDLash_EventFilter( SDL_Event *event ) @@ -247,7 +439,7 @@ static void SDLash_EventFilter( SDL_Event *event )
type = event_down;
else if( event->type == SDL_FINGERUP )
type = event_up ;
else if(event->type == SDL_FINGERMOTION )
else if( event->type == SDL_FINGERMOTION )
type = event_motion;
else break;
@ -288,30 +480,11 @@ static void SDLash_EventFilter( SDL_Event *event ) @@ -288,30 +480,11 @@ static void SDLash_EventFilter( SDL_Event *event )
break;
}
/* IME */
case SDL_TEXTINPUT:
SDLash_InputEvent( event->text );
break;
/* Joystick events */
case SDL_JOYAXISMOTION:
Joy_AxisMotionEvent( event->jaxis.axis, event->jaxis.value );
break;
case SDL_JOYBALLMOTION:
Joy_BallMotionEvent( event->jball.ball, event->jball.xrel, event->jball.yrel );
break;
case SDL_JOYHATMOTION:
Joy_HatMotionEvent( event->jhat.hat, event->jhat.value );
break;
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
Joy_ButtonEvent( event->jbutton.button, event->jbutton.state );
break;
case SDL_JOYDEVICEADDED:
Joy_AddEvent();
break;
@ -361,10 +534,6 @@ static void SDLash_EventFilter( SDL_Event *event ) @@ -361,10 +534,6 @@ static void SDLash_EventFilter( SDL_Event *event )
Joy_RemoveEvent( );
break;
case SDL_QUIT:
Sys_Quit();
break;
case SDL_WINDOWEVENT:
if( event->window.windowID != SDL_GetWindowID( host.hWnd ) )
return;
@ -393,47 +562,33 @@ static void SDLash_EventFilter( SDL_Event *event ) @@ -393,47 +562,33 @@ static void SDLash_EventFilter( SDL_Event *event )
VID_SetMode();
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
host.status = HOST_FRAME;
IN_ActivateMouse(true);
if( snd_mute_losefocus->value )
{
SNDDMA_Activate( true );
}
host.force_draw_version = true;
host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME;
if( vid_fullscreen->value )
VID_SetMode();
SDLash_ActiveEvent( true );
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
#if TARGET_OS_IPHONE
{
// Keep running if ftp server enabled
void IOS_StartBackgroundTask( void );
IOS_StartBackgroundTask();
}
#endif
host.status = HOST_NOFOCUS;
IN_DeactivateMouse();
if( snd_mute_losefocus->value )
{
SNDDMA_Activate( false );
}
host.force_draw_version = true;
host.force_draw_version_time = host.realtime + 2;
VID_RestoreScreenResolution();
SDLash_ActiveEvent( false );
break;
case SDL_WINDOWEVENT_RESIZED:
{
int w = VID_MIN_WIDTH, h = VID_MIN_HEIGHT;
if( vid_fullscreen->value )
break;
VID_SaveWindowSize( event->window.data1, event->window.data2 );
SCR_VidInit(); // tell the client.dll what vid_mode has changed
VID_SaveWindowSize( w, h );
SCR_VidInit(); // tell the client.dll that vid_mode has changed
break;
}
default:
break;
}
#else
case SDL_VIDEORESIZE:
VID_SaveWindowSize( event->resize.w, event->resize.h );
SCR_VidInit();
break; // tell the client.dll that vid_mode has changed
case SDL_ACTIVEEVENT:
SDLash_ActiveEvent( event->active.gain );
break;
#endif
}
}

33
engine/platform/sdl/in_sdl.c

@ -25,7 +25,13 @@ GNU General Public License for more details. @@ -25,7 +25,13 @@ GNU General Public License for more details.
#include "vid_common.h"
static SDL_Joystick *joy;
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
static SDL_GameController *gamecontroller;
#else // SDL_VERSION_ATLEAST( 2, 0, 0 )
#define SDL_WarpMouseInWindow( win, x, y ) SDL_WarpMouse( ( x ), ( y ) )
#endif
/*
=============
@ -57,6 +63,7 @@ Platform_GetClipobardText @@ -57,6 +63,7 @@ Platform_GetClipobardText
*/
void Platform_GetClipboardText( char *buffer, size_t size )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
char *sdlbuffer = SDL_GetClipboardText();
if( !sdlbuffer )
@ -64,6 +71,9 @@ void Platform_GetClipboardText( char *buffer, size_t size ) @@ -64,6 +71,9 @@ void Platform_GetClipboardText( char *buffer, size_t size )
Q_strncpy( buffer, sdlbuffer, size );
SDL_free( sdlbuffer );
#else // SDL_VERSION_ATLEAST( 2, 0, 0 )
buffer[0] = 0;
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
}
/*
@ -74,7 +84,9 @@ Platform_SetClipobardText @@ -74,7 +84,9 @@ Platform_SetClipobardText
*/
void Platform_SetClipboardText( const char *buffer, size_t size )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_SetClipboardText( buffer );
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
}
/*
@ -96,7 +108,9 @@ SDLash_EnableTextInput @@ -96,7 +108,9 @@ SDLash_EnableTextInput
*/
void Platform_EnableTextInput( qboolean enable )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
enable ? SDL_StartTextInput() : SDL_StopTextInput();
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
}
/*
@ -134,8 +148,10 @@ static int SDLash_JoyInit_Old( int numjoy ) @@ -134,8 +148,10 @@ static int SDLash_JoyInit_Old( int numjoy )
return 0;
}
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
for( i = 0; i < num; i++ )
Con_Reportf( "%i\t: %s\n", i, SDL_JoystickNameForIndex( i ) );
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
Con_Reportf( "Pass +set joy_index N to command line, where N is number, to select active joystick\n" );
@ -147,6 +163,7 @@ static int SDLash_JoyInit_Old( int numjoy ) @@ -147,6 +163,7 @@ static int SDLash_JoyInit_Old( int numjoy )
return 0;
}
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
Con_Reportf( "Selected joystick: %s\n"
"\tAxes: %i\n"
"\tHats: %i\n"
@ -156,11 +173,13 @@ static int SDLash_JoyInit_Old( int numjoy ) @@ -156,11 +173,13 @@ static int SDLash_JoyInit_Old( int numjoy )
SDL_JoystickNumButtons( joy ), SDL_JoystickNumBalls( joy ) );
SDL_GameControllerEventState( SDL_DISABLE );
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_JoystickEventState( SDL_ENABLE );
return num;
}
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
/*
=============
SDLash_JoyInit_New
@ -219,18 +238,19 @@ static int SDLash_JoyInit_New( int numjoy ) @@ -219,18 +238,19 @@ static int SDLash_JoyInit_New( int numjoy )
return 0;
}
// was added in SDL2-2.0.6, allow build with earlier versions just in case
#if SDL_MAJOR_VERSION > 2 || SDL_MINOR_VERSION > 0 || SDL_PATCHLEVEL >= 6
#if SDL_VERSION_ATLEAST( 2, 0, 6 )
Con_Reportf( "Selected joystick: %s (%i:%i:%i)\n",
SDL_GameControllerName( gamecontroller ),
SDL_GameControllerGetVendor( gamecontroller ),
SDL_GameControllerGetProduct( gamecontroller ),
SDL_GameControllerGetProductVersion( gamecontroller ));
#endif
#endif // SDL_VERSION_ATLEAST( 2, 0, 6 )
SDL_GameControllerEventState( SDL_ENABLE );
SDL_JoystickEventState( SDL_DISABLE );
return num;
}
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
/*
=============
@ -240,12 +260,13 @@ Platform_JoyInit @@ -240,12 +260,13 @@ Platform_JoyInit
*/
int Platform_JoyInit( int numjoy )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
// SDL_Joystick is now an old API
// SDL_GameController is preferred
if( Sys_CheckParm( "-sdl_joy_old_api" ) )
return SDLash_JoyInit_Old(numjoy);
return SDLash_JoyInit_New(numjoy);
if( !Sys_CheckParm( "-sdl_joy_old_api" ) )
return SDLash_JoyInit_New(numjoy);
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
return SDLash_JoyInit_Old(numjoy);
}
#endif // XASH_DEDICATED

27
engine/platform/sdl/s_sdl.c

@ -24,6 +24,18 @@ GNU General Public License for more details. @@ -24,6 +24,18 @@ GNU General Public License for more details.
#define SAMPLE_16BIT_SHIFT 1
#define SECONDARY_BUFFER_SIZE 0x10000
#if ! SDL_VERSION_ATLEAST( 2, 0, 0 )
#include <stdlib.h>
#define SDL_setenv setenv
#define SDL_GetCurrentAudioDriver() "legacysdl"
#define SDL_OpenAudioDevice( a, b, c, d, e ) SDL_OpenAudio( ( c ), ( d ) )
#define SDL_CloseAudioDevice( a ) SDL_CloseAudio()
#define SDL_PauseAudioDevice( a, b ) SDL_PauseAudio( ( b ) )
#define SDLash_IsAudioError( x ) ( x ) != 0
#else
#define SDLash_IsAudioError( x ) ( x ) == 0
#endif
/*
=======================================================================
Global variables. Must be visible to window-procedure function
@ -41,6 +53,11 @@ void SDL_SoundCallback( void *userdata, Uint8 *stream, int len ) @@ -41,6 +53,11 @@ void SDL_SoundCallback( void *userdata, Uint8 *stream, int len )
int pos = dma.samplepos << 1;
int wrapped = pos + len - size;
#if ! SDL_VERSION_ATLEAST( 2, 0, 0 )
if( !dma.buffer )
return;
#endif
if( wrapped < 0 )
{
memcpy( stream, dma.buffer + pos, len );
@ -88,7 +105,7 @@ qboolean SNDDMA_Init( void ) @@ -88,7 +105,7 @@ qboolean SNDDMA_Init( void )
sdl_dev = SDL_OpenAudioDevice( NULL, 0, &desired, &obtained, 0 );
if( !sdl_dev )
if( SDLash_IsAudioError( sdl_dev ))
{
Con_Printf( "Couldn't open SDL audio: %s\n", SDL_GetError( ) );
return false;
@ -113,12 +130,12 @@ qboolean SNDDMA_Init( void ) @@ -113,12 +130,12 @@ qboolean SNDDMA_Init( void )
if( !samplecount )
samplecount = 0x8000;
dma.samples = samplecount * obtained.channels;
dma.buffer = Z_Malloc( dma.samples * 2 );
dma.buffer = Z_Calloc( dma.samples * 2 );
dma.samplepos = 0;
Con_Printf( "Using SDL audio driver: %s @ %d Hz\n", SDL_GetCurrentAudioDriver( ), obtained.freq );
SDL_PauseAudioDevice( sdl_dev, 0 );
SNDDMA_Activate( true );
dma.initialized = true;
return true;
@ -218,10 +235,10 @@ void SNDDMA_Shutdown( void ) @@ -218,10 +235,10 @@ void SNDDMA_Shutdown( void )
if( sdl_dev )
{
SDL_PauseAudioDevice( sdl_dev, 1 );
SNDDMA_Activate( false );
#ifndef __EMSCRIPTEN__
SDL_CloseAudioDevice( sdl_dev );
SDL_CloseAudio( );
#endif
}

2
engine/platform/sdl/sys_sdl.c

@ -38,7 +38,9 @@ void Platform_Sleep( int msec ) @@ -38,7 +38,9 @@ void Platform_Sleep( int msec )
}
#endif // XASH_TIMER == TIMER_SDL
#if XASH_MESSAGEBOX == MSGBOX_SDL
void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow )
{
SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, title, message, parentMainWindow ? host.hWnd : NULL );
}
#endif // XASH_MESSAGEBOX == MSGBOX_SDL

284
engine/platform/sdl/vid_sdl.c

@ -31,8 +31,10 @@ struct @@ -31,8 +31,10 @@ struct
struct
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
SDL_Renderer *renderer;
SDL_Texture *tex;
#endif
int width, height;
SDL_Surface *surf;
SDL_Surface *win;
@ -43,6 +45,7 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * @@ -43,6 +45,7 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *
sw.width = width;
sw.height = height;
#if SDL_VERSION_ATLEAST(2, 0, 0)
if( sw.renderer )
{
unsigned int format = SDL_GetWindowPixelFormat( host.hWnd );
@ -54,7 +57,7 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * @@ -54,7 +57,7 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *
// guess
if( format == SDL_PIXELFORMAT_UNKNOWN )
{
if( glw_state.desktopBitsPixel == 16 )
if( refState.desktopBitsPixel == 16 )
format = SDL_PIXELFORMAT_RGB565;
else
format = SDL_PIXELFORMAT_RGBA8888;
@ -110,10 +113,16 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * @@ -110,10 +113,16 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *
sw.renderer = NULL;
}
}
#endif
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( !sw.renderer )
{
sw.win = SDL_GetWindowSurface( host.hWnd );
#else // SDL_VERSION_ATLEAST( 2, 0, 0 )
{
sw.win = SDL_GetVideoSurface();
#endif
// sdl will create renderer if hw framebuffer unavailiable, so cannot fallback here
// if it is failed, it is not possible to draw with SDL in REF_SOFTWARE mode
@ -145,6 +154,7 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * @@ -145,6 +154,7 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *
void *SW_LockBuffer( void )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( sw.renderer )
{
void *pixels;
@ -154,35 +164,38 @@ void *SW_LockBuffer( void ) @@ -154,35 +164,38 @@ void *SW_LockBuffer( void )
Sys_Error("%s", SDL_GetError());
return pixels;
}
else
{
// ensure it not changed (do we really need this?)
sw.win = SDL_GetWindowSurface( host.hWnd );
//if( !sw.win )
//SDL_GetWindowSurface( host.hWnd );
// ensure it not changed (do we really need this?)
sw.win = SDL_GetWindowSurface( host.hWnd );
//if( !sw.win )
//SDL_GetWindowSurface( host.hWnd );
#else // SDL_VERSION_ATLEAST( 2, 0, 0 )
sw.win = SDL_GetVideoSurface();
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
// prevent buffer overrun
if( !sw.win || sw.win->w < sw.width || sw.win->h < sw.height )
return NULL;
// prevent buffer overrun
if( !sw.win || sw.win->w < sw.width || sw.win->h < sw.height )
return NULL;
if( sw.surf )
{
SDL_LockSurface( sw.surf );
return sw.surf->pixels;
}
else
{
// real window pixels (x11 shm region, dma buffer, etc)
// or SDL_Renderer texture if not supported
SDL_LockSurface( sw.win );
return sw.win->pixels;
}
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( sw.surf )
{
SDL_LockSurface( sw.surf );
return sw.surf->pixels;
}
else
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
{
// real window pixels (x11 shm region, dma buffer, etc)
// or SDL_Renderer texture if not supported
SDL_LockSurface( sw.win );
return sw.win->pixels;
}
}
void SW_UnlockBuffer( void )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( sw.renderer )
{
SDL_Rect src, dst;
@ -197,26 +210,33 @@ void SW_UnlockBuffer( void ) @@ -197,26 +210,33 @@ void SW_UnlockBuffer( void )
SDL_RenderCopy(sw.renderer, sw.tex, &src, &dst);
SDL_RenderPresent(sw.renderer);
return;
//Con_Printf("%s\n", SDL_GetError());
}
else
{
// blit if blitting surface availiable
if( sw.surf )
{
SDL_Rect src, dst;
src.x = src.y = 0;
src.w = sw.width;
src.h = sw.height;
dst = src;
SDL_UnlockSurface( sw.surf );
SDL_BlitSurface( sw.surf, &src, sw.win, &dst );
}
else // already blitted
SDL_UnlockSurface( sw.win );
SDL_UpdateWindowSurface( host.hWnd );
// blit if blitting surface availiable
if( sw.surf )
{
SDL_Rect src, dst;
src.x = src.y = 0;
src.w = sw.width;
src.h = sw.height;
dst = src;
SDL_UnlockSurface( sw.surf );
SDL_BlitSurface( sw.surf, &src, sw.win, &dst );
return;
}
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
// already blitted
SDL_UnlockSurface( sw.win );
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_UpdateWindowSurface( host.hWnd );
#else // SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_Flip( host.hWnd );
#endif
}
int R_MaxVideoModes( void )
@ -236,6 +256,7 @@ vidmode_t *R_GetVideoMode( int num ) @@ -236,6 +256,7 @@ vidmode_t *R_GetVideoMode( int num )
static void R_InitVideoModes( void )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
int displayIndex = 0; // TODO: handle multiple displays somehow
int i, modes;
@ -250,7 +271,6 @@ static void R_InitVideoModes( void ) @@ -250,7 +271,6 @@ static void R_InitVideoModes( void )
for( i = 0; i < modes; i++ )
{
int j;
qboolean skip = false;
SDL_DisplayMode mode;
if( SDL_GetDisplayMode( displayIndex, i, &mode ) )
@ -267,7 +287,6 @@ static void R_InitVideoModes( void ) @@ -267,7 +287,6 @@ static void R_InitVideoModes( void )
if( mode.w == vidmodes[j].width &&
mode.h == vidmodes[j].height )
{
skip = true;
break;
}
}
@ -280,6 +299,43 @@ static void R_InitVideoModes( void ) @@ -280,6 +299,43 @@ static void R_InitVideoModes( void )
num_vidmodes++;
}
#else // SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_Rect **modes;
int len = 0, i = 0, j;
modes = SDL_ListModes( NULL, SDL_FULLSCREEN );
if( !modes || modes == (void*)-1 )
return;
for( len = 0; modes[len]; len++ );
vidmodes = Mem_Malloc( host.mempool, len * sizeof( vidmode_t ) );
// from smallest to largest
for( ; i < len; i++ )
{
SDL_Rect *mode = modes[len - i - 1];
for( j = 0; j < num_vidmodes; j++ )
{
if( mode->w == vidmodes[j].width &&
mode->h == vidmodes[j].height )
{
break;
}
}
if( j != num_vidmodes )
continue;
vidmodes[num_vidmodes].width = mode->w;
vidmodes[num_vidmodes].height = mode->h;
vidmodes[num_vidmodes].desc = copystring( va( "%ix%i", mode->w, mode->h ));
num_vidmodes++;
}
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
}
static void R_FreeVideoModes( void )
@ -364,9 +420,9 @@ GL_GetProcAddress @@ -364,9 +420,9 @@ GL_GetProcAddress
void *GL_GetProcAddress( const char *name )
{
#if defined( XASH_NANOGL )
void *func = nanoGL_GetProcAddress(name);
void *func = nanoGL_GetProcAddress( name );
#else
void *func = SDL_GL_GetProcAddress(name);
void *func = SDL_GL_GetProcAddress( name );
#endif
if( !func )
@ -384,6 +440,7 @@ GL_UpdateSwapInterval @@ -384,6 +440,7 @@ GL_UpdateSwapInterval
*/
void GL_UpdateSwapInterval( void )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
// disable VSync while level is loading
if( cls.state < ca_active )
{
@ -397,6 +454,7 @@ void GL_UpdateSwapInterval( void ) @@ -397,6 +454,7 @@ void GL_UpdateSwapInterval( void )
if( SDL_GL_SetSwapInterval( gl_vsync->value ) )
Con_Reportf( S_ERROR "SDL_GL_SetSwapInterval: %s\n", SDL_GetError( ) );
}
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
}
/*
@ -408,12 +466,13 @@ always return false @@ -408,12 +466,13 @@ always return false
*/
qboolean GL_DeleteContext( void )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( glw_state.context )
{
SDL_GL_DeleteContext(glw_state.context);
glw_state.context = NULL;
}
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
return false;
}
@ -424,12 +483,13 @@ GL_CreateContext @@ -424,12 +483,13 @@ GL_CreateContext
*/
qboolean GL_CreateContext( void )
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
if( ( glw_state.context = SDL_GL_CreateContext( host.hWnd ) ) == NULL)
{
Con_Reportf( S_ERROR "GL_CreateContext: %s\n", SDL_GetError());
return GL_DeleteContext();
}
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
return true;
}
@ -440,12 +500,13 @@ GL_UpdateContext @@ -440,12 +500,13 @@ GL_UpdateContext
*/
qboolean GL_UpdateContext( void )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( SDL_GL_MakeCurrent( host.hWnd, glw_state.context ))
{
Con_Reportf( S_ERROR "GL_UpdateContext: %s\n", SDL_GetError());
return GL_DeleteContext();
}
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
return true;
}
@ -454,10 +515,12 @@ void VID_SaveWindowSize( int width, int height ) @@ -454,10 +515,12 @@ void VID_SaveWindowSize( int width, int height )
int render_w = width, render_h = height;
uint rotate = vid_rotate->value;
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( !glw_state.software )
SDL_GL_GetDrawableSize( host.hWnd, &render_w, &render_h );
else
SDL_RenderSetLogicalSize( sw.renderer, width, height );
#endif
if( ref.dllFuncs.R_SetDisplayTransform( rotate, 0, 0, vid_scale->value, vid_scale->value ) )
{
@ -482,6 +545,7 @@ void VID_SaveWindowSize( int width, int height ) @@ -482,6 +545,7 @@ void VID_SaveWindowSize( int width, int height )
static qboolean VID_SetScreenResolution( int width, int height )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_DisplayMode want, got;
Uint32 wndFlags = 0;
static string wndname;
@ -511,12 +575,15 @@ static qboolean VID_SetScreenResolution( int width, int height ) @@ -511,12 +575,15 @@ static qboolean VID_SetScreenResolution( int width, int height )
SDL_SetWindowSize( host.hWnd, got.w, got.h );
VID_SaveWindowSize( got.w, got.h );
#else
VID_SaveWindowSize( width, height );
#endif
return true;
}
void VID_RestoreScreenResolution( void )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( !Cvar_VariableInteger("fullscreen") )
{
SDL_SetWindowBordered( host.hWnd, SDL_TRUE );
@ -527,6 +594,7 @@ void VID_RestoreScreenResolution( void ) @@ -527,6 +594,7 @@ void VID_RestoreScreenResolution( void )
SDL_MinimizeWindow( host.hWnd );
SDL_SetWindowFullscreen( host.hWnd, 0 );
}
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
}
#if defined(_WIN32) && !defined(XASH_64BIT) // ICO support only for Win32
@ -553,6 +621,7 @@ VID_CreateWindow @@ -553,6 +621,7 @@ VID_CreateWindow
qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
{
static string wndname;
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
Uint32 wndFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_MOUSE_FOCUS;
rgbdata_t *icon = NULL;
qboolean iconLoaded = false;
@ -704,6 +773,52 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen ) @@ -704,6 +773,52 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
}
#else // SDL_VERSION_ATLEAST( 2, 0, 0 )
Uint32 flags = 0;
if( fullscreen )
{
flags |= SDL_FULLSCREEN|SDL_HWSURFACE;
}
if( glw_state.software )
{
// flags |= SDL_ASYNCBLIT;
}
else
{
flags |= SDL_OPENGL;
}
while( glw_state.safe >= SAFE_NO && glw_state.safe < SAFE_LAST )
{
host.hWnd = sw.surf = SDL_SetVideoMode( width, height, 16, flags );
// we have window, exit loop
if( host.hWnd )
break;
Con_Reportf( S_ERROR "VID_CreateWindow: couldn't create '%s' with safegl level %d: %s\n", wndname, glw_state.safe, SDL_GetError());
glw_state.safe++;
if( !gl_wgl_msaa_samples->value && glw_state.safe == SAFE_NOMSAA )
glw_state.safe++; // no need to skip msaa, if we already disabled it
GL_SetupAttributes(); // re-choose attributes
// try again create window
}
// window creation has failed...
if( glw_state.safe >= SAFE_LAST )
{
return false;
}
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
VID_SaveWindowSize( width, height );
return true;
@ -721,7 +836,9 @@ void VID_DestroyWindow( void ) @@ -721,7 +836,9 @@ void VID_DestroyWindow( void )
VID_RestoreScreenResolution();
if( host.hWnd )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_DestroyWindow ( host.hWnd );
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
host.hWnd = NULL;
}
@ -738,14 +855,20 @@ GL_SetupAttributes @@ -738,14 +855,20 @@ GL_SetupAttributes
*/
static void GL_SetupAttributes( void )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_GL_ResetAttributes();
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
ref.dllFuncs.GL_SetupAttributes( glw_state.safe );
}
void GL_SwapBuffers( void )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_GL_SwapWindow( host.hWnd );
#else // SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_Flip( host.hWnd );
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
}
int GL_SetAttribute( int attr, int val )
@ -763,12 +886,20 @@ int GL_SetAttribute( int attr, int val ) @@ -763,12 +886,20 @@ int GL_SetAttribute( int attr, int val )
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_MULTISAMPLEBUFFERS );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_MULTISAMPLESAMPLES );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_ACCELERATED_VISUAL );
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_MAJOR_VERSION );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_MINOR_VERSION );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_EGL );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_FLAGS );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_SHARE_WITH_CURRENT_CONTEXT );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_FRAMEBUFFER_SRGB_CAPABLE );
case REF_GL_CONTEXT_PROFILE_MASK:
#ifdef SDL_HINT_OPENGL_ES_DRIVER
if( val == REF_GL_CONTEXT_PROFILE_ES )
SDL_SetHint(SDL_HINT_OPENGL_ES_DRIVER, "1");
#endif // SDL_HINT_OPENGL_ES_DRIVER
return SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, val );
#endif
#if SDL_VERSION_ATLEAST( 2, 0, 4 )
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_RELEASE_BEHAVIOR );
#endif
@ -776,16 +907,9 @@ int GL_SetAttribute( int attr, int val ) @@ -776,16 +907,9 @@ int GL_SetAttribute( int attr, int val )
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_RESET_NOTIFICATION );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_NO_ERROR );
#endif
case REF_GL_CONTEXT_PROFILE_MASK:
#ifdef SDL_HINT_OPENGL_ES_DRIVER
if (val == REF_GL_CONTEXT_PROFILE_ES)
SDL_SetHint(SDL_HINT_OPENGL_ES_DRIVER, "1");
#endif // SDL_HINT_OPENGL_ES_DRIVER
return SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, val );
#undef MAP_REF_API_ATTRIBUTE_TO_SDL
}
ASSERT( 0 );
return -1;
}
@ -804,12 +928,15 @@ int GL_GetAttribute( int attr, int *val ) @@ -804,12 +928,15 @@ int GL_GetAttribute( int attr, int *val )
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_MULTISAMPLEBUFFERS );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_MULTISAMPLESAMPLES );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_ACCELERATED_VISUAL );
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_MAJOR_VERSION );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_MINOR_VERSION );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_EGL );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_FLAGS );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_SHARE_WITH_CURRENT_CONTEXT );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_FRAMEBUFFER_SRGB_CAPABLE );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_PROFILE_MASK );
#endif
#if SDL_VERSION_ATLEAST( 2, 0, 4 )
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_RELEASE_BEHAVIOR );
#endif
@ -817,11 +944,9 @@ int GL_GetAttribute( int attr, int *val ) @@ -817,11 +944,9 @@ int GL_GetAttribute( int attr, int *val )
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_RESET_NOTIFICATION );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_NO_ERROR );
#endif
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_PROFILE_MASK );
#undef MAP_REF_API_ATTRIBUTE_TO_SDL
}
ASSERT( 0 );
return 0;
}
@ -836,22 +961,21 @@ R_Init_Video @@ -836,22 +961,21 @@ R_Init_Video
*/
qboolean R_Init_Video( const int type )
{
SDL_DisplayMode displayMode;
string safe;
qboolean retval;
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_DisplayMode displayMode;
SDL_GetCurrentDisplayMode(0, &displayMode);
glw_state.desktopBitsPixel = SDL_BITSPERPIXEL(displayMode.format);
glw_state.desktopWidth = displayMode.w;
glw_state.desktopHeight = displayMode.h;
refState.desktopBitsPixel = SDL_BITSPERPIXEL( displayMode.format );
#else
refState.desktopBitsPixel = 16;
#endif
#if !defined(_WIN32)
#if SDL_VERSION_ATLEAST( 2, 0, 0 ) && !defined(_WIN32)
SDL_SetHint( "SDL_VIDEO_X11_XRANDR", "1" );
SDL_SetHint( "SDL_VIDEO_X11_XVIDMODE", "1" );
#endif
R_InitVideoModes();
// must be initialized before creating window
#ifdef _WIN32
WIN_SetDPIAwareness();
@ -896,6 +1020,8 @@ qboolean R_Init_Video( const int type ) @@ -896,6 +1020,8 @@ qboolean R_Init_Video( const int type )
break;
}
R_InitVideoModes();
host.renderinfo_changed = false;
return true;
@ -903,16 +1029,16 @@ qboolean R_Init_Video( const int type ) @@ -903,16 +1029,16 @@ qboolean R_Init_Video( const int type )
rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_DisplayMode displayMode;
SDL_GetCurrentDisplayMode( 0, &displayMode );
Con_Reportf( "R_ChangeDisplaySettings: Setting video mode to %dx%d %s\n", width, height, fullscreen ? "fullscreen" : "windowed" );
// check our desktop attributes
glw_state.desktopBitsPixel = SDL_BITSPERPIXEL( displayMode.format );
glw_state.desktopWidth = displayMode.w;
glw_state.desktopHeight = displayMode.h;
refState.desktopBitsPixel = SDL_BITSPERPIXEL( displayMode.format );
#endif
Con_Reportf( "R_ChangeDisplaySettings: Setting video mode to %dx%d %s\n", width, height, fullscreen ? "fullscreen" : "windowed" );
refState.fullScreen = fullscreen;
@ -929,6 +1055,7 @@ rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen ) @@ -929,6 +1055,7 @@ rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen )
else
{
VID_RestoreScreenResolution();
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( SDL_SetWindowFullscreen( host.hWnd, 0 ) )
return rserr_invalid_fullscreen;
#if SDL_VERSION_ATLEAST( 2, 0, 5 )
@ -936,6 +1063,8 @@ rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen ) @@ -936,6 +1063,8 @@ rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen )
#endif
SDL_SetWindowBordered( host.hWnd, SDL_TRUE );
SDL_SetWindowSize( host.hWnd, width, height );
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
VID_SaveWindowSize( width, height );
}
@ -961,6 +1090,7 @@ qboolean VID_SetMode( void ) @@ -961,6 +1090,7 @@ qboolean VID_SetMode( void )
if( iScreenWidth < VID_MIN_WIDTH ||
iScreenHeight < VID_MIN_HEIGHT ) // trying to get resolution automatically by default
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
#if !defined( DEFAULT_MODE_WIDTH ) || !defined( DEFAULT_MODE_HEIGHT )
SDL_DisplayMode mode;
@ -972,13 +1102,17 @@ qboolean VID_SetMode( void ) @@ -972,13 +1102,17 @@ qboolean VID_SetMode( void )
iScreenWidth = DEFAULT_MODE_WIDTH;
iScreenHeight = DEFAULT_MODE_HEIGHT;
#endif
if( !FBitSet( vid_fullscreen->flags, FCVAR_CHANGED ) )
Cvar_SetValue( "fullscreen", DEFAULT_FULLSCREEN );
else
ClearBits( vid_fullscreen->flags, FCVAR_CHANGED );
#else // SDL_VERSION_ATLEAST( 2, 0, 0 )
iScreenWidth = 320;
iScreenHeight = 240;
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
}
if( !FBitSet( vid_fullscreen->flags, FCVAR_CHANGED ) )
Cvar_SetValue( "fullscreen", DEFAULT_FULLSCREEN );
else
ClearBits( vid_fullscreen->flags, FCVAR_CHANGED );
SetBits( gl_vsync->flags, FCVAR_CHANGED );
fullscreen = Cvar_VariableInteger("fullscreen") != 0;
@ -1028,6 +1162,10 @@ void R_Free_Video( void ) @@ -1028,6 +1162,10 @@ void R_Free_Video( void )
R_FreeVideoModes();
ref.dllFuncs.GL_ClearExtensions();
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_VideoQuit();
#endif
}
#endif // XASH_DEDICATED

4
engine/platform/win32/sys_win.c

@ -53,9 +53,9 @@ void Platform_ShellExecute( const char *path, const char *parms ) @@ -53,9 +53,9 @@ void Platform_ShellExecute( const char *path, const char *parms )
ShellExecute( NULL, "open", path, parms, NULL, SW_SHOW );
}
#ifdef XASH_DEDICATED
#if XASH_MESSAGEBOX == MSGBOX_WIN32
void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow )
{
MessageBox( parentMainWindow ? host.hWnd : NULL, message, title, MB_OK|MB_SETFOREGROUND|MB_ICONSTOP );
}
#endif
#endif // XASH_MESSAGEBOX == MSGBOX_WIN32

2
engine/ref_api.h

@ -106,6 +106,8 @@ typedef struct ref_globals_s @@ -106,6 +106,8 @@ typedef struct ref_globals_s
sortedface_t *draw_surfaces; // used for sorting translucent surfaces
int max_surfaces; // max surfaces per submodel (for all models)
size_t visbytes; // cluster size
int desktopBitsPixel;
} ref_globals_t;
enum

35
engine/wscript

@ -22,9 +22,26 @@ def options(opt): @@ -22,9 +22,26 @@ def options(opt):
grp.add_option('--enable-custom-swap', action = 'store_true', dest = 'CUSTOM_SWAP', default = False,
help = 'enable custom swap allocator. For devices with no swap support')
grp.add_option('--enable-magx', action = 'store_true', dest = 'MAGX', default = False,
help = 'enable targetting for MotoMAGX phones [default: %default]')
grp.add_option('--enable-legacy-sdl', action = 'store_true', dest = 'SDL12', default = False,
help = 'enable using SDL1.2 instead of SDL2(not recommended) [default: %default')
opt.load('sdl2')
def configure(conf):
conf.env.MAGX = conf.options.MAGX
if conf.options.MAGX:
# useless to change toolchain path, as toolchain meant to be placed in this path
toolchain_path = '/opt/toolchains/motomagx/arm-eabi2/lib/'
conf.env.INCLUDES_MAGX = [toolchain_path + i for i in ['ezx-z6/include', 'qt-2.3.8/include']]
conf.env.LIBPATH_MAGX = [toolchain_path + i for i in ['ezx-z6/lib', 'qt-2.3.8/lib']]
conf.env.LINKFLAGS_MAGX = ['-Wl,-rpath-link=' + i for i in conf.env.LIBPATH_MAGX]
for lib in ['qte-mt', 'ezxappbase', 'ezxpm', 'log_util']:
conf.check_cc(lib=lib, use='MAGX', uselib_store='MAGX')
conf.options.SDL12 = True
# check for dedicated server build
if conf.options.DEDICATED:
if conf.env.DEST_OS == 'linux':
@ -37,11 +54,17 @@ def configure(conf): @@ -37,11 +54,17 @@ def configure(conf):
conf.define('XASH_FBDEV', 1)
conf.check_cc( lib = 'asound' )
conf.check_cc( lib = 'rt' )
elif conf.options.SDL12:
conf.define('XASH_SDL', 12)
conf.check_cfg(package='sdl', args='--cflags --libs', uselib_store='SDL2' )
if conf.env.DEST_OS == 'linux':
conf.check_cc( lib='rt' )
conf.env.HAVE_SDL2 = True
else:
conf.load('sdl2')
if not conf.env.HAVE_SDL2:
conf.fatal('SDL2 not availiable! If you want to build dedicated server, specify --dedicated')
conf.define('XASH_SDL', 1)
conf.define('XASH_SDL', 2)
if conf.options.USE_SELECT == None:
conf.options.USE_SELECT = conf.options.DEDICATED
@ -60,6 +83,7 @@ def configure(conf): @@ -60,6 +83,7 @@ def configure(conf):
conf.define_cond('PSAPI_VERSION', conf.env.DEST_OS == 'win32') # will be defined as 1
def build(bld):
is_cxx_link = False
libs = [ 'public' ]
source = bld.path.ant_glob([
'common/*.c',
@ -86,6 +110,11 @@ def build(bld): @@ -86,6 +110,11 @@ def build(bld):
libs.append('SDL2')
source += bld.path.ant_glob(['platform/sdl/*.c'])
if bld.env.MAGX:
libs.append('MAGX')
source += bld.path.ant_glob(['platform/magx/*.cpp'])
is_cxx_link = True
if bld.env.DEST_OS == 'android':
libs += ['LOG', 'EGL', 'ANDROID']
source += bld.path.ant_glob(['platform/android/*.cpp', 'platform/android/*.c', 'platform/linux/*.c'])
@ -102,10 +131,10 @@ def build(bld): @@ -102,10 +131,10 @@ def build(bld):
if bld.env.SINGLE_BINARY:
install_path = bld.env.BINDIR
features = 'c cprogram'
features = ['c', 'cxxprogram' if is_cxx_link else 'cprogram']
else:
install_path = bld.env.LIBDIR
features = 'c cshlib'
features = ['c', 'cxxshlib' if is_cxx_link else 'cshlib']
bld(source = source,
target = 'xash',

3
game_launch/game.cpp

@ -92,7 +92,8 @@ static void Sys_LoadEngine( void ) @@ -92,7 +92,8 @@ static void Sys_LoadEngine( void )
Xash_Error("Unable to load the " XASHLIB ": %s", dlerror() );
}
if(( Xash_Main = (pfnInit)GetProcAddress( hEngine, "Host_Main" )) == NULL )
if(( Xash_Main = (pfnInit)GetProcAddress( hEngine, "Platform_Main" )) == NULL &&
( Xash_Main = (pfnInit)GetProcAddress( hEngine, "Host_Main" )) == NULL )
{
Xash_Error( XASHLIB " missed 'Host_Main' export: %s", dlerror() );
}

8
public/build.h

@ -142,13 +142,13 @@ GNU General Public License for more details. @@ -142,13 +142,13 @@ GNU General Public License for more details.
#elif defined __arm__ || defined _M_ARM
#if defined _M_ARM
#define XASH_ARM 7 // MSVC can only ARMv7
#elif __ARM_ARCH == 7
#elif __ARM_ARCH == 7 || __ARM_ARCH_7__
#define XASH_ARM 7
#elif __ARM_ARCH == 6
#elif __ARM_ARCH == 6 || __ARM_ARCH_6__ || __ARM_ARCH_6J__
#define XASH_ARM 6
#elif __ARM_ARCH == 5
#elif __ARM_ARCH == 5 || __ARM_ARCH_5__
#define XASH_ARM 5
#elif __ARM_ARCH == 4
#elif __ARM_ARCH == 4 || __ARM_ARCH_4__
#define XASH_ARM 4
#else
#error "Unknown ARM"

10
ref_gl/gl_image.c

@ -687,25 +687,25 @@ static void GL_SetTextureFormat( gl_texture_t *tex, pixformat_t format, int chan @@ -687,25 +687,25 @@ static void GL_SetTextureFormat( gl_texture_t *tex, pixformat_t format, int chan
{
if( haveColor && haveAlpha )
{
if( FBitSet( tex->flags, TF_ARB_16BIT ) || glw_state.desktopBitsPixel == 16 )
if( FBitSet( tex->flags, TF_ARB_16BIT ) || gpGlobals->desktopBitsPixel == 16 )
tex->format = GL_RGBA16F_ARB;
else tex->format = GL_RGBA32F_ARB;
}
else if( haveColor )
{
if( FBitSet( tex->flags, TF_ARB_16BIT ) || glw_state.desktopBitsPixel == 16 )
if( FBitSet( tex->flags, TF_ARB_16BIT ) || gpGlobals->desktopBitsPixel == 16 )
tex->format = GL_RGB16F_ARB;
else tex->format = GL_RGB32F_ARB;
}
else if( haveAlpha )
{
if( FBitSet( tex->flags, TF_ARB_16BIT ) || glw_state.desktopBitsPixel == 16 )
if( FBitSet( tex->flags, TF_ARB_16BIT ) || gpGlobals->desktopBitsPixel == 16 )
tex->format = GL_RG16F;
else tex->format = GL_RG32F;
}
else
{
if( FBitSet( tex->flags, TF_ARB_16BIT ) || glw_state.desktopBitsPixel == 16 )
if( FBitSet( tex->flags, TF_ARB_16BIT ) || gpGlobals->desktopBitsPixel == 16 )
tex->format = GL_LUMINANCE16F_ARB;
else tex->format = GL_LUMINANCE32F_ARB;
}
@ -713,7 +713,7 @@ static void GL_SetTextureFormat( gl_texture_t *tex, pixformat_t format, int chan @@ -713,7 +713,7 @@ static void GL_SetTextureFormat( gl_texture_t *tex, pixformat_t format, int chan
else
{
// NOTE: not all the types will be compressed
int bits = glw_state.desktopBitsPixel;
int bits = gpGlobals->desktopBitsPixel;
switch( GL_CalcTextureSamples( channelMask ))
{

9
ref_gl/gl_local.h

@ -33,6 +33,7 @@ GNU General Public License for more details. @@ -33,6 +33,7 @@ GNU General Public License for more details.
#include "pm_movevars.h"
//#include "cvar.h"
#include "gl_export.h"
#include "wadfile.h"
#ifndef offsetof
#define offsetof(s,m) (size_t)&(((s *)0)->m)
@ -480,7 +481,6 @@ void R_AliasInit( void ); @@ -480,7 +481,6 @@ void R_AliasInit( void );
//
// gl_warp.c
//
typedef struct mip_s mip_t;
void R_InitSkyClouds( mip_t *mt, struct texture_s *tx, qboolean custom_palette );
void R_AddSkyBoxSurface( msurface_t *fa );
void R_ClearSkyBox( void );
@ -691,13 +691,6 @@ typedef struct @@ -691,13 +691,6 @@ typedef struct
typedef struct
{
void* context; // handle to GL rendering context
int safe;
int desktopBitsPixel;
int desktopWidth;
int desktopHeight;
qboolean initialized; // OpenGL subsystem started
qboolean extended; // extended context allows to GL_Debug
} glwstate_t;

6
ref_gl/gl_opengl.c

@ -1041,7 +1041,7 @@ void GL_SetupAttributes( int safegl ) @@ -1041,7 +1041,7 @@ void GL_SetupAttributes( int safegl )
if( safegl < SAFE_NOACC )
gEngfuncs.GL_SetAttribute( REF_GL_ACCELERATED_VISUAL, 1 );
gEngfuncs.Con_Printf( "bpp %d\n", glw_state.desktopBitsPixel );
gEngfuncs.Con_Printf( "bpp %d\n", gpGlobals->desktopBitsPixel );
if( safegl < SAFE_NOSTENCIL )
gEngfuncs.GL_SetAttribute( REF_GL_STENCIL_SIZE, gl_stencilbits->value );
@ -1056,13 +1056,13 @@ void GL_SetupAttributes( int safegl ) @@ -1056,13 +1056,13 @@ void GL_SetupAttributes( int safegl )
if( safegl < SAFE_NOCOLOR )
{
if( glw_state.desktopBitsPixel >= 24 )
if( gpGlobals->desktopBitsPixel >= 24 )
{
gEngfuncs.GL_SetAttribute( REF_GL_RED_SIZE, 8 );
gEngfuncs.GL_SetAttribute( REF_GL_GREEN_SIZE, 8 );
gEngfuncs.GL_SetAttribute( REF_GL_BLUE_SIZE, 8 );
}
else if( glw_state.desktopBitsPixel >= 16 )
else if( gpGlobals->desktopBitsPixel >= 16 )
{
gEngfuncs.GL_SetAttribute( REF_GL_RED_SIZE, 5 );
gEngfuncs.GL_SetAttribute( REF_GL_GREEN_SIZE, 6 );

Loading…
Cancel
Save