//////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2011, Computer Graphics Group RWTH Aachen University // // All rights reserved. // //////////////////////////////////////////////////////////////////////////////// #ifndef ACGL_OPENGL_OBJECTS_ELEMENTBUFFERDATA_HH #define ACGL_OPENGL_OBJECTS_ELEMENTBUFFERDATA_HH /** * An ElementArrayBuffer is an index into ArrayBuffers and defines which * elements of that array should be drawn in which order. * * The combination of (multiple) attributes of (multiple) ArrayBuffers * and one (optional) ElementArrayBuffer is a VertexBufferObject or VertexArrayObject. * * Note: In some documents ElementArrayBuffer are called VertexBufferObjects, VBOs * or IndexBufferObjects (IBOs). But ArrayBuffers can also be called VBOs... * The original extension that introduced these two new buffer types was called * ARB_vertex_buffer_object but the buffers itself are called ArrayBuffer and * ElementArrayBuffer. */ #include #include #include #include #include namespace ACGL{ namespace OpenGL{ class ElementArrayBuffer : public Buffer { // ========================================================================================================= \/ // ============================================================================================ CONSTRUCTORS \/ // ========================================================================================================= \/ public: ElementArrayBuffer( GLenum _type = GL_UNSIGNED_INT) : Buffer(GL_ELEMENT_ARRAY_BUFFER), mType(_type) {} ElementArrayBuffer( SharedBufferObject _pBuffer, GLenum _type = GL_UNSIGNED_INT) : Buffer(_pBuffer, GL_ELEMENT_ARRAY_BUFFER), mType(_type) {} // ==================================================================================================== \/ // ============================================================================================ GETTERS \/ // ==================================================================================================== \/ public: inline GLenum getType(void) const { return mType; } // ==================================================================================================== \/ // ============================================================================================ SETTERS \/ // ==================================================================================================== \/ public: //! _type has to be one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT and indicates the //! datatype of the indices inline void setType (GLenum _type) { mType = _type; } //! Returns the number of indices: GLuint getElements() { return (GLuint)( getSize() / getGLTypeSize(mType)); } //! Overloaded from the base class to _prevent_ redefining of the binding target! (see Buffer) inline void setTarget( GLenum ) { ACGL::Utils::error() << "DON'T redefine the target binding point of an ElementArrayBuffer" << std::endl; } // =================================================================================================== \/ // ============================================================================================ FIELDS \/ // =================================================================================================== \/ protected: //! index data type: GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT GLenum mType; }; ACGL_SMARTPOINTER_TYPEDEFS(ElementArrayBuffer) } // OpenGL } // ACGL #endif // ACGL_OPENGL_OBJECTS_ELEMENTBUFFERDATA_HH