00001 00006 #pragma once 00007 00008 #include <Cg/cg.h> 00009 #include <Cg/cgGL.h> 00010 00011 #include <boost/any.hpp> 00012 00013 #include <map> 00014 #include <string> 00015 00016 #include "Tools/Exception.hpp" 00017 00018 namespace Tool { 00019 00020 typedef Exception CGShaderManagerException; 00021 typedef enum { 00022 Shader_Vertex = 0, 00023 Shader_Fragment = 1 00024 } ShaderType; 00025 00026 typedef std::map<std::string,CGparameter> CGParameterList; 00027 00028 typedef struct { 00029 std::string name; 00030 ShaderType type; 00031 CGprogram program; 00032 CGprofile profile; 00033 CGParameterList parameters; 00034 } CGProgram; 00035 00040 class CGShaderManager { 00041 private: 00042 CGcontext context; 00043 std::map<std::string,CGProgram> shaders; 00044 00045 static CGShaderManager *instance; 00046 CGShaderManager(); 00047 00048 public: 00049 static CGShaderManager &getInstance(); 00050 00051 void initialise(); 00052 00053 CGProgram createProgram( const std::string &name, 00054 const ShaderType &shadertype, 00055 const CGenum &sourcetype, 00056 const std::string &programfilename, 00057 const CGParameterList parameters = CGParameterList(), 00058 const std::string &mainroutine = "main", 00059 const char** args = NULL ); 00060 00061 void destroyProgram( const std::string &name ); 00062 00063 void bindProgram( const std::string &name ); 00064 void unbindProgram( const std::string &name ); 00065 }; 00066 00067 }