Commit 7a1718d0 authored by Maciej Suminski's avatar Maciej Suminski

Changed functions for adding vertices in VBO mode to make code easier to read and understand.

parent 2579fd52
This diff is collapsed.
......@@ -72,9 +72,6 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
if( m_spaceLeft == 0 )
useNewBlock();
// Add the new vertex
memcpy( m_vertPtr, aVertex, VertSize );
if( m_transform != NULL )
{
// Apply transformations
......@@ -83,9 +80,17 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
glm::vec4 transVertex = *m_transform * origVertex;
// Replace only coordinates, leave color as it is
memcpy( m_vertPtr, &transVertex[0], 3 * sizeof(GLfloat) );
memcpy( m_vertPtr, &transVertex[0], CoordSize );
}
else
{
// Add the new vertex
memcpy( m_vertPtr, aVertex, CoordSize );
}
// Apply currently used color
memcpy( m_vertPtr + ColorOffset, m_color, ColorSize );
// Move to the next free space
m_vertPtr += VertStride;
......@@ -180,7 +185,6 @@ void VBO_ITEM::ChangeColor( const COLOR4D& aColor )
}
// TODO it is not used yet
void VBO_ITEM::UseColor( const COLOR4D& aColor )
{
m_color[0] = aColor.r;
......
......@@ -506,6 +506,26 @@ private:
inline void drawLineCap( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint,
double aDepthOffset );
///< OpenGL replacement functions (that are working both in immediate and VBO modes)
/**
* @brief Starts drawing in immediate mode or does nothing if an item's caching has started.
* @param aMode specifies the primitive or primitives that will be created.
*/
inline void begin( GLenum aMode );
/**
* @brief Ends drawing in immediate mode or does nothing if an item's caching has started.
*/
inline void end();
/**
* @brief Adds vertex to the current item or draws it in immediate mode.
* @param aX is X coordinate.
* @param aY is Y coordinate.
* @param aZ is Z coordinate.
*/
inline void vertex3( double aX, double aY, double aZ );
/**
* @brief Function that replaces glTranslate and behaves according to isGrouping variable.
* In case isGrouping==false, it is simply glTranslate, in other case it
......
......@@ -130,8 +130,8 @@ public:
static const int VertStride = 7;
static const int VertSize = VertStride * sizeof(GLfloat);
static const int IndStride = 1;
static const int IndSize = IndStride * sizeof(GLuint);
static const int CoordStride = 3;
static const int CoordSize = CoordStride * sizeof(GLfloat);
// Offset of color data from the beginning of each vertex data
static const int ColorOffset = 3;
......@@ -139,6 +139,9 @@ public:
static const int ColorStride = 4;
static const int ColorSize = ColorStride * sizeof(GLfloat);
static const int IndStride = 1;
static const int IndSize = IndStride * sizeof(GLuint);
private:
///< VBO ids in which the item is stored.
//int m_vboId; // not used yet
......
Markdown is supported
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