Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_CG_SHADERPROGRAM_H__
00009 #define __SP_CG_SHADERPROGRAM_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013
00014 #if defined(SP_COMPILE_WITH_CG)
00015
00016
00017 #include "Framework/Cg/spCgShaderClass.hpp"
00018 #include "RenderSystem/spShaderProgram.hpp"
00019
00020 #include <map>
00021 #include <Cg/cg.h>
00022
00023
00024 namespace sp
00025 {
00026 namespace video
00027 {
00028
00029
00031 class SP_EXPORT CgShaderProgram : public Shader
00032 {
00033
00034 public:
00035
00036 virtual ~CgShaderProgram();
00037
00038
00039
00040 bool compile(
00041 const std::list<io::stringc> &ShaderBuffer, const io::stringc &EntryPoint = "", const c8** CompilerOptions = 0
00042 );
00043
00044
00045
00046 virtual bool setConstant(const io::stringc &Name, const f32 Value);
00047 virtual bool setConstant(const io::stringc &Name, const f32* Buffer, s32 Count);
00048
00049 virtual bool setConstant(const io::stringc &Name, const s32 Value);
00050 virtual bool setConstant(const io::stringc &Name, const s32* Buffer, s32 Count);
00051
00052 virtual bool setConstant(const io::stringc &Name, const dim::vector3df &Position);
00053 virtual bool setConstant(const io::stringc &Name, const dim::vector4df &Position);
00054 virtual bool setConstant(const io::stringc &Name, const video::color &Color);
00055 virtual bool setConstant(const io::stringc &Name, const dim::matrix4f &Matrix);
00056
00057 protected:
00058
00059 friend class CgShaderClass;
00060
00061
00062
00063 CgShaderProgram(ShaderClass* Table, const EShaderTypes Type, const EShaderVersions Version);
00064
00065 bool createProgram(
00066 const io::stringc &SourceCodeString, const io::stringc &EntryPoint, const c8** CompilerOptions = 0
00067 );
00068
00069 virtual bool compileCg(
00070 const io::stringc &SourceCodeString, const io::stringc &EntryPoint, const c8** CompilerOptions = 0
00071 ) = 0;
00072
00073 virtual void bind() = 0;
00074 virtual void unbind() = 0;
00075
00076 bool getParam(const io::stringc &Name);
00077
00078 bool setupShaderConstants();
00079
00080
00081
00082 CGprofile cgProfile_;
00083 CGprogram cgProgram_;
00084
00085 std::map<std::string, CGparameter> ParameterMap_;
00086
00087 static CGparameter ActiveParam_;
00088
00089 };
00090
00091
00092 }
00093
00094 }
00095
00096
00097 #endif
00098
00099 #endif
00100
00101
00102
00103