Eigene Dateien/FlowVis/src/VProgram.h

Go to the documentation of this file.
00001 #pragma once
00002 
00003 #ifndef __v_program_h
00004 #define __v_program_h
00005 
00006 #include "VShader.h"
00007 
00011 class VProgram
00012 {
00013 public:
00014 
00018         VProgram() : m_uProgram(0)
00019         {
00020                 m_refCount = new int;
00021                 *m_refCount = 0; 
00022                 //initialize();
00023         };
00024 
00029         VProgram(const VShader & shaShader) : m_uProgram(0)
00030         {
00031                 m_refCount = new int;
00032                 *m_refCount = 1;
00033                 initialize();
00034                 attach(shaShader);
00035         };
00036 
00042         VProgram(const VShader & shaShaderA, const VShader & shaShaderB) : m_uProgram(0)
00043         {
00044                 m_refCount = new int;
00045                 *m_refCount = 1;
00046                 initialize();
00047                 attach(shaShaderA);
00048                 attach(shaShaderB);
00049         };
00050 
00054         ~VProgram()
00055         {
00056                 --*m_refCount;
00057                 if(*m_refCount == 0)
00058                 {
00059                         uninitialize();
00060                         delete m_refCount;
00061                         m_refCount = 0;
00062                 }
00063         };
00064 
00068         VProgram & operator=(const VProgram & rhs)
00069         {
00070                 if(this != &rhs)
00071                 {
00072                         --*m_refCount;
00073                         if(*m_refCount == 0)
00074                         {
00075                                 uninitialize();
00076                                 delete m_refCount;
00077                                 m_refCount = 0;
00078                         }
00079                         m_refCount = rhs.m_refCount;
00080                         m_uProgram = rhs.m_uProgram;
00081                         m_lisShaders = rhs.m_lisShaders;
00082                         ++*m_refCount;
00083                 }
00084                 return (*this);
00085         }
00086 
00091         void attach(const VShader & shaShader);
00092 
00097         void detach(const VShader & shaShader);
00098 
00102         void bind();
00103 
00107         void release();
00108 
00114         const int getUniformLocation(const std::string & strName) const;
00115 
00121         const int getAttributeLocation(const std::string & strName) const;
00122 
00123 protected:
00124         
00128         VProgram(const VProgram & rhs)
00129         {
00130                 m_refCount = rhs.m_refCount;
00131                 m_uProgram = rhs.m_uProgram;
00132                 m_lisShaders = rhs.m_lisShaders;
00133                 ++*m_refCount;
00134         }
00135 
00139         void link();
00140 
00144         void initialize();
00145 
00149         void uninitialize();
00150 
00151 private:
00152 
00153         int * m_refCount;                                       
00154         unsigned int m_uProgram;                        
00155         std::list<VShader> m_lisShaders;                
00157 };
00158 
00159 #endif //__v_program_h

Generated on Mon Jan 21 01:15:16 2008 for FlowVis by  doxygen 1.5.4