UniShader  1.0.0a
Interface for GPGPU and working with shader programs
 All Classes Functions Typedefs Enumerations Enumerator
D:/Visual Studio 2010/Projects/Unishader project/Unishader/include/UniShader/Uniform.h
00001 #pragma once
00002 #ifndef UNIFORM_H
00003 #define UNIFORM_H
00004 
00005 #include <UniShader/Config.h>
00006 #include <UniShader/Utility.h>
00007 #include <UniShader/ObjectBase.h>
00008 #include <UniShader/SafePtr.h>
00009 #include <UniShader/Signal.h>
00010 #include <UniShader/TextureBuffer.h>
00011 #include <UniShader/GLSLType.h>
00012 
00013 #include <vector>
00014 
00015 UNISHADER_BEGIN
00016         
00017 class ShaderProgram;
00018 
00020 
00037 class UniShader_API Uniform : public SignalReceiver, public ObjectBase{
00038 public:
00039         Uniform(ShaderProgram& program, std::string name);
00040         typedef SafePtr<Uniform> Ptr; 
00041         typedef SafePtr<const Uniform> PtrConst; 
00042         virtual const std::string& getClassName() const; 
00043         ~Uniform();
00044 
00046 
00049         std::string getName() const;
00050 
00052 
00056         void transposeMatrix(bool transpose);
00057 
00059 
00062         bool isMatrixTransposed();
00063 
00065         void getSource();
00066 
00068 
00071         void clearSource();
00072 
00074 
00078         void setSource(float* arr, unsigned int size);
00079 
00081 
00084         void setSource(std::vector<float> vec);
00085 
00087 
00090         void setSource(TextureBuffer::Ptr& textureBuffer);
00091 
00093 
00096         const GLSLType& getGLSLType() const;
00097 
00099 
00103         bool prepare();
00104 
00106 
00109         void apply();
00110 
00112 
00116         void deactivateTextureSource();
00117 
00119 
00124         virtual bool handleSignal(unsigned int signalID, const ObjectBase* callerPtr);
00125 private:
00126         ShaderProgram& m_program;
00127         GLSLType m_type;
00128         std::string m_name;
00129 
00130         TextureBuffer::Ptr m_textureBuffer;
00131         void* m_plainData;
00132         size_t m_dataByteSize;
00133 
00134         int m_location;
00135         bool m_transposeMatrix;
00136         bool m_prepared;
00137         bool m_applied;
00138 };
00139 
00140 UNISHADER_END
00141 
00142 #endif