Eigene Dateien/FlowVis/src/VShader.h

Go to the documentation of this file.
00001 #pragma once
00002 
00003 #ifndef __v_shader_h
00004 #define __v_shader_h
00005 
00006 #include <stdlib.h>
00007 #include <iostream>
00008 #include <fstream>
00009 #include <string>
00010 #include <list>
00011 #include <map>
00012 #include "VCommon.h"
00013 
00014 
00015 class VProgram;
00016 
00020 class VShader
00021 {
00022         friend class VProgram;
00023 
00024 public:
00025 
00029         VShader(const VShader & rhs) : m_uObject(rhs.m_uObject), m_uType(rhs.m_uType)
00030         {
00031                 m_refCount = rhs.m_refCount;
00032                 ++*m_refCount;
00033         }
00034 
00038         ~VShader()
00039         {
00040                 --*m_refCount;
00041                 if(*m_refCount == 0)
00042                 {
00043                         uninitialize();
00044                         delete m_refCount;
00045                         m_refCount = 0;
00046                 }
00047         };
00048 
00049 protected:
00050 
00056         VShader(const unsigned int uType) : m_uType(uType), m_uObject(0)
00057         {
00058                 m_refCount = new int;
00059                 *m_refCount = 1;
00060                 initialize();
00061         };
00062 
00066         void initialize();
00067 
00071         void uninitialize();
00072         
00077         void load(const std::string & strFilename);
00078 
00083         const unsigned int GetObject() const
00084         {
00085                 return m_uObject;
00086         };
00087 
00092         const unsigned int GetType() const
00093         {
00094                 return m_uType;
00095         };
00096 
00100         void attach() const
00101         {
00102                 s_mapAttachment[m_uObject]++;
00103         };
00104 
00108         void detach() const
00109         {
00110                 if((int)s_mapAttachment.size() > 0)
00111                         s_mapAttachment[m_uObject]--;
00112         };
00113 
00114         int * m_refCount;                               
00115         const unsigned int m_uType;             
00116         unsigned int m_uObject;                 
00118         static std::map<unsigned int, unsigned int> s_mapAttachment;    
00119 };
00120 
00124 class VFragmentShader : public VShader
00125 {
00126 public:
00127 
00132         VFragmentShader(const std::string & strFilename);
00133 
00137         ~VFragmentShader()
00138         {
00139         };
00140 
00141 protected:
00142 
00147         VFragmentShader(const VFragmentShader & rhs) : VShader(rhs)
00148         {
00149                 
00150         }
00151 };
00152 
00156 class VVertexShader : public VShader
00157 {
00158 public:
00159 
00164         VVertexShader(const std::string & strFilename);
00165         
00169         ~VVertexShader()
00170         {
00171         };
00172 
00173 protected:
00174 
00179         VVertexShader(const VVertexShader & rhs) : VShader(rhs)
00180         {
00181                 
00182         }
00183 
00184 };
00185 
00186 #endif //__v_shader_h

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