I have a function that draw a line on the screen:
void Viewer::drawScence(){
glClearColor (0.f,0.f,1.0f,1.f);
glMatrixMode (GL_PROJECTION);
glFrustumf (-1000.f,1000.f,-1000.f,1000.f,3.f,1000.f);
glMatrixMode (GL_MODELVIEW);
glShadeModel (GL_SMOOTH);
glEnableClientState (GL_VERTEX_ARRAY);
glTranslatef (0,0,-5.f);
glColor4f(0,1,0,1);
static const GLfloat vertices[3 * 3] =
{
-1000, 1000, 0,
1000, -1000, 0,
1000, 1000, 0
};
static const GLubyte colors[3*4] = {
255, 0, 0, 255,
0, 255, 0, 255,
0, 0, 255, 255
};
glVertexPointer( 3, GL_FLOAT, 0, vertices );
glDrawArrays( GL_LINES, 0, 2);
}
When I add glClear, i cannot see anything on the screen:
glClear(GL_COLOR_BUFFER_BIT);
void Viewer::drawScence(){
glClearColor (0.f,0.f,1.0f,1.f);
[color:#FF0000][b]glClear(GL_COLOR_BUFFER_BIT);[/b][/color]
glMatrixMode (GL_PROJECTION);
glFrustumf (-1000.f,1000.f,-1000.f,1000.f,3.f,1000.f);
glMatrixMode (GL_MODELVIEW);
glShadeModel (GL_SMOOTH);
glEnableClientState (GL_VERTEX_ARRAY);
glTranslatef (0,0,-5.f);
glColor4f(0,1,0,1);
static const GLfloat vertices[3 * 3] =
{
-1000, 1000, 0,
1000, -1000, 0,
1000, 1000, 0
};
static const GLubyte colors[3*4] = {
255, 0, 0, 255,
0, 255, 0, 255,
0, 0, 255, 255
};
glVertexPointer( 3, GL_FLOAT, 0, vertices );
glDrawArrays( GL_LINES, 0, 2);
}
Can anyone tell me why?
thanks,