18 #include "precompiled.h"
78 (attr->
type == GL_FLOAT || attr->
type == GL_SHORT || attr->
type == GL_UNSIGNED_SHORT || attr->
type == GL_UNSIGNED_BYTE)
79 &&
"Unsupported attribute type"
100 return vertexArray->MakeIterator<
CVector3D>(
this);
110 return vertexArray->MakeIterator<
CVector4D>(
this);
120 return vertexArray->MakeIterator<
float[2]>(
this);
127 ENSURE(type == GL_UNSIGNED_BYTE);
130 return vertexArray->MakeIterator<
SColor3ub>(
this);
137 ENSURE(type == GL_UNSIGNED_BYTE);
140 return vertexArray->MakeIterator<
SColor4ub>(
this);
147 ENSURE(type == GL_UNSIGNED_SHORT);
150 return vertexArray->MakeIterator<
u16>(
this);
157 ENSURE(type == GL_UNSIGNED_SHORT);
160 return vertexArray->MakeIterator<
u16[2]>(
this);
167 ENSURE(type == GL_UNSIGNED_BYTE);
170 return vertexArray->MakeIterator<
u8>(
this);
177 ENSURE(type == GL_UNSIGNED_BYTE);
180 return vertexArray->MakeIterator<
u8[4]>(
this);
190 return vertexArray->MakeIterator<
short>(
this);
200 return vertexArray->MakeIterator<
short[2]>(
this);
214 return Align<32>(stride);
238 case GL_UNSIGNED_BYTE:
239 attrSize =
sizeof(GLubyte);
242 attrSize =
sizeof(GLshort);
244 case GL_UNSIGNED_SHORT:
245 attrSize =
sizeof(GLushort);
248 attrSize =
sizeof(GLfloat);
255 attrSize *= attr->
elems;
void * rtl_AllocateAligned(size_t size, size_t align)
size_t m_Index
Start index of this chunk in owner.
VertexArray * vertexArray
CVertexBuffer::VBChunk * m_VB
VertexArrayIterator< u16 > GetIterator() const
Gets the iterator over the (only) attribute in this array, i.e. a u16.
CVertexBufferManager g_VBMan
VertexIndexArray(GLenum usage)
void AddAttribute(Attribute *attr)
u8 * Bind()
Bind to this buffer; return pointer to address required as parameter to glVertexPointer ( + etc) call...
VertexArray(GLenum usage, GLenum target=GL_ARRAY_BUFFER)
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
CVertexBuffer::VBChunk * Allocate(size_t vertexSize, size_t numVertices, GLenum usage, GLenum target)
Try to allocate a vertex buffer of the given size and type.
static size_t RoundStride(size_t stride)
void SetNumVertices(size_t num)
void UpdateChunkVertices(VBChunk *chunk, void *data)
Update vertex data for given chunk. Transfers the provided data to the actual OpenGL vertex buffer...
VertexArrayIterator< T > GetIterator() const
std::vector< Attribute * > m_Attributes
void Release(CVertexBuffer::VBChunk *chunk)
Returns the given chunk to its owning buffer.
CVertexBuffer * m_Owner
Owning (parent) vertex buffer.
void rtl_FreeAligned(void *alignedPointer)
#define debug_warn(expr)
display the error dialog with the given text.