Commit 7a43dc85 authored by Robert Menzel's avatar Robert Menzel
Browse files

added some comments, clean up, less redundant code

parent eb5193ef
......@@ -6,6 +6,24 @@
#ifndef ACGL_OPENGL_OBJECTS_ARRAYBUFFER_HH
#define ACGL_OPENGL_OBJECTS_ARRAYBUFFER_HH
/*
* An ArrayBuffer holds an array of per-vertex data. In its simplest form an
* array of one attribute, for example the vertex position or texture-coordinate.
* An ArrayBuffer however can also hold multiple attributes in an interleaved
* way.
*
* An ArrayBuffer can be drawn directly or indexed in combination with an
* ElementArrayBuffer.
*
* The combination of (multiple) attributes of (multiple) ArrayBuffers
* and one (optional) ElementArrayBuffer is a VertexBufferObject or VertexArrayObject.
*
* Note: In some documents ArrayBuffers (and sometimes ElementArrayBuffers) are
* called VertexBufferObjects, 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 <ACGL/ACGL.hh>
#include <ACGL/Base/Macros.hh>
......@@ -155,16 +173,16 @@ public:
return true;
}
//! Set data for this buffer
//! Note: The function is not const, because it changes the corresponding GPU data
inline void setData(const GLvoid* _pData)
//! Set data for this buffer and change its size, usage and mode
inline void setData(
const GLvoid* _pData,
GLsizei _elements,
GLenum _usage,
GLenum _mode)
{
glBindBuffer(GL_ARRAY_BUFFER, mContext);
glBufferData(
GL_ARRAY_BUFFER,
mStride * mElements,
_pData,
mUsage);
mUsage = _usage;
mMode = _mode;
setData( _pData, _elements );
}
//! Set data for this buffer and change its size
......@@ -173,24 +191,13 @@ public:
GLsizei _elements)
{
mElements = _elements;
glBindBuffer(GL_ARRAY_BUFFER, mContext);
glBufferData(
GL_ARRAY_BUFFER,
mStride * mElements,
_pData,
mUsage);
setData( _pData );
}
//! Set data for this buffer and change its size
inline void setData(
const GLvoid* _pData,
GLsizei _elements,
GLenum _usage,
GLenum _mode)
//! Set data for this buffer
//! Note: The function is not const, because it changes the corresponding GPU data
inline void setData(const GLvoid* _pData)
{
mElements = _elements;
mUsage = _usage;
mMode = _mode;
glBindBuffer(GL_ARRAY_BUFFER, mContext);
glBufferData(
GL_ARRAY_BUFFER,
......
......@@ -6,6 +6,20 @@
#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 <ACGL/ACGL.hh>
#include <ACGL/Base/Macros.hh>
......@@ -96,30 +110,26 @@ public:
}
//! Set data for this buffer
//! Note: The function is not const, because it changes the corresponding GPU data
inline void setData(
const GLvoid* _pData)
const GLvoid* _pData,
GLsizei _elements)
{
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mContext);
glBufferData(
GL_ELEMENT_ARRAY_BUFFER,
mElements * mSizeOfType,
_pData,
mUsage);
mElements = _elements;
setData( _pData );
}
//! Set data for this buffer
//! Note: The function is not const, because it changes the corresponding GPU data
inline void setData(
const GLvoid* _pData,
GLsizei _elements)
const GLvoid* _pData)
{
mElements = _elements;
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mContext);
glBufferData(
GL_ELEMENT_ARRAY_BUFFER,
mElements * mSizeOfType,
_pData,
mUsage);
openGLRareError();
}
// =================================================================================================== \/
......
......@@ -6,6 +6,14 @@
#ifndef ACGL_OPENGL_OBJECTS_VERTEXBUFFEROBJECT_HH
#define ACGL_OPENGL_OBJECTS_VERTEXBUFFEROBJECT_HH
/*
* A VertexBufferObject combines the two tightly related buffers from the
* ARB_vertex_buffer_object extension.
*
* M Attributes from N ArrayBuffer and one (optional) ElementArrayBuffer form
* one VertexBufferObject.
*/
#include <ACGL/ACGL.hh>
#include <ACGL/Base/Macros.hh>
......@@ -124,7 +132,7 @@ public:
enable();
draw();
disable();
};
}
void drawElements(void) const
{
......@@ -160,5 +168,4 @@ ACGL_SHARED_TYPEDEF(VertexBufferObject)
} // OpenGL
} // ACGL
#endif // ACGL_OPENGL_OBJECTS_VERTEXBUFFEROBJECT_HH
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment