gKitGL
TPAttributeArrays.h
00001 
00002 #ifndef _TP_ATTRIBUTE_ARRAYS_H
00003 #define _TP_ATTRIBUTE_ARRAYS_H
00004 
00005 #include "GL/GLPlatform.h"
00006 #include "GLResource.h"
00007 #include "GL/TPAttributes.h"
00008 
00009 
00010 namespace gk {
00011 
00012 //! representation d'un VertexArray openGL. ensemble de buffers permettant de dessiner un objet.
00013 class GLBufferArray : public GLResource
00014 {
00015     GLuint m_name;
00016 
00017     // non copyable
00018     GLBufferArray( const GLBufferArray& );
00019     GLBufferArray& operator= ( const GLBufferArray& );
00020     
00021 public:
00022     //! constructeur par defaut.
00023     GLBufferArray( )
00024         :
00025         GLResource()
00026     {
00027         glGenVertexArrays(1, &m_name);
00028     }
00029     
00030     //! destructeur.
00031     ~GLBufferArray( )
00032     {
00033         glDeleteVertexArrays(1, &m_name);
00034     }
00035     
00036 #if 0
00037     //! associe le contenu d'un buffer aux attributs de sommet, cf. GLBuffer::bindAsVertexAttribute() pour la description des parametres.
00038     //! index identifiant de l'attribut declare dans le shader, cf. glGetAttribLocation(),
00039     int setVertexBuffer( const ProgramAttribute& attribute,
00040         GLAttributeBuffer *buffer,
00041         const int size, const GLenum type,
00042         const unsigned long int stride= 0, const unsigned long int offset= 0 )
00043     {
00044         if(buffer == NULL)
00045             return -1;
00046         if(m_name == 0)
00047             return -1;
00048         
00049         glBindVertexArray(m_name);
00050         //! \todo
00051         //~ ActiveAttributes[attribute.location()].setBufferState(attribute, buffer, BufferLayout(size, type, stride, offset));
00052         return 0;
00053     }
00054     
00055     //! associe le contenu d'un buffer aux attributs d'instance, cf. GLBuffer::bindAsInstanceAttribute() pour la description des parametres.
00056     //! index identifiant de l'attribut declare dans le shader, cf. glGetAttribLocation(),
00057     int setInstanceBuffer( const ProgramAttribute& attribute,
00058         GLAttributeBuffer *buffer, 
00059         const int size, const GLenum type,
00060         const unsigned long int stride= 0, const unsigned long int offset= 0,
00061         const int divisor= 1 )
00062     {
00063         if(buffer == NULL)
00064             return -1;
00065         if(m_name == 0)
00066             return -1;
00067         
00068         glBindVertexArray(m_name);
00069         //! \todo
00070         //~ ActiveAttributes[attribute.location()].setBufferState(attribute, buffer, BufferLayout(size, type, stride, offset, divisor));
00071         return 0;
00072     }
00073     
00074     int setIndexBuffer( GLIndexBuffer *buffer, const GLenum type= GL_UNSIGNED_INT, const unsigned int offset= 0 )
00075     {
00076         if(buffer == NULL)
00077             return -1;
00078         if(m_name == 0)
00079             return -1;
00080         
00081         glBindVertexArray(m_name);
00082         //! \todo
00083         //~ ActiveIndex.setIndexState(buffer, IndexLayout(type, offset));
00084         return 0;
00085     }
00086 #endif
00087 
00088     //! creation de la ressource openGL.
00089     int createGLResource( )
00090     {
00091         return (m_name != 0) ? 0 : -1;
00092     }
00093     
00094     //! destruction de la ressource openGL.
00095     int releaseGLResource( )
00096     {
00097         return (m_name != 0) ? 0 : -1;
00098     }
00099 };
00100 
00101 }
00102 
00103 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerator Friends