1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//===========================================================================//
#include "materialsystem/imaterialsystem.h"
#include "materialsystem/MaterialSystem_Config.h"
#include "tier0/dbg.h"
#include <windows.h>
#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<CShaderDLLInfo> 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( "<HTML>\n" );
printf( "<HEAD>\n" );
printf( "<TITLE>Valve Source Shader Reference</TITLE>\n" );
printf( "</HEAD>\n" );
printf( "<CENTER>\n" );
printf( "<H1>Valve Source Shader Reference</H1>\n" );
printf( "</CENTER>\n" );
}
void PrintShaderContents( int dllID )
{
IShaderDLLInternal *pShaderDLL = g_ShaderDLLs[dllID].m_pInternal;
int nShaders = pShaderDLL->ShaderCount();
int i;
printf( "<H2>%s</H2><BR>\n", g_ShaderDLLs[dllID].m_Filename );
printf( "<dl>\n" ); // define list
for( i = 0; i < nShaders; i++ )
{
IShader *pShader = pShaderDLL->GetShader( i );
printf( "<A HREF=\"#%s_%s\">\n", g_ShaderDLLs[dllID].m_Filename, pShader->GetName() );
printf( "<dt>%s</A>\n", pShader->GetName() );
// int nParams = pShader->GetNumParams();
}
printf( "</dl>\n" ); // end define list
}
void PrintShaderHelp( int dllID )
{
IShaderDLLInternal *pShaderDLL = g_ShaderDLLs[dllID].m_pInternal;
int nShaders = pShaderDLL->ShaderCount();
int i;
printf( "<H2>%s</H2><BR>\n", g_ShaderDLLs[dllID].m_Filename );
printf( "<dl>\n" ); // define list
for( i = 0; i < nShaders; i++ )
{
IShader *pShader = pShaderDLL->GetShader( i );
printf( "<A NAME=\"%s_%s\"></A>\n", g_ShaderDLLs[dllID].m_Filename, pShader->GetName() );
printf( "<dt>%s<dl>\n", pShader->GetName() );
int nParams = pShader->GetNumParams();
int j;
for( j = 0; j < nParams; j++ )
{
printf( "<dt>%s\n<dd>%s\n",
pShader->GetParamName( j ),
pShader->GetParamHelp( j )
);
}
printf( "</dl><br>\n" ); // end define list
}
printf( "</dl>\n" ); // end define list
}
void PrintFooter( void )
{
printf( "</HTML>\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;
}
|