UniShader
1.0.0a
Interface for GPGPU and working with shader programs
|
00001 #pragma once 00002 #ifndef SHADER_PROGRAM_H 00003 #define SHADER_PROGRAM_H 00004 00005 #include <UniShader/Config.h> 00006 #include <UniShader/Utility.h> 00007 #include <UniShader/ObjectBase.h> 00008 #include <UniShader/ShaderObject.h> 00009 #include <UniShader/ShaderInput.h> 00010 #include <UniShader/ShaderOutput.h> 00011 #include <UniShader/Signal.h> 00012 #include <UniShader/Attribute.h> 00013 #include <UniShader/Uniform.h> 00014 #include <UniShader/Varying.h> 00015 #include <UniShader/PrimitiveType.h> 00016 00017 #include <memory> 00018 #include <deque> 00019 00020 UNISHADER_BEGIN 00021 00022 class UniShader; 00023 00025 00041 class UniShader_API ShaderProgram : public SignalSender, public SignalReceiver, public ObjectBase{ 00042 private: 00043 ShaderProgram(); 00044 public: 00045 typedef std::shared_ptr<ShaderProgram> Ptr; 00046 typedef std::shared_ptr<const ShaderProgram> PtrConst; 00047 virtual const std::string& getClassName() const; 00048 ~ShaderProgram(); 00049 00051 class LinkStatus{ 00052 public: 00053 enum myEnum{NONE, 00054 PENDING_LINK, 00055 SUCCESSFUL_LINK, 00056 FAILED_LINK 00057 }; 00058 private: 00059 myEnum m_en; 00060 public: 00061 LinkStatus(){} 00062 LinkStatus(const LinkStatus& ref):m_en(ref.m_en){} 00063 LinkStatus(myEnum en){ m_en = en; } 00064 LinkStatus& operator =(myEnum en){ m_en = en; return *this; } 00065 operator myEnum(){ return m_en; } 00066 }; 00067 00069 00072 class SignalID{ 00073 public: 00074 enum Types{RELINKED 00075 }; 00076 }; 00077 00078 00080 00083 static Ptr create(); 00084 00086 00091 void addShaderObject(ShaderObject::Ptr& shaderObjPtr); 00092 00094 00099 bool removeShaderObject(ShaderObject::Ptr& shaderObjPtr); 00100 00102 00106 ShaderInput::Ptr getInput(); 00107 00109 00113 ShaderOutput::Ptr getOutput(); 00114 00116 00119 unsigned int getGlID() const; 00120 00122 00125 LinkStatus getLinkStatus() const; 00126 00128 00134 bool activate(PrimitiveType primitiveType, unsigned int primitiveCount); 00135 00137 00141 bool isActive(); 00142 00144 00147 bool deactivate(); 00148 00150 00155 virtual bool handleSignal(unsigned int signalID, const ObjectBase* callerPtr); 00156 private: 00157 bool ensureLink(); 00158 bool link(); 00159 int printProgramInfoLog() const; 00160 00161 std::shared_ptr<ShaderInput> m_input; 00162 std::shared_ptr<ShaderOutput> m_output; 00163 std::deque<ShaderObject::Ptr> m_shaderObjects; 00164 unsigned int m_programObjectID; 00165 LinkStatus m_linkStatus; 00166 bool m_active; 00167 }; 00168 00169 UNISHADER_END 00170 00171 #endif