Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_SHADER_CLASS_H__
00009 #define __SP_SHADER_CLASS_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013 #include "Base/spInputOutput.hpp"
00014 #include "Base/spBaseObject.hpp"
00015 #include "RenderSystem/spShaderConfigTypes.hpp"
00016 #include "RenderSystem/spComputeShader.hpp"
00017
00018
00019 namespace sp
00020 {
00021
00022 namespace scene { class MaterialNode; }
00023
00024 namespace video
00025 {
00026
00027
00028 class ConstantBuffer;
00029
00034 enum EBuildShaderFlags
00035 {
00036 SHADERBUILD_CG = 0x0002,
00037 SHADERBUILD_GLSL = 0x0004,
00038 SHADERBUILD_HLSL3 = 0x0008,
00039 SHADERBUILD_HLSL5 = 0x0010,
00040
00041 SHADERBUILD_VERTEX = 0x0100,
00042 SHADERBUILD_PIXEL = 0x0200,
00043 SHADERBUILD_GEOMETRY = 0x0400,
00044 SHADERBUILD_HULL = 0x0800,
00045 SHADERBUILD_DOMAIN = 0x1000,
00046 };
00047
00048
00049 class Shader;
00050 class VertexFormat;
00051
00063 class SP_EXPORT ShaderClass : public BaseObject
00064 {
00065
00066 public:
00067
00068 virtual ~ShaderClass();
00069
00070
00071
00076 virtual void bind(const scene::MaterialNode* Object = 0) = 0;
00077
00079 virtual void unbind() = 0;
00080
00085 virtual bool link() = 0;
00086
00087
00088
00098 static EShaderVersions getShaderVersion(s32 Flags);
00099
00119 static bool build(
00120 const io::stringc &Name,
00121
00122 ShaderClass* &ShdClass,
00123 VertexFormat* VertFmt,
00124
00125 const std::list<io::stringc>* ShdBufferVertex,
00126 const std::list<io::stringc>* ShdBufferPixel,
00127
00128 const io::stringc &VertexMain = "VertexMain",
00129 const io::stringc &PixelMain = "PixelMain",
00130
00131 s32 Flags = SHADERBUILD_CG
00132 );
00133
00134
00135
00143 inline void setObjectCallback(const ShaderObjectCallback &CallbackProc)
00144 {
00145 ObjectCallback_ = CallbackProc;
00146 }
00147
00154 inline void setSurfaceCallback(const ShaderSurfaceCallback &CallbackProc)
00155 {
00156 SurfaceCallback_ = CallbackProc;
00157 }
00158
00159 inline Shader* getVertexShader() const
00160 {
00161 return VertexShader_;
00162 }
00163 inline Shader* getPixelShader() const
00164 {
00165 return PixelShader_;
00166 }
00167 inline Shader* getGeometryShader() const
00168 {
00169 return GeometryShader_;
00170 }
00171 inline Shader* getHullShader() const
00172 {
00173 return HullShader_;
00174 }
00175 inline Shader* getDomainShader() const
00176 {
00177 return DomainShader_;
00178 }
00179 inline Shader* getComputeShader() const
00180 {
00181 return ComputeShader_;
00182 }
00183
00190 inline const std::vector<ConstantBuffer*>& getConstantBufferList() const
00191 {
00192 return ConstBufferList_;
00193 }
00194
00196 inline bool isHighLevel() const
00197 {
00198 return HighLevel_;
00199 }
00201 inline bool valid() const
00202 {
00203 return CompiledSuccessfully_;
00204 }
00205
00206 protected:
00207
00208 friend class Shader;
00209
00210 ShaderClass();
00211
00212
00213
00214 void printError(const io::stringc &Message);
00215 void printWarning(const io::stringc &Message);
00216
00217
00218
00219 ShaderObjectCallback ObjectCallback_;
00220 ShaderSurfaceCallback SurfaceCallback_;
00221
00222 Shader* VertexShader_;
00223 Shader* PixelShader_;
00224 Shader* GeometryShader_;
00225 Shader* HullShader_;
00226 Shader* DomainShader_;
00227 Shader* ComputeShader_;
00228
00229 std::vector<ConstantBuffer*> ConstBufferList_;
00230
00231 bool HighLevel_;
00232 bool CompiledSuccessfully_;
00233
00234 };
00235
00236
00237 }
00238
00239 }
00240
00241
00242 #endif
00243
00244
00245
00246