00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_DIRECT3D9_SHADER_H__
00009 #define __SP_DIRECT3D9_SHADER_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013
00014 #if defined(SP_COMPILE_WITH_DIRECT3D9)
00015
00016
00017 #include "RenderSystem/Direct3D9/spDirect3D9ShaderClass.hpp"
00018
00019 #if defined(SP_PLATFORM_WINDOWS)
00020 # include <d3d9.h>
00021 # include <d3dx9shader.h>
00022 #endif
00023
00024
00025 namespace sp
00026 {
00027 namespace video
00028 {
00029
00030
00031 class SP_EXPORT Direct3D9Shader : public Shader
00032 {
00033
00034 public:
00035
00036 Direct3D9Shader(ShaderClass* Table, const EShaderTypes Type, const EShaderVersions Version);
00037 ~Direct3D9Shader();
00038
00039
00040
00041 bool compile(
00042 const std::list<io::stringc> &ShaderBuffer, const io::stringc &EntryPoint = "", const c8** CompilerOptions = 0
00043 );
00044
00045
00046
00047 bool setConstant(s32 Number, const EConstantTypes Type, const f32 Value);
00048 bool setConstant(s32 Number, const EConstantTypes Type, const f32* Buffer, s32 Count);
00049
00050 bool setConstant(s32 Number, const EConstantTypes Type, const dim::vector3df &Position);
00051 bool setConstant(s32 Number, const EConstantTypes Type, const video::color &Color);
00052 bool setConstant(s32 Number, const EConstantTypes Type, const dim::matrix4f &Matrix);
00053
00054
00055
00056 bool setConstant(const io::stringc &Name, const f32 Value);
00057 bool setConstant(const io::stringc &Name, const f32* Buffer, s32 Count);
00058
00059 bool setConstant(const io::stringc &Name, const s32 Value);
00060 bool setConstant(const io::stringc &Name, const s32* Buffer, s32 Count);
00061
00062 bool setConstant(const io::stringc &Name, const dim::vector3df &Position);
00063 bool setConstant(const io::stringc &Name, const dim::vector4df &Position);
00064 bool setConstant(const io::stringc &Name, const video::color &Color);
00065 bool setConstant(const io::stringc &Name, const dim::matrix4f &Matrix);
00066
00067
00068
00069 bool setConstant(const f32* Buffer, s32 StartRegister, s32 ConstAmount);
00070
00071 private:
00072
00073 friend class Direct3D9ShaderClass;
00074
00075
00076
00077 bool compileHLSL(const c8* ProgramBuffer, const c8* EntryPoint, const c8* TargetName);
00078 bool compileProgram(const c8* ProgramBuffer);
00079
00080 HRESULT d3dAssembleShader(
00081 LPCSTR pSrcData, UINT SrcDataLen, CONST D3DXMACRO* pDefines,
00082 LPD3DXINCLUDE pInclude, DWORD Flags, LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs
00083 );
00084
00085 HRESULT d3dCompileShader(
00086 LPCSTR pSrcData, UINT SrcDataLen, CONST D3DXMACRO* pDefines,
00087 LPD3DXINCLUDE pInclude, LPCSTR pFunctionName,
00088 LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader,
00089 LPD3DXBUFFER* ppErrorMsgs, LPD3DXCONSTANTTABLE* ppConstantTable
00090 );
00091
00092 bool setupShaderConstants();
00093
00094
00095
00096 IDirect3DDevice9* D3DDevice_;
00097
00098 IDirect3DVertexShader9* VertexShaderObject_;
00099 IDirect3DPixelShader9* PixelShaderObject_;
00100
00101 ID3DXConstantTable* ConstantTable_;
00102
00103 };
00104
00105
00106 }
00107
00108 }
00109
00110
00111 #endif
00112
00113 #endif
00114
00115
00116
00117