Commit 00847a8a authored by Maciej Sumiński's avatar Maciej Sumiński

Colors are stored as unsigned bytes instead of floats.

parent 27a6f8af
......@@ -511,7 +511,7 @@ void OPENGL_GAL::EndDrawing()
// Bind vertices data buffers
glBindBuffer( GL_ARRAY_BUFFER, vboVertices );
glVertexPointer( VBO_ITEM::CoordStride, GL_FLOAT, VBO_ITEM::VertByteSize, 0 );
glColorPointer( VBO_ITEM::ColorStride, GL_FLOAT, VBO_ITEM::VertByteSize,
glColorPointer( VBO_ITEM::ColorStride, GL_UNSIGNED_BYTE, VBO_ITEM::VertByteSize,
(GLvoid*) VBO_ITEM::ColorByteOffset );
// Shader parameters
......
......@@ -83,10 +83,10 @@ void VBO_ITEM::ChangeColor( const COLOR4D& aColor )
for( unsigned int i = 0; i < m_size; ++i )
{
vertexPtr->r = aColor.r;
vertexPtr->g = aColor.g;
vertexPtr->b = aColor.b;
vertexPtr->a = aColor.a;
vertexPtr->r = aColor.r * 255;
vertexPtr->g = aColor.g * 255;
vertexPtr->b = aColor.b * 255;
vertexPtr->a = aColor.a * 255;
// Move on to the next vertex
vertexPtr++;
......
......@@ -150,10 +150,10 @@ public:
*/
inline void UseColor( const COLOR4D& aColor )
{
m_color[0] = aColor.r;
m_color[1] = aColor.g;
m_color[2] = aColor.b;
m_color[3] = aColor.a;
m_color[0] = aColor.r * 255;
m_color[1] = aColor.g * 255;
m_color[2] = aColor.b * 255;
m_color[3] = aColor.a * 255;
}
/**
......@@ -165,7 +165,7 @@ public:
{
for( unsigned int i = 0; i < VBO_ITEM::ColorStride; ++i )
{
m_color[i] = aColor[i];
m_color[i] = aColor[i] * 255;
}
}
......@@ -179,10 +179,10 @@ public:
*/
inline void UseColor( GLfloat aR, GLfloat aG, GLfloat aB, GLfloat aA )
{
m_color[0] = aR;
m_color[1] = aG;
m_color[2] = aB;
m_color[3] = aA;
m_color[0] = aR * 255;
m_color[1] = aG * 255;
m_color[2] = aB * 255;
m_color[3] = aA * 255;
}
/**
......@@ -318,7 +318,7 @@ private:
VBO_ITEM* item;
///< Color used for new vertices pushed.
GLfloat m_color[VBO_ITEM::ColorStride];
GLubyte m_color[VBO_ITEM::ColorStride];
///< Shader and its parameters used for new vertices pushed
GLfloat m_shader[VBO_ITEM::ShaderStride];
......
......@@ -39,7 +39,7 @@ namespace KiGfx
typedef struct VBO_VERTEX
{
GLfloat x, y, z; // Coordinates
GLfloat r, g, b, a; // Color
GLubyte r, g, b, a; // Color
GLfloat shader[4]; // Shader type & params
} VBO_VERTEX;
......@@ -136,10 +136,10 @@ public:
// Offset of color data from the beginning of each vertex data
static const unsigned int ColorByteOffset = offsetof(VBO_VERTEX, r);
static const unsigned int ColorOffset = ColorByteOffset / sizeof(GLfloat);
static const unsigned int ColorOffset = ColorByteOffset / sizeof(GLubyte);
static const unsigned int ColorByteSize = sizeof(VBO_VERTEX().r) + sizeof(VBO_VERTEX().g) +
sizeof(VBO_VERTEX().b) + sizeof(VBO_VERTEX().a);
static const unsigned int ColorStride = ColorByteSize / sizeof(GLfloat);
static const unsigned int ColorStride = ColorByteSize / sizeof(GLubyte);
// Shader attributes
static const unsigned int ShaderByteOffset = offsetof(VBO_VERTEX, shader);
......
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