//========= Copyright Valve Corporation, All rights reserved. ============// // // Purpose: // // $NoKeywords: $ // //===========================================================================// #include "materialsystem/imaterialsystem.h" #include "materialsystem/MaterialSystem_Config.h" #include "tier0/dbg.h" #include #include "filesystem.h" #include "FileSystem_Tools.h" #include "../materialsystem/ishadersystem.h" #include "utlvector.h" #include "tier0/icommandline.h" #include "tier2/tier2.h" CreateInterfaceFn g_MatSysFactory = NULL; CreateInterfaceFn g_ShaderAPIFactory = NULL; class CShaderDLLInfo { public: char m_Filename[MAX_PATH]; IShaderDLLInternal *m_pInternal; }; CUtlVector g_ShaderDLLs; bool LoadShaderDLL( const char *pFilename ) { // Load the new shader CSysModule *hInstance = g_pFullFileSystem->LoadModule( pFilename ); if ( !hInstance ) return false; // Get at the shader DLL interface CreateInterfaceFn factory = Sys_GetFactory( hInstance ); if (!factory) { g_pFullFileSystem->UnloadModule( hInstance ); return false; } IShaderDLLInternal *pShaderDLL = (IShaderDLLInternal*)factory( SHADER_DLL_INTERFACE_VERSION, NULL ); if ( !pShaderDLL ) { g_pFullFileSystem->UnloadModule( hInstance ); return false; } CShaderDLLInfo *pOut = &g_ShaderDLLs[ g_ShaderDLLs.AddToTail() ]; pOut->m_pInternal = pShaderDLL; Q_strncpy( pOut->m_Filename, pFilename, sizeof( pOut->m_Filename ) ); return true; } void PrintHeader( void ) { printf( "\n" ); printf( "\n" ); printf( "Valve Source Shader Reference\n" ); printf( "\n" ); printf( "
\n" ); printf( "

Valve Source Shader Reference

\n" ); printf( "
\n" ); } void PrintShaderContents( int dllID ) { IShaderDLLInternal *pShaderDLL = g_ShaderDLLs[dllID].m_pInternal; int nShaders = pShaderDLL->ShaderCount(); int i; printf( "

%s


\n", g_ShaderDLLs[dllID].m_Filename ); printf( "
\n" ); // define list for( i = 0; i < nShaders; i++ ) { IShader *pShader = pShaderDLL->GetShader( i ); printf( "\n", g_ShaderDLLs[dllID].m_Filename, pShader->GetName() ); printf( "
%s\n", pShader->GetName() ); // int nParams = pShader->GetNumParams(); } printf( "
\n" ); // end define list } void PrintShaderHelp( int dllID ) { IShaderDLLInternal *pShaderDLL = g_ShaderDLLs[dllID].m_pInternal; int nShaders = pShaderDLL->ShaderCount(); int i; printf( "

%s


\n", g_ShaderDLLs[dllID].m_Filename ); printf( "
\n" ); // define list for( i = 0; i < nShaders; i++ ) { IShader *pShader = pShaderDLL->GetShader( i ); printf( "\n", g_ShaderDLLs[dllID].m_Filename, pShader->GetName() ); printf( "
%s
\n", pShader->GetName() ); int nParams = pShader->GetNumParams(); int j; for( j = 0; j < nParams; j++ ) { printf( "
%s\n
%s\n", pShader->GetParamName( j ), pShader->GetParamHelp( j ) ); } printf( "

\n" ); // end define list } printf( "
\n" ); // end define list } void PrintFooter( void ) { printf( "\n" ); } int main( int argc, char **argv ) { CommandLine()->CreateCmdLine( argc, argv ); FileSystem_Init( "" ); PrintHeader(); LoadShaderDLL( "stdshader_dx6.dll" ); LoadShaderDLL( "stdshader_dx7.dll" ); LoadShaderDLL( "stdshader_dx8.dll" ); LoadShaderDLL( "stdshader_dx9.dll" ); int i; for( i = 0; i < g_ShaderDLLs.Count(); i++ ) { PrintShaderContents( i ); } for( i = 0; i < g_ShaderDLLs.Count(); i++ ) { PrintShaderHelp( i ); } PrintFooter(); FileSystem_Term(); return 0; }