void SetSpewFunctionLogFile( char const *pFilename ) { Assert( (!g_pLogFile) ); g_pLogFile = g_pFileSystem->Open( pFilename, "a" ); Assert( g_pLogFile ); if (!g_pLogFile) Error("Can't create LogFile:\"%s\"\n", pFilename ); CmdLib_FPrintf( g_pLogFile, "\n\n\n" ); }
void OutputWindingColor (winding_t *w, FileHandle_t glview, int r, int g, int b) { int i; CmdLib_FPrintf( glview, "%i\n", w->numpoints); float lr = r * (1.0f/255.0f); float lg = g * (1.0f/255.0f); float lb = b * (1.0f/255.0f); for (i=0 ; i<w->numpoints ; i++) { CmdLib_FPrintf(glview, "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\n", w->p[i][0], w->p[i][1], w->p[i][2], lr, lg, lb); } //CmdLib_FPrintf(glview, "\n"); }
//----------------------------------------------------------------------------- // Purpose: Writes a glview text file containing the collision surface in question // Input : *pCollide - // *pFilename - //----------------------------------------------------------------------------- void DumpRayToGlView( Ray_t const& ray, float dist, Vector* pColor, const char *pFilename ) { Vector dir = ray.m_Delta; float len = VectorNormalize(dir); if (len < 1e-3) return; Vector up( 0, 0, 1 ); Vector crossDir; if (fabs(DotProduct(up, dir)) - 1.0f < -1e-3 ) { CrossProduct( dir, up, crossDir ); VectorNormalize(crossDir); } else { up.Init( 0, 1, 0 ); CrossProduct( dir, up, crossDir ); VectorNormalize(crossDir); } Vector end; Vector start1, start2; VectorMA( ray.m_Start, dist, ray.m_Delta, end ); VectorMA( ray.m_Start, -2, crossDir, start1 ); VectorMA( ray.m_Start, 2, crossDir, start2 ); FileHandle_t fp = g_pFileSystem->Open( pFilename, "a" ); int vert = 0; CmdLib_FPrintf( fp, "3\n" ); CmdLib_FPrintf( fp, "%6.3f %6.3f %6.3f %.2f %.2f %.2f\n", start1.x, start1.y, start1.z, pColor->x, pColor->y, pColor->z ); vert++; CmdLib_FPrintf( fp, "%6.3f %6.3f %6.3f %.2f %.2f %.2f\n", start2.x, start2.y, start2.z, pColor->x, pColor->y, pColor->z ); vert++; CmdLib_FPrintf( fp, "%6.3f %6.3f %6.3f %.2f %.2f %.2f\n", end.x, end.y, end.z, pColor->x, pColor->y, pColor->z ); vert++; g_pFileSystem->Close( fp ); }
void OutputWinding (winding_t *w, FileHandle_t glview) { static int level = 128; vec_t light; int i; CmdLib_FPrintf( glview, "%i\n", w->numpoints); level+=28; light = (level&255)/255.0; for (i=0 ; i<w->numpoints ; i++) { CmdLib_FPrintf(glview, "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\n", w->p[i][0], w->p[i][1], w->p[i][2], light, light, light); } //CmdLib_FPrintf(glview, "\n"); }
SpewRetval_t CmdLib_SpewOutputFunc( SpewType_t type, char const *pMsg ) { // Hopefully two threads won't call this simultaneously right at the start! if ( !g_bSpewCSInitted ) { InitializeCriticalSection( &g_SpewCS ); g_bSpewCSInitted = true; } WORD old; SpewRetval_t retVal; EnterCriticalSection( &g_SpewCS ); { if (( type == SPEW_MESSAGE ) || (type == SPEW_LOG )) { old = SetConsoleTextColor( 1, 1, 1, 0 ); retVal = SPEW_CONTINUE; } else if( type == SPEW_WARNING ) { old = SetConsoleTextColor( 1, 1, 0, 1 ); retVal = SPEW_CONTINUE; } else if( type == SPEW_ASSERT ) { old = SetConsoleTextColor( 1, 0, 0, 1 ); retVal = SPEW_DEBUGGER; #ifdef MPI // VMPI workers don't want to bring up dialogs and suchlike. if ( g_bUseMPI && !g_bMPIMaster ) { VMPI_HandleCrash( pMsg, true ); exit( 0 ); } #endif } else if( type == SPEW_ERROR ) { old = SetConsoleTextColor( 1, 0, 0, 1 ); retVal = SPEW_ABORT; // doesn't matter.. we exit below so we can return an errorlevel (which dbg.dll doesn't do). } else { old = SetConsoleTextColor( 1, 1, 1, 1 ); retVal = SPEW_CONTINUE; } if ( !g_bSuppressPrintfOutput || type == SPEW_ERROR ) printf( "%s", pMsg ); OutputDebugString( pMsg ); if ( type == SPEW_ERROR ) { printf( "\n" ); OutputDebugString( "\n" ); } if( g_pLogFile ) { CmdLib_FPrintf( g_pLogFile, "%s", pMsg ); g_pFileSystem->Flush( g_pLogFile ); } // Dispatch to other spew hooks. FOR_EACH_LL( g_ExtraSpewHooks, i ) g_ExtraSpewHooks[i]( pMsg ); RestoreConsoleTextColor( old ); } LeaveCriticalSection( &g_SpewCS ); if ( type == SPEW_ERROR ) { CmdLib_Exit( 1 ); } return retVal; }
SpewRetval_t CmdLib_SpewOutputFunc( SpewType_t type, char const *pMsg ) { // Hopefully two threads won't call this simultaneously right at the start! if ( !g_bSpewCSInitted ) { InitializeCriticalSection( &g_SpewCS ); g_bSpewCSInitted = true; } WORD old; SpewRetval_t retVal; EnterCriticalSection( &g_SpewCS ); { if (( type == SPEW_MESSAGE ) || (type == SPEW_LOG )) { Color c = GetSpewOutputColor(); if ( c.r() != 255 || c.g() != 255 || c.b() != 255 ) { // custom color old = SetConsoleTextColor( c.r(), c.g(), c.b(), c.a() ); } else { old = SetConsoleTextColor( 1, 1, 1, 0 ); } retVal = SPEW_CONTINUE; } else if( type == SPEW_WARNING ) { old = SetConsoleTextColor( 1, 1, 0, 1 ); retVal = SPEW_CONTINUE; } else if( type == SPEW_ASSERT ) { old = SetConsoleTextColor( 1, 0, 0, 1 ); retVal = SPEW_DEBUGGER; #ifdef MPI // VMPI workers don't want to bring up dialogs and suchlike. // They need to have a special function installed to handle // the exceptions and write the minidumps. // Install the function after VMPI_Init with a call: // SetupToolsMinidumpHandler( VMPI_ExceptionFilter ); if ( g_bUseMPI && !g_bMPIMaster && !Plat_IsInDebugSession() ) { // Generating an exception and letting the // installed handler handle it ::RaiseException ( 0, // dwExceptionCode EXCEPTION_NONCONTINUABLE, // dwExceptionFlags 0, // nNumberOfArguments, NULL // const ULONG_PTR* lpArguments ); // Never get here (non-continuable exception) VMPI_HandleCrash( pMsg, NULL, true ); exit( 0 ); } #endif } else if( type == SPEW_ERROR ) { old = SetConsoleTextColor( 1, 0, 0, 1 ); retVal = SPEW_ABORT; // doesn't matter.. we exit below so we can return an errorlevel (which dbg.dll doesn't do). } else { old = SetConsoleTextColor( 1, 1, 1, 1 ); retVal = SPEW_CONTINUE; } if ( !g_bSuppressPrintfOutput || type == SPEW_ERROR ) printf( "%s", pMsg ); OutputDebugString( pMsg ); if ( type == SPEW_ERROR ) { printf( "\n" ); OutputDebugString( "\n" ); } if( g_pLogFile ) { CmdLib_FPrintf( g_pLogFile, "%s", pMsg ); g_pFileSystem->Flush( g_pLogFile ); } // Dispatch to other spew hooks. FOR_EACH_LL( g_ExtraSpewHooks, i ) g_ExtraSpewHooks[i]( pMsg ); RestoreConsoleTextColor( old ); } LeaveCriticalSection( &g_SpewCS ); if ( type == SPEW_ERROR ) { CmdLib_Exit( 1 ); } return retVal; }