mirror of
https://github.com/ioquake/jedi-academy.git
synced 2024-11-09 23:01:35 +00:00
add sdl glimp/input from ioquake3 for SP
This commit is contained in:
parent
788897fb1f
commit
8f7968cb9c
13 changed files with 2601 additions and 16 deletions
|
@ -33,12 +33,14 @@ add_definitions( -D_IMMERSION_DISABLE )
|
|||
add_definitions( -DNDEBUG )
|
||||
add_definitions( -DFINAL_BUILD )
|
||||
|
||||
include_directories(/usr/X11R6/include/)
|
||||
link_directories(/usr/X11R6/lib)
|
||||
find_package (SDL REQUIRED)
|
||||
include_directories(${SDL_INCLUDE_DIR})
|
||||
|
||||
include_directories(/usr/local/include/)
|
||||
link_directories(/usr/local/lib)
|
||||
find_package(OpenGL REQUIRED)
|
||||
include_directories(${OPENGL_INCLUDE_DIR})
|
||||
|
||||
find_package(OpenAL REQUIRED)
|
||||
include_directories(${OPENAL_INCLUDE_DIR})
|
||||
|
||||
set(src_main_rmg
|
||||
RMG/RM_Area.cpp
|
||||
|
@ -272,11 +274,16 @@ set(src_main_zlib
|
|||
set(src_main_unix
|
||||
unix/unix_main.cpp
|
||||
unix/unix_shared.cpp
|
||||
unix/linux_glimp.cpp
|
||||
unix/linux_qgl.cpp
|
||||
unix/unix_glimp_common.cpp
|
||||
null/null_snddma.cpp
|
||||
)
|
||||
|
||||
set(src_sdl
|
||||
sdl/sdl_gamma.cpp
|
||||
sdl/sdl_glimp.cpp
|
||||
sdl/sdl_input.cpp
|
||||
)
|
||||
|
||||
set(src_starwars
|
||||
${src_main_rmg}
|
||||
${src_main_client}
|
||||
|
@ -292,6 +299,7 @@ set(src_starwars
|
|||
${src_main_ui}
|
||||
${src_main_zlib}
|
||||
${src_main_unix}
|
||||
${src_sdl}
|
||||
)
|
||||
|
||||
add_executable(jasp
|
||||
|
@ -302,8 +310,9 @@ set_target_properties(jasp PROPERTIES COMPILE_DEFINITIONS "_JK2EXE;_FF_DISABLE")
|
|||
|
||||
target_link_libraries(jasp
|
||||
m pthread
|
||||
X11 Xxf86vm Xxf86dga
|
||||
openal
|
||||
${SDL_LIBRARY}
|
||||
${OPENGL_gl_LIBRARY}
|
||||
${OPENAL_LIBRARY}
|
||||
)
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
|
|
|
@ -79,6 +79,8 @@ cvar_t *cl_ingameVideo;
|
|||
|
||||
cvar_t *cl_thumbStickMode;
|
||||
|
||||
cvar_t *cl_consoleKeys;
|
||||
|
||||
clientActive_t cl;
|
||||
clientConnection_t clc;
|
||||
clientStatic_t cls;
|
||||
|
@ -1265,6 +1267,9 @@ void CL_Init( void ) {
|
|||
|
||||
cl_updateInfoString = Cvar_Get( "cl_updateInfoString", "", CVAR_ROM );
|
||||
|
||||
// ~ and `, as keys and characters
|
||||
cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60", CVAR_ARCHIVE);
|
||||
|
||||
// userinfo
|
||||
Cvar_Get ("name", "Jaden", CVAR_USERINFO | CVAR_ARCHIVE );
|
||||
Cvar_Get ("snaps", "20", CVAR_USERINFO | CVAR_ARCHIVE );
|
||||
|
|
|
@ -305,6 +305,8 @@ extern cvar_t *cl_activeAction;
|
|||
|
||||
extern cvar_t *cl_thumbStickMode;
|
||||
|
||||
extern cvar_t *cl_consoleKeys;
|
||||
|
||||
//=================================================
|
||||
|
||||
//
|
||||
|
@ -352,6 +354,7 @@ void CL_WritePacket( void );
|
|||
void IN_CenterView (void);
|
||||
|
||||
float CL_KeyState (kbutton_t *key);
|
||||
int Key_StringToKeynum( char *str );
|
||||
const char *Key_KeynumToString( int keynum/*, qboolean bTranslate*/ ); //note: translate is only called for menu display not configs
|
||||
|
||||
//
|
||||
|
@ -458,6 +461,7 @@ void CL_FirstSnapshot( void );
|
|||
//
|
||||
void CL_InitUI( void );
|
||||
void CL_ShutdownUI( void );
|
||||
int Key_GetCatcher( void );
|
||||
void CL_GenericMenu_f(void);
|
||||
void CL_DataPad_f(void);
|
||||
void CL_EndScreenDissolve_f(void);
|
||||
|
|
|
@ -585,6 +585,44 @@ void Parse3DMatrix ( const char **buf_p, int z, int y, int x, float *m) {
|
|||
COM_MatchToken( buf_p, ")" );
|
||||
}
|
||||
|
||||
/*
|
||||
===================
|
||||
Com_HexStrToInt
|
||||
===================
|
||||
*/
|
||||
int Com_HexStrToInt( const char *str )
|
||||
{
|
||||
if ( !str || !str[ 0 ] )
|
||||
return -1;
|
||||
|
||||
// check for hex code
|
||||
if( str[ 0 ] == '0' && str[ 1 ] == 'x' )
|
||||
{
|
||||
int i, n = 0;
|
||||
|
||||
for( i = 2; i < strlen( str ); i++ )
|
||||
{
|
||||
char digit;
|
||||
|
||||
n *= 16;
|
||||
|
||||
digit = tolower( str[ i ] );
|
||||
|
||||
if( digit >= '0' && digit <= '9' )
|
||||
digit -= '0';
|
||||
else if( digit >= 'a' && digit <= 'f' )
|
||||
digit = digit - 'a' + 10;
|
||||
else
|
||||
return -1;
|
||||
|
||||
n += digit;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
============================================================================
|
||||
|
|
|
@ -226,6 +226,8 @@ typedef int clipHandle_t;
|
|||
#define MAX_QINT 0x7fffffff
|
||||
#define MIN_QINT (-MAX_QINT-1)
|
||||
|
||||
#define ARRAY_LEN(x) (sizeof(x) / sizeof(*(x)))
|
||||
#define STRARRAY_LEN(x) (ARRAY_LEN(x) - 1)
|
||||
|
||||
// angle indexes
|
||||
#define PITCH 0 // up / down
|
||||
|
@ -1207,6 +1209,7 @@ void SkipRestOfLine ( const char **data );
|
|||
void Parse1DMatrix (const char **buf_p, int x, float *m);
|
||||
void Parse2DMatrix (const char **buf_p, int y, int x, float *m);
|
||||
void Parse3DMatrix (const char **buf_p, int z, int y, int x, float *m);
|
||||
int Com_HexStrToInt( const char *str );
|
||||
|
||||
void QDECL Com_sprintf (char *dest, int size, const char *fmt, ...);
|
||||
|
||||
|
|
|
@ -5,7 +5,17 @@
|
|||
#ifndef __QGL_H__
|
||||
#define __QGL_H__
|
||||
|
||||
#if defined( __LINT__ )
|
||||
#ifndef DYNAMIC_LINK_GL
|
||||
|
||||
#ifdef USE_LOCAL_HEADERS
|
||||
# include "SDL_opengl.h"
|
||||
#else
|
||||
# include <SDL_opengl.h>
|
||||
#endif
|
||||
|
||||
#include "qgl_linked.h"
|
||||
|
||||
#elif defined( __LINT__ )
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
|
@ -29,7 +39,7 @@
|
|||
#include <GL/gl.h>
|
||||
#include <GL/glx.h>
|
||||
|
||||
#endif
|
||||
#endif // !DYNAMIC_LINK_GL
|
||||
|
||||
#ifndef APIENTRY
|
||||
#define APIENTRY
|
||||
|
@ -328,6 +338,8 @@ extern void ( APIENTRY * qglPointParameterfvEXT)( GLenum, GLfloat *);
|
|||
extern void ( APIENTRY * qglPointParameteriNV)( GLenum, GLint);
|
||||
extern void ( APIENTRY * qglPointParameterivNV)( GLenum, const GLint *);
|
||||
|
||||
#ifdef DYNAMIC_LINK_GL
|
||||
|
||||
//===========================================================================
|
||||
|
||||
// windows systems use a function pointer for each call so we can load minidrivers
|
||||
|
@ -708,4 +720,5 @@ extern void (*qglXSwapBuffers)( Display *dpy, GLXDrawable drawable );
|
|||
|
||||
#endif // _WIN32
|
||||
|
||||
#endif
|
||||
#endif // DYNAMIC_LINK_GL
|
||||
#endif // __QGL_H__
|
||||
|
|
|
@ -1144,11 +1144,7 @@ void R_Register( void )
|
|||
r_texturebitslm = Cvar_Get( "r_texturebitslm", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_colorbits = Cvar_Get( "r_colorbits", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_stereo = Cvar_Get( "r_stereo", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
#ifdef __linux__
|
||||
r_stencilbits = Cvar_Get( "r_stencilbits", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
#else
|
||||
r_stencilbits = Cvar_Get( "r_stencilbits", "8", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
#endif
|
||||
r_depthbits = Cvar_Get( "r_depthbits", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_overBrightBits = Cvar_Get ("r_overBrightBits", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_ignorehwgamma = Cvar_Get( "r_ignorehwgamma", "0", CVAR_ARCHIVE | CVAR_LATCH);
|
||||
|
|
92
code/sdl/sdl_gamma.cpp
Normal file
92
code/sdl/sdl_gamma.cpp
Normal file
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
|
||||
This file is part of Quake III Arena source code.
|
||||
|
||||
Quake III Arena source code 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 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Quake III Arena source code 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Quake III Arena source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#ifdef USE_LOCAL_HEADERS
|
||||
# include "SDL.h"
|
||||
#else
|
||||
# include <SDL.h>
|
||||
#endif
|
||||
|
||||
#include "../game/q_shared.h"
|
||||
#include "../renderer/tr_local.h"
|
||||
#include "../qcommon/qcommon.h"
|
||||
|
||||
/*
|
||||
=================
|
||||
GLimp_SetGamma
|
||||
=================
|
||||
*/
|
||||
void GLimp_SetGamma( unsigned char red[256], unsigned char green[256], unsigned char blue[256] )
|
||||
{
|
||||
Uint16 table[3][256];
|
||||
int i, j;
|
||||
|
||||
if( !glConfig.deviceSupportsGamma || r_ignorehwgamma->integer > 0 )
|
||||
return;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
table[0][i] = ( ( ( Uint16 ) red[i] ) << 8 ) | red[i];
|
||||
table[1][i] = ( ( ( Uint16 ) green[i] ) << 8 ) | green[i];
|
||||
table[2][i] = ( ( ( Uint16 ) blue[i] ) << 8 ) | blue[i];
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
||||
// Win2K and newer put this odd restriction on gamma ramps...
|
||||
{
|
||||
OSVERSIONINFO vinfo;
|
||||
|
||||
vinfo.dwOSVersionInfoSize = sizeof( vinfo );
|
||||
GetVersionEx( &vinfo );
|
||||
if( vinfo.dwMajorVersion >= 5 && vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT )
|
||||
{
|
||||
ri.Printf( PRINT_DEVELOPER, "performing gamma clamp.\n" );
|
||||
for( j = 0 ; j < 3 ; j++ )
|
||||
{
|
||||
for( i = 0 ; i < 128 ; i++ )
|
||||
{
|
||||
if( table[ j ] [ i] > ( ( 128 + i ) << 8 ) )
|
||||
table[ j ][ i ] = ( 128 + i ) << 8;
|
||||
}
|
||||
|
||||
if( table[ j ] [127 ] > 254 << 8 )
|
||||
table[ j ][ 127 ] = 254 << 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// enforce constantly increasing
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
for (i = 1; i < 256; i++)
|
||||
{
|
||||
if (table[j][i] < table[j][i-1])
|
||||
table[j][i] = table[j][i-1];
|
||||
}
|
||||
}
|
||||
|
||||
SDL_SetGammaRamp(table[0], table[1], table[2]);
|
||||
}
|
||||
|
1225
code/sdl/sdl_glimp.cpp
Normal file
1225
code/sdl/sdl_glimp.cpp
Normal file
File diff suppressed because it is too large
Load diff
1107
code/sdl/sdl_input.cpp
Normal file
1107
code/sdl/sdl_input.cpp
Normal file
File diff suppressed because it is too large
Load diff
11
code/sdl/sdl_local.h
Normal file
11
code/sdl/sdl_local.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include "../game/q_shared.h"
|
||||
#include "../qcommon/qcommon.h"
|
||||
#include "../client/client.h"
|
||||
|
||||
void IN_Init( void );
|
||||
void IN_Shutdown( void );
|
||||
void IN_Restart( void );
|
||||
|
||||
void Sys_GLimpSafeInit( void );
|
||||
void Sys_GLimpInit( void );
|
||||
void Sys_QueEvent( int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr );
|
82
code/unix/unix_glimp_common.cpp
Normal file
82
code/unix/unix_glimp_common.cpp
Normal file
|
@ -0,0 +1,82 @@
|
|||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include "../game/q_shared.h"
|
||||
|
||||
/*
|
||||
===========================================================
|
||||
|
||||
SMP acceleration
|
||||
|
||||
===========================================================
|
||||
*/
|
||||
|
||||
sem_t renderCommandsEvent;
|
||||
sem_t renderCompletedEvent;
|
||||
sem_t renderActiveEvent;
|
||||
|
||||
void (*glimpRenderThread)( void );
|
||||
|
||||
void *GLimp_RenderThreadWrapper( void *stub ) {
|
||||
glimpRenderThread();
|
||||
}
|
||||
|
||||
/*
|
||||
=======================
|
||||
GLimp_SpawnRenderThread
|
||||
=======================
|
||||
*/
|
||||
pthread_t renderThreadHandle;
|
||||
qboolean GLimp_SpawnRenderThread( void (*function)( void ) ) {
|
||||
|
||||
sem_init( &renderCommandsEvent, 0, 0 );
|
||||
sem_init( &renderCompletedEvent, 0, 0 );
|
||||
sem_init( &renderActiveEvent, 0, 0 );
|
||||
|
||||
glimpRenderThread = function;
|
||||
|
||||
if (pthread_create( &renderThreadHandle, NULL,
|
||||
GLimp_RenderThreadWrapper, NULL)) {
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
static void *smpData;
|
||||
|
||||
void *GLimp_RendererSleep( void ) {
|
||||
void *data;
|
||||
|
||||
// after this, the front end can exit GLimp_FrontEndSleep
|
||||
sem_post ( &renderCompletedEvent );
|
||||
|
||||
sem_wait ( &renderCommandsEvent );
|
||||
|
||||
data = smpData;
|
||||
|
||||
// after this, the main thread can exit GLimp_WakeRenderer
|
||||
sem_post ( &renderActiveEvent );
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void GLimp_FrontEndSleep( void ) {
|
||||
sem_wait ( &renderCompletedEvent );
|
||||
}
|
||||
|
||||
void GLimp_WakeRenderer( void *data ) {
|
||||
smpData = data;
|
||||
|
||||
// after this, the renderer can continue through GLimp_RendererSleep
|
||||
sem_post( &renderCommandsEvent );
|
||||
|
||||
sem_wait( &renderActiveEvent );
|
||||
}
|
||||
|
||||
void Sys_GLimpInit( void )
|
||||
{
|
||||
}
|
||||
|
||||
void Sys_GLimpSafeInit( void )
|
||||
{
|
||||
}
|
|
@ -144,7 +144,7 @@ void Sys_Init(void)
|
|||
Cvar_Set( "arch", "unknown" );
|
||||
#endif
|
||||
|
||||
IN_Init();
|
||||
// IN_Init();
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue