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:
myT 2017-11-03 19:35:35 +01:00
parent 9362d9bf53
commit c60d47e93f
15 changed files with 108 additions and 117 deletions

View file

@ -1633,6 +1633,8 @@ static void QDECL CL_RefPrintf( printParm_t print_level, const char* fmt, ... )
Com_Printf( "%s", msg ); Com_Printf( "%s", msg );
} else if ( print_level == PRINT_WARNING ) { } else if ( print_level == PRINT_WARNING ) {
Com_Printf( S_COLOR_YELLOW "%s", msg ); 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 ) { } else if ( print_level == PRINT_DEVELOPER ) {
Com_DPrintf( S_COLOR_CYAN "%s", msg ); Com_DPrintf( S_COLOR_CYAN "%s", msg );
} }

View file

@ -62,6 +62,3 @@ sfxHandle_t S_RegisterSound( const char* sample );
void S_DisplayFreeMemory(); void S_DisplayFreeMemory();
void S_ClearSoundBuffer(); void S_ClearSoundBuffer();
void SNDDMA_Activate();

View file

@ -602,7 +602,7 @@ static void RB_RenderLitSurfList( dlight_t* dl )
R_RotateForEntity( backEnd.currentEntity, &backEnd.viewParms, &backEnd.orient ); R_RotateForEntity( backEnd.currentEntity, &backEnd.viewParms, &backEnd.orient );
R_TransformDlights( 1, dl, &backEnd.orient ); R_TransformDlights( 1, dl, &backEnd.orient );
GL2_DynLights_SetupLight(); GL2_SetupDynLight();
if ( backEnd.currentEntity->e.renderfx & RF_DEPTHHACK ) { if ( backEnd.currentEntity->e.renderfx & RF_DEPTHHACK ) {
// hack the depth range to prevent view model from poking into walls // 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 // the world (like water) continue with the wrong frame
tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset;
R_TransformDlights( 1, dl, &backEnd.orient ); R_TransformDlights( 1, dl, &backEnd.orient );
GL2_DynLights_SetupLight(); GL2_SetupDynLight();
} }
qglLoadMatrixf( backEnd.orient.modelMatrix ); qglLoadMatrixf( backEnd.orient.modelMatrix );

View file

@ -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_Program( dynLightProg );
GL_SelectTexture( 0 );
R_BindAnimatedImage( &pStage->bundle ); 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; 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 ); 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 ); qglDrawElements( GL_TRIANGLES, numIndexes, GL_INDEX_TYPE, hitIndexes );
} }
/////////////////////////////////////////////////////////////// static void GL2_StageIterator_LightingPass()
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()
{ {
if (tess.shader->lightingStages[ST_DIFFUSE] == -1) if (tess.shader->lightingStages[ST_DIFFUSE] == -1)
return; return;
@ -164,7 +158,7 @@ static void GL2_DynLights_LightingPass()
qglVertexPointer( 3, GL_FLOAT, 16, tess.xyz ); qglVertexPointer( 3, GL_FLOAT, 16, tess.xyz );
qglLockArraysEXT( 0, tess.numVertexes ); qglLockArraysEXT( 0, tess.numVertexes );
GL2_DynLights_Lighting(); GL2_StageIterator_Lighting();
qglUnlockArraysEXT(); qglUnlockArraysEXT();
@ -176,7 +170,7 @@ static void GL2_DynLights_LightingPass()
// returns qtrue if needs to break early // 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 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) { if (tess.pass == shaderCommands_t::TP_LIGHT) {
GL2_DynLights_LightingPass(); GL2_StageIterator_LightingPass();
return; return;
} }
@ -274,7 +268,7 @@ void GL2_DynLights_StageIterator()
if ( pStage->mtStages ) { if ( pStage->mtStages ) {
// we can't really cope with massive collapses, so // we can't really cope with massive collapses, so
assert( pStage->mtStages == 1 ); assert( pStage->mtStages == 1 );
if ( GL2_DynLights_MultitextureStage( stage ) ) if ( GL2_StageIterator_MultitextureStage( stage ) )
break; break;
stage += pStage->mtStages; stage += pStage->mtStages;
continue; 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. static char log[4096]; // I've seen logs over 3 KB in size.
qglGetShaderInfoLog( shader, sizeof(log), NULL, log ); 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; return qfalse;
} }
@ -433,10 +427,10 @@ static void GL2_CheckError( const char* call, const char* function, const char*
++file; ++file;
} }
Com_Printf( "%s failed\n", call ); ri.Printf( PRINT_ERROR, "%s failed\n", call );
Com_Printf( "%s:%d in %s\n", fileName, line, function ); ri.Printf( PRINT_ERROR, "%s:%d in %s\n", fileName, line, function );
Com_Printf( "Error code: 0x%X (%d)\n", (unsigned int)ec, (int)ec ); ri.Printf( PRINT_ERROR, "GL error code: 0x%X (%d)\n", (unsigned int)ec, (int)ec );
Com_Printf( "Error message: %s\n", GL2_GetErrorString(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 ); const GLenum fboStatus = qglCheckFramebufferStatus( GL_FRAMEBUFFER );
if ( fboStatus != GL_FRAMEBUFFER_COMPLETE ) if ( fboStatus != GL_FRAMEBUFFER_COMPLETE )
{ {
Com_Printf( "Failed to create FBO (status 0x%X, error 0x%X)\n", (unsigned int)fboStatus, (unsigned int)qglGetError() ); ri.Printf( PRINT_ERROR, "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, "FBO status string: %s\n", GL2_GetFBOStatusString(fboStatus) );
return qfalse; return qfalse;
} }
@ -524,8 +518,8 @@ static qbool GL2_FBO_CreateMS( FrameBuffer& fb )
const GLenum fboStatus = qglCheckFramebufferStatus( GL_FRAMEBUFFER ); const GLenum fboStatus = qglCheckFramebufferStatus( GL_FRAMEBUFFER );
if ( fboStatus != GL_FRAMEBUFFER_COMPLETE ) if ( fboStatus != GL_FRAMEBUFFER_COMPLETE )
{ {
Com_Printf( "Failed to create FBO (status 0x%X, error 0x%X)\n", (unsigned int)fboStatus, (unsigned int)qglGetError() ); ri.Printf( PRINT_ERROR, "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, "FBO status string: %s\n", GL2_GetFBOStatusString(fboStatus) );
return qfalse; return qfalse;
} }
@ -544,7 +538,7 @@ static qbool GL2_FBO_Init()
const qbool enable = validOption && qglRenderbufferStorageMultisample != NULL; const qbool enable = validOption && qglRenderbufferStorageMultisample != NULL;
frameBufferMultiSampling = enable; frameBufferMultiSampling = enable;
if ( validOption && !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 ) if ( !enable )
return GL2_FBO_CreateSS( frameBuffersPostProcess[0], qtrue ) && return GL2_FBO_CreateSS( frameBuffersPostProcess[0], qtrue ) &&
@ -731,12 +725,12 @@ static const char* greyscaleFS =
qbool GL2_Init() qbool GL2_Init()
{ {
if ( !GL2_FBO_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; return qfalse;
} }
if ( !GL2_CreateProgram( dynLightProg, dynLightVS, dynLightFS ) ) { 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; return qfalse;
} }
dynLightProgAttribs.osEyePos = qglGetUniformLocation( dynLightProg.p, "osEyePos" ); dynLightProgAttribs.osEyePos = qglGetUniformLocation( dynLightProg.p, "osEyePos" );
@ -745,7 +739,7 @@ qbool GL2_Init()
dynLightProgAttribs.lightColorRadius = qglGetUniformLocation( dynLightProg.p, "lightColorRadius" ); dynLightProgAttribs.lightColorRadius = qglGetUniformLocation( dynLightProg.p, "lightColorRadius" );
if ( !GL2_CreateProgram( gammaProg, gammaVS, gammaFS ) ) { 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; return qfalse;
} }
gammaProgAttribs.texture = qglGetUniformLocation( gammaProg.p, "texture" ); gammaProgAttribs.texture = qglGetUniformLocation( gammaProg.p, "texture" );
@ -756,7 +750,7 @@ qbool GL2_Init()
greyscaleProgAttribs.texture = qglGetUniformLocation( greyscaleProg.p, "texture" ); greyscaleProgAttribs.texture = qglGetUniformLocation( greyscaleProg.p, "texture" );
greyscaleProgAttribs.greyscale = qglGetUniformLocation( greyscaleProg.p, "greyscale" ); greyscaleProgAttribs.greyscale = qglGetUniformLocation( greyscaleProg.p, "greyscale" );
} else { } else {
Com_Printf( "ERROR: failed to compile greyscale shaders\n" ); ri.Printf( PRINT_ERROR, "Failed to compile greyscale shaders\n" );
} }
return qtrue; return qtrue;

View file

@ -213,7 +213,7 @@ static void GL_InitExtensions()
** InitOpenGL ** InitOpenGL
** **
** This function is responsible for initializing a valid OpenGL subsystem. This ** 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 ** setting variables, checking GL constants, and reporting the gfx system config
** to the user. ** to the user.
*/ */

View file

@ -1518,8 +1518,8 @@ private:
// tr_gl2.cpp // tr_gl2.cpp
qbool GL2_Init(); qbool GL2_Init();
void GL2_DynLights_SetupLight(); void GL2_SetupDynLight();
void GL2_DynLights_StageIterator(); void GL2_StageIterator();
void GL2_BeginFrame(); void GL2_BeginFrame();
void GL2_EndFrame(); void GL2_EndFrame();

View file

@ -1540,7 +1540,7 @@ static void ComputeStageIteratorFunc()
return; return;
} }
shader.siFunc = GL2_DynLights_StageIterator; shader.siFunc = GL2_StageIterator;
} }
@ -2366,7 +2366,7 @@ void R_ShaderList_f( void )
ri.Printf( PRINT_ALL, " " ); ri.Printf( PRINT_ALL, " " );
} }
if ( shader->siFunc == GL2_DynLights_StageIterator ) { if ( shader->siFunc == GL2_StageIterator ) {
ri.Printf( PRINT_ALL, " " ); ri.Printf( PRINT_ALL, " " );
} else if ( shader->siFunc == RB_StageIteratorSky ) { } else if ( shader->siFunc == RB_StageIteratorSky ) {
ri.Printf( PRINT_ALL, "sky " ); ri.Printf( PRINT_ALL, "sky " );

View file

@ -589,7 +589,7 @@ void RB_StageIteratorSky()
// which will be drawn by the generic shader routine // which will be drawn by the generic shader routine
R_BuildCloudData( &tess ); R_BuildCloudData( &tess );
if (tess.numVertexes) if (tess.numVertexes)
GL2_DynLights_StageIterator(); GL2_StageIterator();
// back to normal depth range // back to normal depth range
qglDepthRange( 0.0, 1.0 ); qglDepthRange( 0.0, 1.0 );

View file

@ -23,12 +23,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
** WIN_GLIMP.C ** WIN_GLIMP.C
** **
** This file contains ALL Win32 specific stuff having to do with the ** 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: ** must be implemented by the port:
** **
** GLimp_EndFrame ** Sys_GL_EndFrame
** GLimp_Init ** Sys_GL_Init
** GLimp_Shutdown ** Sys_GL_Shutdown
** **
** Note that the GLW_xxx functions are Windows specific GL-subsystem ** Note that the GLW_xxx functions are Windows specific GL-subsystem
** related functions that are relevant ONLY to win_glimp.c ** related functions that are relevant ONLY to win_glimp.c
@ -643,7 +643,7 @@ void Sys_GL_Init()
// load appropriate DLL and initialize subsystem // load appropriate DLL and initialize subsystem
if (!GLW_LoadOpenGL()) 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" );
} }

View file

@ -54,14 +54,14 @@ void Mouse::UpdateWheel( int delta )
wheel += delta; wheel += delta;
while (wheel >= WHEEL_DELTA) { while (wheel >= WHEEL_DELTA) {
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELUP, qtrue, 0, NULL ); WIN_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, qfalse, 0, NULL );
wheel -= WHEEL_DELTA; wheel -= WHEEL_DELTA;
} }
while (wheel <= -WHEEL_DELTA) { while (wheel <= -WHEEL_DELTA) {
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELDOWN, qtrue, 0, NULL ); WIN_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, qfalse, 0, NULL );
wheel += WHEEL_DELTA; 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 dx = (int)ri.data.mouse.lLastX;
const int dy = (int)ri.data.mouse.lLastY; const int dy = (int)ri.data.mouse.lLastY;
if (active && (dx != 0 || dy != 0)) 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 if (!ri.data.mouse.usButtonFlags) // no button or wheel transitions
return qfalse; return qfalse;
@ -165,12 +165,12 @@ qbool rawmouse_t::ProcessMessage( UINT msg, WPARAM wParam, LPARAM lParam )
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {
if (active && (ri.data.mouse.usButtonFlags & riBtnDnFlags[i]) != 0) 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 // we always send the button up events to avoid
// buttons getting "stuck" when bringing the console down // buttons getting "stuck" when bringing the console down
if (ri.data.mouse.usButtonFlags & riBtnUpFlags[i]) 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; return qfalse;
@ -225,14 +225,14 @@ qbool winmouse_t::ProcessMessage( UINT msg, WPARAM wParam, LPARAM lParam )
UpdateWindowCenter(); UpdateWindowCenter();
#define QUEUE_WM_BUTTON( qbutton, mask ) \ #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; POINT p;
GetCursorPos( &p ); GetCursorPos( &p );
const int dx = p.x - window_center_x; const int dx = p.x - window_center_x;
const int dy = p.y - window_center_y; const int dy = p.y - window_center_y;
if (dx != 0 || dy != 0) { 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 ); SetCursorPos( window_center_x, window_center_y );
} }
@ -620,10 +620,10 @@ static void IN_JoyMove()
buttonstate = joy.ji.dwButtons; buttonstate = joy.ji.dwButtons;
for ( i=0 ; i < joy.jc.wNumButtons ; i++ ) { for ( i=0 ; i < joy.jc.wNumButtons ; i++ ) {
if ( (buttonstate & (1<<i)) && !(joy.oldbuttonstate & (1<<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)) ) { 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; joy.oldbuttonstate = buttonstate;
@ -659,11 +659,11 @@ static void IN_JoyMove()
// determine which bits have changed and key an auxillary event for each change // determine which bits have changed and key an auxillary event for each change
for (i=0 ; i < 16 ; i++) { for (i=0 ; i < 16 ; i++) {
if ( (povstate & (1<<i)) && !(joy.oldpovstate & (1<<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)) ) { 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; joy.oldpovstate = povstate;
@ -673,7 +673,7 @@ static void IN_JoyMove()
x = JoyToI( joy.ji.dwUpos ) * in_joyBallScale->value; x = JoyToI( joy.ji.dwUpos ) * in_joyBallScale->value;
y = JoyToI( joy.ji.dwVpos ) * in_joyBallScale->value; y = JoyToI( joy.ji.dwVpos ) * in_joyBallScale->value;
if ( x || y ) { 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 ) if ( qkey > 255 || qkey < K_AUX1 )
return; 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 ) 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 ) if ( qkey > 255 || qkey < K_AUX1 )
return; 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 ) 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; 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 ) static void MidiInfo_f( void )

View file

@ -24,18 +24,20 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "windows.h" #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 ); // "early console" window management
void Sys_DestroyConsole( void ); void WIN_CreateConsole();
const char* Sys_ConsoleInput(); void WIN_DestroyConsole();
const char* WIN_ConsoleInput();
void Conbuf_AppendText( const char *msg ); void WIN_AppendConsoleText( const char *msg );
// input
void IN_Activate( qbool active ); void IN_Activate( qbool active );
qbool IN_ProcessMessage( UINT msg, WPARAM wParam, LPARAM lParam ); // returns true if the event was handled qbool IN_ProcessMessage( UINT msg, WPARAM wParam, LPARAM lParam ); // returns true if the event was handled
void IN_Frame(); void IN_Frame();
// misc. Windows-specific stuff
void WIN_UpdateMonitorIndexFromCvar(); void WIN_UpdateMonitorIndexFromCvar();
void WIN_UpdateMonitorIndexFromMainWindow(); void WIN_UpdateMonitorIndexFromMainWindow();
void WIN_UpdateResolution( int width, int height ); void WIN_UpdateResolution( int width, int height );
@ -44,7 +46,8 @@ void WIN_UnregisterHotKey();
void WIN_SetGameDisplaySettings(); void WIN_SetGameDisplaySettings();
void WIN_SetDesktopDisplaySettings(); 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 ); LRESULT CALLBACK MainWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );

View file

@ -82,8 +82,8 @@ void QDECL Sys_Error( const char *error, ... )
vsprintf (text, error, argptr); vsprintf (text, error, argptr);
va_end (argptr); va_end (argptr);
Conbuf_AppendText( text ); WIN_AppendConsoleText( text );
Conbuf_AppendText( "\n" ); WIN_AppendConsoleText( "\n" );
Sys_SetErrorText( text ); Sys_SetErrorText( text );
Sys_ShowConsole( 1, qtrue ); Sys_ShowConsole( 1, qtrue );
@ -103,7 +103,7 @@ void QDECL Sys_Error( const char *error, ... )
DispatchMessage(&msg); DispatchMessage(&msg);
} }
Sys_DestroyConsole(); WIN_DestroyConsole();
exit(1); exit(1);
} }
@ -115,14 +115,14 @@ void Sys_Quit( int status )
#ifndef DEDICATED #ifndef DEDICATED
Sys_ShutdownInput(); Sys_ShutdownInput();
#endif #endif
Sys_DestroyConsole(); WIN_DestroyConsole();
exit( status ); exit( status );
} }
void Sys_Print( const char *msg ) 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 // 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 // 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 ]; sysEvent_t* ev = &eventQue[ eventHead & MASK_QUED_EVENTS ];
@ -479,12 +479,12 @@ sysEvent_t Sys_GetEvent()
} }
// check for console commands // check for console commands
const char* s = Sys_ConsoleInput(); const char* s = WIN_ConsoleInput();
if ( s ) { if ( s ) {
int len = strlen( s ) + 1; int len = strlen( s ) + 1;
char* b = (char*)Z_Malloc( len ); char* b = (char*)Z_Malloc( len );
Q_strncpyz( b, s, len-1 ); 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 // check for network packets
@ -499,7 +499,7 @@ sysEvent_t Sys_GetEvent()
netadr_t* buf = (netadr_t*)Z_Malloc( len ); netadr_t* buf = (netadr_t*)Z_Malloc( len );
*buf = adr; *buf = adr;
memcpy( buf+1, &netmsg.data[netmsg.readcount], netmsg.cursize - netmsg.readcount ); 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 // return if we have data
@ -639,7 +639,7 @@ int WINAPI WinMainImpl( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCm
WIN_InitMonitorList(); WIN_InitMonitorList();
// done before Com/Sys_Init since we need this for error output // done before Com/Sys_Init since we need this for error output
Sys_CreateConsole(); WIN_CreateConsole();
// get the initial time base // get the initial time base
Sys_Milliseconds(); Sys_Milliseconds();

View file

@ -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 ) { if ( !pDS ) {
return; return;

View file

@ -126,7 +126,7 @@ static LONG WINAPI ConWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
if ( ( com_dedicated && com_dedicated->integer ) ) if ( ( com_dedicated && com_dedicated->integer ) )
{ {
cmdString = CopyString( "quit" ); 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 ) else if ( s_wcd.quitOnClose )
{ {
@ -189,7 +189,7 @@ static LONG WINAPI ConWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
else else
{ {
cmdString = CopyString( "quit" ); 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 ) else if ( wParam == CLEAR_ID )
@ -358,7 +358,7 @@ LONG WINAPI InputLineWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
/* /*
** Sys_CreateConsole ** Sys_CreateConsole
*/ */
void Sys_CreateConsole( void ) void WIN_CreateConsole( void )
{ {
const int desiredw = 540; const int desiredw = 540;
const int desiredh = 450; const int desiredh = 450;
@ -501,7 +501,7 @@ void Sys_CreateConsole( void )
/* /*
** Sys_DestroyConsole ** Sys_DestroyConsole
*/ */
void Sys_DestroyConsole( void ) { void WIN_DestroyConsole( void ) {
if ( s_wcd.hWnd ) { if ( s_wcd.hWnd ) {
ShowWindow( s_wcd.hWnd, SW_HIDE ); ShowWindow( s_wcd.hWnd, SW_HIDE );
CloseWindow( s_wcd.hWnd ); 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 ) if ( s_wcd.consoleText[0] == 0 )
{ {
@ -560,10 +560,7 @@ const char* Sys_ConsoleInput()
} }
/* void WIN_AppendConsoleText( const char *pMsg )
** Conbuf_AppendText
*/
void Conbuf_AppendText( const char *pMsg )
{ {
#define CONSOLE_BUFFER_SIZE 16384 #define CONSOLE_BUFFER_SIZE 16384
@ -643,9 +640,7 @@ void Conbuf_AppendText( const char *pMsg )
SendMessage( s_wcd.hwndBuffer, EM_REPLACESEL, 0, (LPARAM) buffer ); SendMessage( s_wcd.hwndBuffer, EM_REPLACESEL, 0, (LPARAM) buffer );
} }
/*
** Sys_SetErrorText
*/
void Sys_SetErrorText( const char *buf ) void Sys_SetErrorText( const char *buf )
{ {
Q_strncpyz( s_wcd.errorString, buf, sizeof( s_wcd.errorString ) ); Q_strncpyz( s_wcd.errorString, buf, sizeof( s_wcd.errorString ) );

View file

@ -222,14 +222,14 @@ LRESULT CALLBACK MainWndProc (
// but anyone running vista is a moron anyway, so fkit :P // but anyone running vista is a moron anyway, so fkit :P
if (i > 0) { if (i > 0) {
while (i >= WHEEL_DELTA) { while (i >= WHEEL_DELTA) {
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELUP, qtrue, 0, NULL ); WIN_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, qfalse, 0, NULL );
i -= WHEEL_DELTA; i -= WHEEL_DELTA;
} }
} else { } else {
while (i <= -WHEEL_DELTA) { while (i <= -WHEEL_DELTA) {
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELDOWN, qtrue, 0, NULL ); WIN_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, qfalse, 0, NULL );
i += WHEEL_DELTA; i += WHEEL_DELTA;
} }
} }
@ -269,7 +269,7 @@ LRESULT CALLBACK MainWndProc (
case WM_ACTIVATE: case WM_ACTIVATE:
WIN_AppActivate( (LOWORD(wParam) != WA_INACTIVE), !!(BOOL)HIWORD(wParam) ); WIN_AppActivate( (LOWORD(wParam) != WA_INACTIVE), !!(BOOL)HIWORD(wParam) );
SNDDMA_Activate(); WIN_S_WindowActivate();
break; break;
case WM_MOVE: case WM_MOVE:
@ -317,19 +317,19 @@ LRESULT CALLBACK MainWndProc (
} }
// fall through // fall through
case WM_KEYDOWN: 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; break;
case WM_SYSKEYUP: case WM_SYSKEYUP:
case WM_KEYUP: 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; break;
case WM_CHAR: case WM_CHAR:
{ {
const char scanCode = (char)( ( lParam >> 16 ) & 0xFF ); const char scanCode = (char)( ( lParam >> 16 ) & 0xFF );
if ( scanCode != 0x29 ) // never send an event for the console key ('~' or '`') 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; break;