Commit 8e1fe5d7 authored by Maciej Suminski's avatar Maciej Suminski

Changed data structure in VBO_ITEM.

parent e9ebdf25
......@@ -83,19 +83,19 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
vertex = *m_transform * vertex;
// Replace only coordinates, leave color as it is
memcpy( &m_vertPtr->struc.coord, &vertex[0], CoordByteSize );
memcpy( &m_vertPtr->x, &vertex[0], CoordByteSize );
}
else
{
// Add the new vertex
memcpy( &m_vertPtr->struc.coord, aVertex, CoordByteSize );
memcpy( &m_vertPtr->x, aVertex, CoordByteSize );
}
// Apply currently used color
memcpy( &m_vertPtr->struc.color, m_color, ColorByteSize );
memcpy( &m_vertPtr->r, m_color, ColorByteSize );
// Apply currently used shader
memcpy( &m_vertPtr->struc.shader, m_shader, ShaderByteSize );
memcpy( &m_vertPtr->shader, m_shader, ShaderByteSize );
// Move to the next free space
m_vertPtr++;
......@@ -206,19 +206,6 @@ void VBO_ITEM::UseShader( const GLfloat* aShader )
}
/*
// TODO
void SetVbo( int aVboId )
{
}
int GetVbo() const
{
}
*/
void VBO_ITEM::useNewBlock()
{
VBO_VERTEX* newVertBlock = new VBO_VERTEX[BLOCK_SIZE];
......
......@@ -40,25 +40,13 @@
namespace KiGfx
{
typedef struct VBO_VERTEX_DATA
typedef struct VBO_VERTEX
{
GLfloat x, y, z; // Coordinates
GLfloat r, g, b, a; // Color
GLfloat shader[4]; // Shader type & params
} VBO_VERTEX_DATA;
typedef struct VBO_VERTEX_STRUCT
{
GLfloat coord[3]; // Coordinates
GLfloat color[4]; // Color
GLfloat shader[4]; // Shader type & params
} VBO_VERTEX_STRUCT;
typedef union VBO_VERTEX
{
VBO_VERTEX_DATA data;
VBO_VERTEX_STRUCT struc;
} VBO_VERTEX;
class VBO_ITEM
{
......@@ -159,28 +147,27 @@ public:
static const int VertByteSize = sizeof(VBO_VERTEX);
static const int VertStride = VertByteSize / sizeof(GLfloat);
static const int CoordStride = sizeof(VBO_VERTEX_STRUCT().coord) / sizeof(GLfloat);
static const int CoordByteSize = sizeof(VBO_VERTEX_STRUCT().coord);
static const int CoordByteSize = sizeof(VBO_VERTEX().x) + sizeof(VBO_VERTEX().y) +
sizeof(VBO_VERTEX().z);
static const int CoordStride = CoordByteSize / sizeof(GLfloat);
// Offset of color data from the beginning of each vertex data
static const int ColorByteOffset = offsetof( VBO_VERTEX_STRUCT, color );
static const int ColorByteOffset = offsetof(VBO_VERTEX, r);
static const int ColorOffset = ColorByteOffset / sizeof(GLfloat);
static const int ColorStride = sizeof(VBO_VERTEX_STRUCT().color) / sizeof(GLfloat);
static const int ColorByteSize = sizeof(VBO_VERTEX_STRUCT().color);
static const int ColorByteSize = sizeof(VBO_VERTEX().r) + sizeof(VBO_VERTEX().g) +
sizeof(VBO_VERTEX().b) + sizeof(VBO_VERTEX().a);
static const int ColorStride = ColorByteSize / sizeof(GLfloat);
// Shader attributes
static const int ShaderByteOffset = offsetof( VBO_VERTEX_STRUCT, shader );
static const int ShaderByteOffset = offsetof(VBO_VERTEX, shader);
static const int ShaderOffset = ShaderByteOffset / sizeof(GLfloat);
static const int ShaderStride = sizeof(VBO_VERTEX_STRUCT().shader) / sizeof(GLfloat);
static const int ShaderByteSize = sizeof(VBO_VERTEX_STRUCT().shader);
static const int ShaderByteSize = sizeof(VBO_VERTEX().shader);
static const int ShaderStride = ShaderByteSize / sizeof(GLfloat);
static const int IndStride = 1;
static const int IndByteSize = IndStride * sizeof(GLuint);
private:
///< VBO ids in which the item is stored.
//int m_vboId; // not used yet
///< Contains vertices coordinates and colors.
///< Packed by 7 floats for each vertex: {X, Y, Z, R, G, B, A}
GLfloat* m_vertices;
......@@ -216,7 +203,7 @@ private:
///< Flag telling if the item should be recached in VBO or not.
bool m_isDirty;
///< Current transform matrix for every new vertex pushed.
///< Current transform matrix applied for every new vertex pushed.
const glm::mat4* m_transform;
};
} // namespace KiGfx
......
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