mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2024-11-10 06:31:48 +00:00
cleaned up tr_gl2.cpp and prefixes in win32 code
tr_gl2.cpp now uses the proper interface for printing errors tr_gl2.cpp now has function names that make sense removed old references to GLimp_* cleaned up prefixes in the Windows platform layer
This commit is contained in:
parent
9362d9bf53
commit
c60d47e93f
15 changed files with 108 additions and 117 deletions
|
@ -1633,6 +1633,8 @@ static void QDECL CL_RefPrintf( printParm_t print_level, const char* fmt, ... )
|
|||
Com_Printf( "%s", msg );
|
||||
} else if ( print_level == PRINT_WARNING ) {
|
||||
Com_Printf( S_COLOR_YELLOW "%s", msg );
|
||||
} else if ( print_level == PRINT_ERROR ) {
|
||||
Com_Printf( S_COLOR_RED "%s", msg );
|
||||
} else if ( print_level == PRINT_DEVELOPER ) {
|
||||
Com_DPrintf( S_COLOR_CYAN "%s", msg );
|
||||
}
|
||||
|
|
|
@ -62,6 +62,3 @@ sfxHandle_t S_RegisterSound( const char* sample );
|
|||
void S_DisplayFreeMemory();
|
||||
|
||||
void S_ClearSoundBuffer();
|
||||
|
||||
void SNDDMA_Activate();
|
||||
|
||||
|
|
|
@ -602,7 +602,7 @@ static void RB_RenderLitSurfList( dlight_t* dl )
|
|||
R_RotateForEntity( backEnd.currentEntity, &backEnd.viewParms, &backEnd.orient );
|
||||
|
||||
R_TransformDlights( 1, dl, &backEnd.orient );
|
||||
GL2_DynLights_SetupLight();
|
||||
GL2_SetupDynLight();
|
||||
|
||||
if ( backEnd.currentEntity->e.renderfx & RF_DEPTHHACK ) {
|
||||
// hack the depth range to prevent view model from poking into walls
|
||||
|
@ -616,7 +616,7 @@ static void RB_RenderLitSurfList( dlight_t* dl )
|
|||
// the world (like water) continue with the wrong frame
|
||||
tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset;
|
||||
R_TransformDlights( 1, dl, &backEnd.orient );
|
||||
GL2_DynLights_SetupLight();
|
||||
GL2_SetupDynLight();
|
||||
}
|
||||
|
||||
qglLoadMatrixf( backEnd.orient.modelMatrix );
|
||||
|
|
|
@ -47,15 +47,25 @@ static GLSL_DynLightProgramAttribs dynLightProgAttribs;
|
|||
///////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
static void GL2_DynLights_Setup()
|
||||
void GL2_SetupDynLight()
|
||||
{
|
||||
const shaderStage_t* pStage = tess.xstages[tess.shader->lightingStages[ST_DIFFUSE]];
|
||||
GL_SelectTexture( 0 );
|
||||
R_BindAnimatedImage( &pStage->bundle );
|
||||
GL_Program( dynLightProg );
|
||||
|
||||
const dlight_t* dl = tess.light;
|
||||
vec3_t lightColor;
|
||||
VectorCopy( dl->color, lightColor );
|
||||
|
||||
qglUniform4f( dynLightProgAttribs.osLightPos, dl->transformed[0], dl->transformed[1], dl->transformed[2], 0.0f );
|
||||
qglUniform4f( dynLightProgAttribs.osEyePos, backEnd.orient.viewOrigin[0], backEnd.orient.viewOrigin[1], backEnd.orient.viewOrigin[2], 0.0f );
|
||||
qglUniform4f( dynLightProgAttribs.lightColorRadius, lightColor[0], lightColor[1], lightColor[2], 1.0f / Square(dl->radius) );
|
||||
qglUniform1i( dynLightProgAttribs.texture, 0 ); // we use texture unit 0
|
||||
}
|
||||
|
||||
|
||||
static void GL2_DynLights_Lighting()
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
static void GL2_StageIterator_Lighting()
|
||||
{
|
||||
backEnd.pc[RB_LIT_VERTICES_LATECULLTEST] += tess.numVertexes;
|
||||
|
||||
|
@ -115,31 +125,15 @@ static void GL2_DynLights_Lighting()
|
|||
|
||||
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL );
|
||||
|
||||
GL2_DynLights_Setup();
|
||||
const shaderStage_t* const pStage = tess.xstages[tess.shader->lightingStages[ST_DIFFUSE]];
|
||||
GL_SelectTexture( 0 );
|
||||
R_BindAnimatedImage( &pStage->bundle );
|
||||
|
||||
qglDrawElements( GL_TRIANGLES, numIndexes, GL_INDEX_TYPE, hitIndexes );
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
void GL2_DynLights_SetupLight()
|
||||
{
|
||||
GL_Program( dynLightProg );
|
||||
|
||||
const dlight_t* dl = tess.light;
|
||||
vec3_t lightColor;
|
||||
VectorCopy( dl->color, lightColor );
|
||||
|
||||
qglUniform4f( dynLightProgAttribs.osLightPos, dl->transformed[0], dl->transformed[1], dl->transformed[2], 0.0f );
|
||||
qglUniform4f( dynLightProgAttribs.osEyePos, backEnd.orient.viewOrigin[0], backEnd.orient.viewOrigin[1], backEnd.orient.viewOrigin[2], 0.0f );
|
||||
qglUniform4f( dynLightProgAttribs.lightColorRadius, lightColor[0], lightColor[1], lightColor[2], 1.0f / Square(dl->radius) );
|
||||
qglUniform1i( dynLightProgAttribs.texture, 0 ); // we use texture unit 0
|
||||
}
|
||||
|
||||
|
||||
static void GL2_DynLights_LightingPass()
|
||||
static void GL2_StageIterator_LightingPass()
|
||||
{
|
||||
if (tess.shader->lightingStages[ST_DIFFUSE] == -1)
|
||||
return;
|
||||
|
@ -164,7 +158,7 @@ static void GL2_DynLights_LightingPass()
|
|||
qglVertexPointer( 3, GL_FLOAT, 16, tess.xyz );
|
||||
qglLockArraysEXT( 0, tess.numVertexes );
|
||||
|
||||
GL2_DynLights_Lighting();
|
||||
GL2_StageIterator_Lighting();
|
||||
|
||||
qglUnlockArraysEXT();
|
||||
|
||||
|
@ -176,7 +170,7 @@ static void GL2_DynLights_LightingPass()
|
|||
|
||||
|
||||
// returns qtrue if needs to break early
|
||||
static qbool GL2_DynLights_MultitextureStage( int stage )
|
||||
static qbool GL2_StageIterator_MultitextureStage( int stage )
|
||||
{
|
||||
static stageVars_t svarsMT; // this is a huge struct
|
||||
|
||||
|
@ -227,10 +221,10 @@ static qbool GL2_DynLights_MultitextureStage( int stage )
|
|||
}
|
||||
|
||||
|
||||
void GL2_DynLights_StageIterator()
|
||||
void GL2_StageIterator()
|
||||
{
|
||||
if (tess.pass == shaderCommands_t::TP_LIGHT) {
|
||||
GL2_DynLights_LightingPass();
|
||||
GL2_StageIterator_LightingPass();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -274,7 +268,7 @@ void GL2_DynLights_StageIterator()
|
|||
if ( pStage->mtStages ) {
|
||||
// we can't really cope with massive collapses, so
|
||||
assert( pStage->mtStages == 1 );
|
||||
if ( GL2_DynLights_MultitextureStage( stage ) )
|
||||
if ( GL2_StageIterator_MultitextureStage( stage ) )
|
||||
break;
|
||||
stage += pStage->mtStages;
|
||||
continue;
|
||||
|
@ -314,7 +308,7 @@ static qbool GL2_CreateShader( GLuint* shaderPtr, GLenum shaderType, const char*
|
|||
|
||||
static char log[4096]; // I've seen logs over 3 KB in size.
|
||||
qglGetShaderInfoLog( shader, sizeof(log), NULL, log );
|
||||
Com_Printf( "ERROR: %s shader: %s", shaderType == GL_VERTEX_SHADER ? "vertex" : "fragment", log );
|
||||
ri.Printf( PRINT_ERROR, "%s shader: %s\n", shaderType == GL_VERTEX_SHADER ? "Vertex" : "Fragment", log );
|
||||
|
||||
return qfalse;
|
||||
}
|
||||
|
@ -433,10 +427,10 @@ static void GL2_CheckError( const char* call, const char* function, const char*
|
|||
++file;
|
||||
}
|
||||
|
||||
Com_Printf( "%s failed\n", call );
|
||||
Com_Printf( "%s:%d in %s\n", fileName, line, function );
|
||||
Com_Printf( "Error code: 0x%X (%d)\n", (unsigned int)ec, (int)ec );
|
||||
Com_Printf( "Error message: %s\n", GL2_GetErrorString(ec) );
|
||||
ri.Printf( PRINT_ERROR, "%s failed\n", call );
|
||||
ri.Printf( PRINT_ERROR, "%s:%d in %s\n", fileName, line, function );
|
||||
ri.Printf( PRINT_ERROR, "GL error code: 0x%X (%d)\n", (unsigned int)ec, (int)ec );
|
||||
ri.Printf( PRINT_ERROR, "GL error message: %s\n", GL2_GetErrorString(ec) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -489,8 +483,8 @@ static qbool GL2_FBO_CreateSS( FrameBuffer& fb, qbool depthStencil )
|
|||
const GLenum fboStatus = qglCheckFramebufferStatus( GL_FRAMEBUFFER );
|
||||
if ( fboStatus != GL_FRAMEBUFFER_COMPLETE )
|
||||
{
|
||||
Com_Printf( "Failed to create FBO (status 0x%X, error 0x%X)\n", (unsigned int)fboStatus, (unsigned int)qglGetError() );
|
||||
Com_Printf( "FBO status string: %s\n", GL2_GetFBOStatusString(fboStatus) );
|
||||
ri.Printf( PRINT_ERROR, "Failed to create FBO (status 0x%X, error 0x%X)\n", (unsigned int)fboStatus, (unsigned int)qglGetError() );
|
||||
ri.Printf( PRINT_ERROR, "FBO status string: %s\n", GL2_GetFBOStatusString(fboStatus) );
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
|
@ -524,8 +518,8 @@ static qbool GL2_FBO_CreateMS( FrameBuffer& fb )
|
|||
const GLenum fboStatus = qglCheckFramebufferStatus( GL_FRAMEBUFFER );
|
||||
if ( fboStatus != GL_FRAMEBUFFER_COMPLETE )
|
||||
{
|
||||
Com_Printf( "Failed to create FBO (status 0x%X, error 0x%X)\n", (unsigned int)fboStatus, (unsigned int)qglGetError() );
|
||||
Com_Printf( "FBO status string: %s\n", GL2_GetFBOStatusString(fboStatus) );
|
||||
ri.Printf( PRINT_ERROR, "Failed to create FBO (status 0x%X, error 0x%X)\n", (unsigned int)fboStatus, (unsigned int)qglGetError() );
|
||||
ri.Printf( PRINT_ERROR, "FBO status string: %s\n", GL2_GetFBOStatusString(fboStatus) );
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
|
@ -544,7 +538,7 @@ static qbool GL2_FBO_Init()
|
|||
const qbool enable = validOption && qglRenderbufferStorageMultisample != NULL;
|
||||
frameBufferMultiSampling = enable;
|
||||
if ( validOption && !enable )
|
||||
Com_Printf( "Warning: MSAA requested but disabled because glRenderbufferStorageMultisample wasn't found\n" );
|
||||
ri.Printf( PRINT_WARNING, "MSAA requested but disabled because glRenderbufferStorageMultisample wasn't found\n" );
|
||||
|
||||
if ( !enable )
|
||||
return GL2_FBO_CreateSS( frameBuffersPostProcess[0], qtrue ) &&
|
||||
|
@ -731,12 +725,12 @@ static const char* greyscaleFS =
|
|||
qbool GL2_Init()
|
||||
{
|
||||
if ( !GL2_FBO_Init() ) {
|
||||
Com_Printf( "ERROR: failed to create framebuffer objects\n" );
|
||||
ri.Printf( PRINT_ERROR, "Failed to create FBOs\n" );
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if ( !GL2_CreateProgram( dynLightProg, dynLightVS, dynLightFS ) ) {
|
||||
Com_Printf( "ERROR: failed to compile dynamic light shaders\n" );
|
||||
ri.Printf( PRINT_ERROR, "Failed to compile dynamic light shaders\n" );
|
||||
return qfalse;
|
||||
}
|
||||
dynLightProgAttribs.osEyePos = qglGetUniformLocation( dynLightProg.p, "osEyePos" );
|
||||
|
@ -745,7 +739,7 @@ qbool GL2_Init()
|
|||
dynLightProgAttribs.lightColorRadius = qglGetUniformLocation( dynLightProg.p, "lightColorRadius" );
|
||||
|
||||
if ( !GL2_CreateProgram( gammaProg, gammaVS, gammaFS ) ) {
|
||||
Com_Printf( "ERROR: failed to compile gamma correction shaders\n" );
|
||||
ri.Printf( PRINT_ERROR, "Failed to compile gamma correction shaders\n" );
|
||||
return qfalse;
|
||||
}
|
||||
gammaProgAttribs.texture = qglGetUniformLocation( gammaProg.p, "texture" );
|
||||
|
@ -756,7 +750,7 @@ qbool GL2_Init()
|
|||
greyscaleProgAttribs.texture = qglGetUniformLocation( greyscaleProg.p, "texture" );
|
||||
greyscaleProgAttribs.greyscale = qglGetUniformLocation( greyscaleProg.p, "greyscale" );
|
||||
} else {
|
||||
Com_Printf( "ERROR: failed to compile greyscale shaders\n" );
|
||||
ri.Printf( PRINT_ERROR, "Failed to compile greyscale shaders\n" );
|
||||
}
|
||||
|
||||
return qtrue;
|
||||
|
|
|
@ -213,7 +213,7 @@ static void GL_InitExtensions()
|
|||
** InitOpenGL
|
||||
**
|
||||
** This function is responsible for initializing a valid OpenGL subsystem. This
|
||||
** is done by calling GLimp_Init (which gives us a working OGL subsystem) then
|
||||
** is done by calling Sys_GL_Init (which gives us a working OGL subsystem) then
|
||||
** setting variables, checking GL constants, and reporting the gfx system config
|
||||
** to the user.
|
||||
*/
|
||||
|
|
|
@ -1518,8 +1518,8 @@ private:
|
|||
|
||||
// tr_gl2.cpp
|
||||
qbool GL2_Init();
|
||||
void GL2_DynLights_SetupLight();
|
||||
void GL2_DynLights_StageIterator();
|
||||
void GL2_SetupDynLight();
|
||||
void GL2_StageIterator();
|
||||
void GL2_BeginFrame();
|
||||
void GL2_EndFrame();
|
||||
|
||||
|
|
|
@ -1540,7 +1540,7 @@ static void ComputeStageIteratorFunc()
|
|||
return;
|
||||
}
|
||||
|
||||
shader.siFunc = GL2_DynLights_StageIterator;
|
||||
shader.siFunc = GL2_StageIterator;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2366,7 +2366,7 @@ void R_ShaderList_f( void )
|
|||
ri.Printf( PRINT_ALL, " " );
|
||||
}
|
||||
|
||||
if ( shader->siFunc == GL2_DynLights_StageIterator ) {
|
||||
if ( shader->siFunc == GL2_StageIterator ) {
|
||||
ri.Printf( PRINT_ALL, " " );
|
||||
} else if ( shader->siFunc == RB_StageIteratorSky ) {
|
||||
ri.Printf( PRINT_ALL, "sky " );
|
||||
|
|
|
@ -589,7 +589,7 @@ void RB_StageIteratorSky()
|
|||
// which will be drawn by the generic shader routine
|
||||
R_BuildCloudData( &tess );
|
||||
if (tess.numVertexes)
|
||||
GL2_DynLights_StageIterator();
|
||||
GL2_StageIterator();
|
||||
|
||||
// back to normal depth range
|
||||
qglDepthRange( 0.0, 1.0 );
|
||||
|
|
|
@ -23,12 +23,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
** WIN_GLIMP.C
|
||||
**
|
||||
** This file contains ALL Win32 specific stuff having to do with the
|
||||
** OpenGL refresh. When a port is being made the following functions
|
||||
** OpenGL refresh. When a port is being made the following functions
|
||||
** must be implemented by the port:
|
||||
**
|
||||
** GLimp_EndFrame
|
||||
** GLimp_Init
|
||||
** GLimp_Shutdown
|
||||
** Sys_GL_EndFrame
|
||||
** Sys_GL_Init
|
||||
** Sys_GL_Shutdown
|
||||
**
|
||||
** Note that the GLW_xxx functions are Windows specific GL-subsystem
|
||||
** related functions that are relevant ONLY to win_glimp.c
|
||||
|
@ -643,7 +643,7 @@ void Sys_GL_Init()
|
|||
|
||||
// load appropriate DLL and initialize subsystem
|
||||
if (!GLW_LoadOpenGL())
|
||||
ri.Error( ERR_FATAL, "GLimp_Init() - could not load OpenGL subsystem\n" );
|
||||
ri.Error( ERR_FATAL, "Sys_GL_Init - could not load OpenGL subsystem\n" );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -54,14 +54,14 @@ void Mouse::UpdateWheel( int delta )
|
|||
wheel += delta;
|
||||
|
||||
while (wheel >= WHEEL_DELTA) {
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELUP, qtrue, 0, NULL );
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELUP, qfalse, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELUP, qtrue, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELUP, qfalse, 0, NULL );
|
||||
wheel -= WHEEL_DELTA;
|
||||
}
|
||||
|
||||
while (wheel <= -WHEEL_DELTA) {
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELDOWN, qtrue, 0, NULL );
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELDOWN, qfalse, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELDOWN, qtrue, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELDOWN, qfalse, 0, NULL );
|
||||
wheel += WHEEL_DELTA;
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ qbool rawmouse_t::ProcessMessage( UINT msg, WPARAM wParam, LPARAM lParam )
|
|||
const int dx = (int)ri.data.mouse.lLastX;
|
||||
const int dy = (int)ri.data.mouse.lLastY;
|
||||
if (active && (dx != 0 || dy != 0))
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_MOUSE, dx, dy, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_MOUSE, dx, dy, 0, NULL );
|
||||
|
||||
if (!ri.data.mouse.usButtonFlags) // no button or wheel transitions
|
||||
return qfalse;
|
||||
|
@ -165,12 +165,12 @@ qbool rawmouse_t::ProcessMessage( UINT msg, WPARAM wParam, LPARAM lParam )
|
|||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
if (active && (ri.data.mouse.usButtonFlags & riBtnDnFlags[i]) != 0)
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MOUSE1 + i, qtrue, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MOUSE1 + i, qtrue, 0, NULL );
|
||||
|
||||
// we always send the button up events to avoid
|
||||
// buttons getting "stuck" when bringing the console down
|
||||
if (ri.data.mouse.usButtonFlags & riBtnUpFlags[i])
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MOUSE1 + i, qfalse, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MOUSE1 + i, qfalse, 0, NULL );
|
||||
}
|
||||
|
||||
return qfalse;
|
||||
|
@ -225,14 +225,14 @@ qbool winmouse_t::ProcessMessage( UINT msg, WPARAM wParam, LPARAM lParam )
|
|||
UpdateWindowCenter();
|
||||
|
||||
#define QUEUE_WM_BUTTON( qbutton, mask ) \
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, qbutton, (wParam & mask), 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, qbutton, (wParam & mask), 0, NULL );
|
||||
|
||||
POINT p;
|
||||
GetCursorPos( &p );
|
||||
const int dx = p.x - window_center_x;
|
||||
const int dy = p.y - window_center_y;
|
||||
if (dx != 0 || dy != 0) {
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_MOUSE, dx, dy, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_MOUSE, dx, dy, 0, NULL );
|
||||
SetCursorPos( window_center_x, window_center_y );
|
||||
}
|
||||
|
||||
|
@ -620,10 +620,10 @@ static void IN_JoyMove()
|
|||
buttonstate = joy.ji.dwButtons;
|
||||
for ( i=0 ; i < joy.jc.wNumButtons ; i++ ) {
|
||||
if ( (buttonstate & (1<<i)) && !(joy.oldbuttonstate & (1<<i)) ) {
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_JOY1 + i, qtrue, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, K_JOY1 + i, qtrue, 0, NULL );
|
||||
}
|
||||
if ( !(buttonstate & (1<<i)) && (joy.oldbuttonstate & (1<<i)) ) {
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_JOY1 + i, qfalse, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, K_JOY1 + i, qfalse, 0, NULL );
|
||||
}
|
||||
}
|
||||
joy.oldbuttonstate = buttonstate;
|
||||
|
@ -659,11 +659,11 @@ static void IN_JoyMove()
|
|||
// determine which bits have changed and key an auxillary event for each change
|
||||
for (i=0 ; i < 16 ; i++) {
|
||||
if ( (povstate & (1<<i)) && !(joy.oldpovstate & (1<<i)) ) {
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, joyDirectionKeys[i], qtrue, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, joyDirectionKeys[i], qtrue, 0, NULL );
|
||||
}
|
||||
|
||||
if ( !(povstate & (1<<i)) && (joy.oldpovstate & (1<<i)) ) {
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, joyDirectionKeys[i], qfalse, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, joyDirectionKeys[i], qfalse, 0, NULL );
|
||||
}
|
||||
}
|
||||
joy.oldpovstate = povstate;
|
||||
|
@ -673,7 +673,7 @@ static void IN_JoyMove()
|
|||
x = JoyToI( joy.ji.dwUpos ) * in_joyBallScale->value;
|
||||
y = JoyToI( joy.ji.dwVpos ) * in_joyBallScale->value;
|
||||
if ( x || y ) {
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_MOUSE, x, y, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_MOUSE, x, y, 0, NULL );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -713,7 +713,7 @@ static void MIDI_NoteOff( int note )
|
|||
if ( qkey > 255 || qkey < K_AUX1 )
|
||||
return;
|
||||
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, qkey, qfalse, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, qkey, qfalse, 0, NULL );
|
||||
}
|
||||
|
||||
static void MIDI_NoteOn( int note, int velocity )
|
||||
|
@ -728,7 +728,7 @@ static void MIDI_NoteOn( int note, int velocity )
|
|||
if ( qkey > 255 || qkey < K_AUX1 )
|
||||
return;
|
||||
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, qkey, qtrue, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, qkey, qtrue, 0, NULL );
|
||||
}
|
||||
|
||||
static void CALLBACK MidiInProc( HMIDIIN hMidiIn, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 )
|
||||
|
@ -762,7 +762,7 @@ static void CALLBACK MidiInProc( HMIDIIN hMidiIn, UINT uMsg, DWORD dwInstance, D
|
|||
break;
|
||||
}
|
||||
|
||||
// Sys_QueEvent( sys_msg_time, SE_KEY, wMsg, qtrue, 0, NULL );
|
||||
// WIN_QueEvent( sys_msg_time, SE_KEY, wMsg, qtrue, 0, NULL );
|
||||
}
|
||||
|
||||
static void MidiInfo_f( void )
|
||||
|
|
|
@ -24,18 +24,20 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "windows.h"
|
||||
|
||||
|
||||
void Sys_QueEvent( int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr );
|
||||
void WIN_QueEvent( int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr );
|
||||
|
||||
void Sys_CreateConsole( void );
|
||||
void Sys_DestroyConsole( void );
|
||||
const char* Sys_ConsoleInput();
|
||||
|
||||
void Conbuf_AppendText( const char *msg );
|
||||
// "early console" window management
|
||||
void WIN_CreateConsole();
|
||||
void WIN_DestroyConsole();
|
||||
const char* WIN_ConsoleInput();
|
||||
void WIN_AppendConsoleText( const char *msg );
|
||||
|
||||
// input
|
||||
void IN_Activate( qbool active );
|
||||
qbool IN_ProcessMessage( UINT msg, WPARAM wParam, LPARAM lParam ); // returns true if the event was handled
|
||||
void IN_Frame();
|
||||
|
||||
// misc. Windows-specific stuff
|
||||
void WIN_UpdateMonitorIndexFromCvar();
|
||||
void WIN_UpdateMonitorIndexFromMainWindow();
|
||||
void WIN_UpdateResolution( int width, int height );
|
||||
|
@ -44,7 +46,8 @@ void WIN_UnregisterHotKey();
|
|||
void WIN_SetGameDisplaySettings();
|
||||
void WIN_SetDesktopDisplaySettings();
|
||||
|
||||
void SNDDMA_Activate();
|
||||
// sound - called in reaction to WM_ACTIVATE
|
||||
void WIN_S_WindowActivate();
|
||||
|
||||
LRESULT CALLBACK MainWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
|
||||
|
|
|
@ -82,8 +82,8 @@ void QDECL Sys_Error( const char *error, ... )
|
|||
vsprintf (text, error, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
Conbuf_AppendText( text );
|
||||
Conbuf_AppendText( "\n" );
|
||||
WIN_AppendConsoleText( text );
|
||||
WIN_AppendConsoleText( "\n" );
|
||||
|
||||
Sys_SetErrorText( text );
|
||||
Sys_ShowConsole( 1, qtrue );
|
||||
|
@ -103,7 +103,7 @@ void QDECL Sys_Error( const char *error, ... )
|
|||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
Sys_DestroyConsole();
|
||||
WIN_DestroyConsole();
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
@ -115,14 +115,14 @@ void Sys_Quit( int status )
|
|||
#ifndef DEDICATED
|
||||
Sys_ShutdownInput();
|
||||
#endif
|
||||
Sys_DestroyConsole();
|
||||
WIN_DestroyConsole();
|
||||
exit( status );
|
||||
}
|
||||
|
||||
|
||||
void Sys_Print( const char *msg )
|
||||
{
|
||||
Conbuf_AppendText( msg );
|
||||
WIN_AppendConsoleText( msg );
|
||||
}
|
||||
|
||||
|
||||
|
@ -427,7 +427,7 @@ static int eventHead, eventTail;
|
|||
// a time of 0 will get the current time
|
||||
// ptr should either be null, or point to a block of data that can be freed by the game later
|
||||
|
||||
void Sys_QueEvent( int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr )
|
||||
void WIN_QueEvent( int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr )
|
||||
{
|
||||
sysEvent_t* ev = &eventQue[ eventHead & MASK_QUED_EVENTS ];
|
||||
|
||||
|
@ -479,12 +479,12 @@ sysEvent_t Sys_GetEvent()
|
|||
}
|
||||
|
||||
// check for console commands
|
||||
const char* s = Sys_ConsoleInput();
|
||||
const char* s = WIN_ConsoleInput();
|
||||
if ( s ) {
|
||||
int len = strlen( s ) + 1;
|
||||
char* b = (char*)Z_Malloc( len );
|
||||
Q_strncpyz( b, s, len-1 );
|
||||
Sys_QueEvent( 0, SE_CONSOLE, 0, 0, len, b );
|
||||
WIN_QueEvent( 0, SE_CONSOLE, 0, 0, len, b );
|
||||
}
|
||||
|
||||
// check for network packets
|
||||
|
@ -499,7 +499,7 @@ sysEvent_t Sys_GetEvent()
|
|||
netadr_t* buf = (netadr_t*)Z_Malloc( len );
|
||||
*buf = adr;
|
||||
memcpy( buf+1, &netmsg.data[netmsg.readcount], netmsg.cursize - netmsg.readcount );
|
||||
Sys_QueEvent( 0, SE_PACKET, 0, 0, len, buf );
|
||||
WIN_QueEvent( 0, SE_PACKET, 0, 0, len, buf );
|
||||
}
|
||||
|
||||
// return if we have data
|
||||
|
@ -639,7 +639,7 @@ int WINAPI WinMainImpl( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCm
|
|||
WIN_InitMonitorList();
|
||||
|
||||
// done before Com/Sys_Init since we need this for error output
|
||||
Sys_CreateConsole();
|
||||
WIN_CreateConsole();
|
||||
|
||||
// get the initial time base
|
||||
Sys_Milliseconds();
|
||||
|
|
|
@ -327,12 +327,12 @@ void SNDDMA_Submit( void )
|
|||
|
||||
/*
|
||||
=================
|
||||
SNDDMA_Activate
|
||||
WIN_S_WindowActivate
|
||||
|
||||
When we change windows we need to do this
|
||||
Called in reaction to WM_ACTIVATE
|
||||
=================
|
||||
*/
|
||||
void SNDDMA_Activate()
|
||||
void WIN_S_WindowActivate()
|
||||
{
|
||||
if ( !pDS ) {
|
||||
return;
|
||||
|
|
|
@ -126,7 +126,7 @@ static LONG WINAPI ConWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
|
|||
if ( ( com_dedicated && com_dedicated->integer ) )
|
||||
{
|
||||
cmdString = CopyString( "quit" );
|
||||
Sys_QueEvent( 0, SE_CONSOLE, 0, 0, strlen( cmdString ) + 1, cmdString );
|
||||
WIN_QueEvent( 0, SE_CONSOLE, 0, 0, strlen( cmdString ) + 1, cmdString );
|
||||
}
|
||||
else if ( s_wcd.quitOnClose )
|
||||
{
|
||||
|
@ -189,7 +189,7 @@ static LONG WINAPI ConWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
|
|||
else
|
||||
{
|
||||
cmdString = CopyString( "quit" );
|
||||
Sys_QueEvent( 0, SE_CONSOLE, 0, 0, strlen( cmdString ) + 1, cmdString );
|
||||
WIN_QueEvent( 0, SE_CONSOLE, 0, 0, strlen( cmdString ) + 1, cmdString );
|
||||
}
|
||||
}
|
||||
else if ( wParam == CLEAR_ID )
|
||||
|
@ -358,7 +358,7 @@ LONG WINAPI InputLineWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
|||
/*
|
||||
** Sys_CreateConsole
|
||||
*/
|
||||
void Sys_CreateConsole( void )
|
||||
void WIN_CreateConsole( void )
|
||||
{
|
||||
const int desiredw = 540;
|
||||
const int desiredh = 450;
|
||||
|
@ -501,7 +501,7 @@ void Sys_CreateConsole( void )
|
|||
/*
|
||||
** Sys_DestroyConsole
|
||||
*/
|
||||
void Sys_DestroyConsole( void ) {
|
||||
void WIN_DestroyConsole( void ) {
|
||||
if ( s_wcd.hWnd ) {
|
||||
ShowWindow( s_wcd.hWnd, SW_HIDE );
|
||||
CloseWindow( s_wcd.hWnd );
|
||||
|
@ -546,7 +546,7 @@ void Sys_ShowConsole( int visLevel, qbool quitOnClose )
|
|||
}
|
||||
|
||||
|
||||
const char* Sys_ConsoleInput()
|
||||
const char* WIN_ConsoleInput()
|
||||
{
|
||||
if ( s_wcd.consoleText[0] == 0 )
|
||||
{
|
||||
|
@ -560,10 +560,7 @@ const char* Sys_ConsoleInput()
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
** Conbuf_AppendText
|
||||
*/
|
||||
void Conbuf_AppendText( const char *pMsg )
|
||||
void WIN_AppendConsoleText( const char *pMsg )
|
||||
{
|
||||
#define CONSOLE_BUFFER_SIZE 16384
|
||||
|
||||
|
@ -643,9 +640,7 @@ void Conbuf_AppendText( const char *pMsg )
|
|||
SendMessage( s_wcd.hwndBuffer, EM_REPLACESEL, 0, (LPARAM) buffer );
|
||||
}
|
||||
|
||||
/*
|
||||
** Sys_SetErrorText
|
||||
*/
|
||||
|
||||
void Sys_SetErrorText( const char *buf )
|
||||
{
|
||||
Q_strncpyz( s_wcd.errorString, buf, sizeof( s_wcd.errorString ) );
|
||||
|
|
|
@ -222,14 +222,14 @@ LRESULT CALLBACK MainWndProc (
|
|||
// but anyone running vista is a moron anyway, so fkit :P
|
||||
if (i > 0) {
|
||||
while (i >= WHEEL_DELTA) {
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELUP, qtrue, 0, NULL );
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELUP, qfalse, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELUP, qtrue, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELUP, qfalse, 0, NULL );
|
||||
i -= WHEEL_DELTA;
|
||||
}
|
||||
} else {
|
||||
while (i <= -WHEEL_DELTA) {
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELDOWN, qtrue, 0, NULL );
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELDOWN, qfalse, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELDOWN, qtrue, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELDOWN, qfalse, 0, NULL );
|
||||
i += WHEEL_DELTA;
|
||||
}
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ LRESULT CALLBACK MainWndProc (
|
|||
|
||||
case WM_ACTIVATE:
|
||||
WIN_AppActivate( (LOWORD(wParam) != WA_INACTIVE), !!(BOOL)HIWORD(wParam) );
|
||||
SNDDMA_Activate();
|
||||
WIN_S_WindowActivate();
|
||||
break;
|
||||
|
||||
case WM_MOVE:
|
||||
|
@ -317,19 +317,19 @@ LRESULT CALLBACK MainWndProc (
|
|||
}
|
||||
// fall through
|
||||
case WM_KEYDOWN:
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, MapKey( wParam, lParam ), qtrue, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, MapKey( wParam, lParam ), qtrue, 0, NULL );
|
||||
break;
|
||||
|
||||
case WM_SYSKEYUP:
|
||||
case WM_KEYUP:
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, MapKey( wParam, lParam ), qfalse, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_KEY, MapKey( wParam, lParam ), qfalse, 0, NULL );
|
||||
break;
|
||||
|
||||
case WM_CHAR:
|
||||
{
|
||||
const char scanCode = (char)( ( lParam >> 16 ) & 0xFF );
|
||||
if ( scanCode != 0x29 ) // never send an event for the console key ('~' or '`')
|
||||
Sys_QueEvent( g_wv.sysMsgTime, SE_CHAR, wParam, 0, 0, NULL );
|
||||
WIN_QueEvent( g_wv.sysMsgTime, SE_CHAR, wParam, 0, 0, NULL );
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue