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