Xavier
1
Hi,
I have written a drawLine method, but no matter what color I specify, my lines are always black.
void Game::drawLine(CGPoint origin, CGPoint dest, CGFloat width)
{
glLineWidth(width);
GLfloat vertices[] = {origin.x, origin.y, dest.x, dest.y};
GLfloat colors[] = {
0.0f, 1.0f, 0.0f, 1.0f,
0.0f, 1.0f, 0.0f, 1.0f
};
glVertexPointer(2, GL_FLOAT, 0, vertices);
glColorPointer(4, GL_FLOAT, 0, colors);
glEnableClientState(GL_COLOR_ARRAY);
glShadeModel(GL_FLAT);
glDrawArrays(GL_LINES, 0, 2);
glDisableClientState(GL_COLOR_ARRAY);
}
What did I miss ?
Thanks !
d1mbu1b
2
some suggestions to try…
// not sure if this was already enabled
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
// specify the stride
glVertexPointer(2, GL_FLOAT, 2sizeof(float), vertices);
glColorPointer(4, GL_FLOAT, 4sizeof(float), colors);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
Xmas
3
Make sure that lighting and texturing is disabled when you draw the lines.
Xavier
4
That’s it, texturing was not disabled.
Thanks a lot !
system
Closed
5
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.