57 PROCESS_INFORMATION pi;
58 memset(&pi, 0,
sizeof(pi));
59 memset(&si, 0,
sizeof(si));
61 si.dwFlags=STARTF_USESHOWWINDOW;
62 si.wShowWindow=SW_HIDE;
64 static bool found=
false;
65 static char work_dir[_MAX_PATH];
69 char* shader_path=
"\\shaders\\";
71 ::GetCurrentDirectory(_MAX_PATH,work_dir);
72 strcat(work_dir,shader_path);
75 result=CreateProcess(0,cmd,0,0,0,0,0,work_dir,&si,&pi);
79 WaitForSingleObject(pi.hThread, INFINITE);
82 CloseHandle(pi.hProcess);
83 CloseHandle(pi.hThread);
89 int err=GetLastError();
93 "Failed to execute preprocessor on shader\n"
94 "Ensure shaders folder is in application subdirectory\n",
98 WWASSERT_PRINT(result,
"Failed to execute preprocessor on shader (ensure shaders folder is in application subdirectory)");
113 LPD3DXBUFFER* constants,
114 LPD3DXBUFFER* shader_code
117 char shell_command[_MAX_PATH];
118 char temp_path[_MAX_PATH];
119 char temp_file[_MAX_PATH];
122 GetTempPath(_MAX_PATH, temp_path);
123 GetTempFileName(temp_path,
"shd",1,temp_file);
128 sizeof(shell_command),
129 "shaders\\rspp %s %s",
134 LPD3DXBUFFER* errors=
NULL;
138 HRESULT result=D3DXAssembleShaderFromFile
146 WWASSERT_PRINT(result==D3D_OK,
"Failed to assemble shader from file");
150bool ShdHWVertexShader::Using_Hardware=
true;
183 DWORD* vertex_shader_declaration
187 LPD3DXBUFFER shader_code=
NULL;
200 (
DWORD*)vertex_shader_declaration,
201 (
DWORD*)shader_code->GetBufferPointer(),
208 Using_Hardware=
false;
211 (
DWORD*)vertex_shader_declaration,
212 (
DWORD*)shader_code->GetBufferPointer(),
214 D3DUSAGE_SOFTWAREPROCESSING
219 if (shader_code) shader_code->Release();
231 DWORD* shader_code_str,
232 DWORD* vertex_shader_declaration
236 LPD3DXBUFFER shader_code=
NULL;
237 LPD3DXBUFFER errors=
NULL;
239 result=D3DXAssembleShader
242 strlen((
char*)shader_code_str),
250 OutputDebugString((
char*)errors->GetBufferPointer());
258 (
DWORD*)vertex_shader_declaration,
259 (
DWORD*)shader_code->GetBufferPointer(),
266 Using_Hardware=
false;
269 (
DWORD*)vertex_shader_declaration,
270 (
DWORD*)shader_code->GetBufferPointer(),
272 D3DUSAGE_SOFTWAREPROCESSING
277 OutputDebugString((
char*)shader_code_str);
314 LPD3DXBUFFER shader_code=
NULL;
325 (
DWORD*)shader_code->GetBufferPointer(),
341 LPD3DXBUFFER shader_code=
NULL;
344 result=D3DXAssembleShader
347 strlen((
char*)shader_code_str),
355 OutputDebugString((
char*)errors->GetBufferPointer());
361 (
DWORD*)shader_code->GetBufferPointer(),
384 Vector4 light_ambient(1,1,1,1);
405 if (num_lights>
max) num_lights=
max;
417 ccol.
Set(col.
X,col.
Y,col.
Z,1.0f);
433 light_ambient.
X=amb_col.
X;
434 light_ambient.
Y=amb_col.
Y;
435 light_ambient.
Z=amb_col.
Z;
449 D3DLIGHT8& light=state.
Lights[i];
452 if (light.Type==D3DLIGHT_DIRECTIONAL)
454 const D3DXVECTOR3&
dir=state.
Lights[i].Direction;
460 const D3DXVECTOR3& pos=state.
Lights[i].Position;
463 cdir.
Set(pos.x,pos.y,pos.z,0.0f);
469 state.
Lights[i].Diffuse.r,
470 state.
Lights[i].Diffuse.g,
471 state.
Lights[i].Diffuse.b,
487 light_ambient.
X*=ambient.
X;
488 light_ambient.
Y*=ambient.
Y;
489 light_ambient.
Z*=ambient.
Z;
508 Light(rinfo,ambient,diffuse,specular);
static IDirect3DDevice8 * _Get_D3D_Device8()
static void Set_Vertex_Shader_Constant(int reg, const void *data, int count)
static void Get_Render_State(RenderStateStruct &state)
static const Vector3 & Get_Ambient()
int Get_Light_Count(void) const
const Vector3 & Get_Light_Direction(int i) const
static int Get_Max_Lights()
const Vector3 & Get_Equivalent_Ambient(void) const
const Vector3 & Get_Light_Diffuse(int i) const
LightEnvironmentClass * light_environment
DWORD Create(char *file_name)
Create Pixel Shader from a file.
void Destroy()
Destroy this pixel shader.
virtual ~ShdHWPixelShader()
Destruct this pixel shader.
void Shell_Run(char *cmd)
Execute and wait for a hidden shell command.
void Preprocess_And_Assemble_Shader_From_File(char *file_name, LPD3DXBUFFER *constants, LPD3DXBUFFER *shader_code)
Preprocess and assemble a HW shader from file.
virtual ~ShdHWVertexShader()
Destruct this vertex shader.
DWORD Create(char *file_name, DWORD *vertex_shader_declaration)
Create Vertex Shader from a file and vertex stream declaration.
void Destroy()
Destroy this vertex shader.
static void Light(RenderInfoClass &rinfo, Vector4 &ambient, Vector4 &diffuse, Vector4 &specular)
Apply generic lighting.
WWINLINE void Set(float x, float y, float z, float w)
#define CV_LIGHT_DIRECTION_0
#define WWASSERT_PRINT(expr, string)