Added possibility of adding multiple vertices to VBO_ITEM at once
This commit is contained in:
parent
bce9f685ea
commit
32784ea191
|
@ -651,28 +651,16 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP
|
||||||
VECTOR2D v3( aEndPoint.x - ( aWidth * cos( beta ) / 2.0 ),
|
VECTOR2D v3( aEndPoint.x - ( aWidth * cos( beta ) / 2.0 ),
|
||||||
aEndPoint.y + ( aWidth * sin( beta ) / 2.0 ) );
|
aEndPoint.y + ( aWidth * sin( beta ) / 2.0 ) );
|
||||||
|
|
||||||
// First triangle
|
// Two triangles
|
||||||
GLfloat newVertex1[] = { v0.x, v0.y, layerDepth,
|
GLfloat newVertices[] = {
|
||||||
strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a };
|
v0.x, v0.y, layerDepth, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a,
|
||||||
GLfloat newVertex2[] = { v1.x, v1.y, layerDepth,
|
v1.x, v1.y, layerDepth, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a,
|
||||||
strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a };
|
v2.x, v2.y, layerDepth, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a,
|
||||||
GLfloat newVertex3[] = { v2.x, v2.y, layerDepth,
|
v0.x, v0.y, layerDepth, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a,
|
||||||
strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a };
|
v2.x, v2.y, layerDepth, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a,
|
||||||
|
v3.x, v3.y, layerDepth, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a
|
||||||
// Second triangle
|
};
|
||||||
GLfloat newVertex4[] = { v0.x, v0.y, layerDepth,
|
curVboItem->PushVertices( newVertices, 6 );
|
||||||
strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a };
|
|
||||||
GLfloat newVertex5[] = { v2.x, v2.y, layerDepth,
|
|
||||||
strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a };
|
|
||||||
GLfloat newVertex6[] = { v3.x, v3.y, layerDepth,
|
|
||||||
strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a };
|
|
||||||
|
|
||||||
curVboItem->PushVertex( newVertex1 );
|
|
||||||
curVboItem->PushVertex( newVertex2 );
|
|
||||||
curVboItem->PushVertex( newVertex3 );
|
|
||||||
curVboItem->PushVertex( newVertex4 );
|
|
||||||
curVboItem->PushVertex( newVertex5 );
|
|
||||||
curVboItem->PushVertex( newVertex6 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( isFillEnabled )
|
if( isFillEnabled )
|
||||||
|
|
|
@ -61,7 +61,7 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
|
||||||
if( m_vertices )
|
if( m_vertices )
|
||||||
{
|
{
|
||||||
// Copy all previous vertices data
|
// Copy all previous vertices data
|
||||||
memcpy( newVertices, m_vertices, ( m_size ) * VertSize );
|
memcpy( newVertices, m_vertices, m_size * VertSize );
|
||||||
delete m_vertices;
|
delete m_vertices;
|
||||||
}
|
}
|
||||||
m_vertices = newVertices;
|
m_vertices = newVertices;
|
||||||
|
@ -73,7 +73,7 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
|
||||||
if( m_indices )
|
if( m_indices )
|
||||||
{
|
{
|
||||||
// Copy all previous vertices data
|
// Copy all previous vertices data
|
||||||
memcpy( newIndices, m_indices, ( m_size ) * IndSize );
|
memcpy( newIndices, m_indices, m_size * IndSize );
|
||||||
delete m_indices;
|
delete m_indices;
|
||||||
}
|
}
|
||||||
m_indices = newIndices;
|
m_indices = newIndices;
|
||||||
|
@ -88,7 +88,36 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
|
||||||
|
|
||||||
void VBO_ITEM::PushVertices( const GLfloat* aVertex, GLuint aSize )
|
void VBO_ITEM::PushVertices( const GLfloat* aVertex, GLuint aSize )
|
||||||
{
|
{
|
||||||
// FIXME to be done
|
int newSize = m_size + aSize;
|
||||||
|
GLfloat* newVertices = new GLfloat[newSize * VertStride];
|
||||||
|
GLuint* newIndices = new GLuint[newSize * IndStride];
|
||||||
|
|
||||||
|
// Handle new vertices
|
||||||
|
if( m_vertices )
|
||||||
|
{
|
||||||
|
// Copy all previous vertices data
|
||||||
|
memcpy( newVertices, m_vertices, ( m_size ) * VertSize );
|
||||||
|
delete m_vertices;
|
||||||
|
}
|
||||||
|
m_vertices = newVertices;
|
||||||
|
|
||||||
|
// Add the new vertex
|
||||||
|
memcpy( &newVertices[m_size * VertStride], aVertex, aSize * VertSize );
|
||||||
|
|
||||||
|
// Handle new indices
|
||||||
|
if( m_indices )
|
||||||
|
{
|
||||||
|
// Copy all previous vertices data
|
||||||
|
memcpy( newIndices, m_indices, ( m_size ) * IndSize );
|
||||||
|
delete m_indices;
|
||||||
|
}
|
||||||
|
m_indices = newIndices;
|
||||||
|
|
||||||
|
// Add the new vertex
|
||||||
|
for( int i = m_size; i < newSize; ++i )
|
||||||
|
m_indices[i] = m_offset + i;
|
||||||
|
|
||||||
|
m_size += aSize;
|
||||||
m_isDirty = true;
|
m_isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,7 @@ private:
|
||||||
///< Packed by 7 floats for each vertex: {X, Y, Z, R, G, B, A}
|
///< Packed by 7 floats for each vertex: {X, Y, Z, R, G, B, A}
|
||||||
GLfloat* m_vertices;
|
GLfloat* m_vertices;
|
||||||
|
|
||||||
|
///< Indices of vertices
|
||||||
GLuint* m_indices;
|
GLuint* m_indices;
|
||||||
|
|
||||||
///< Offset and size of data in VBO.
|
///< Offset and size of data in VBO.
|
||||||
|
|
Loading…
Reference in New Issue