PDA

View Full Version : not working



Sergiu
01-30-2009, 01:25 AM
please tell me what is wrong with the following algorithm.i am trying to draw a triangle on the screen using the 3 vertices of the array...

GLfloat vertices[]={10,0,20,0,20,10,20,20,10,20,0,20,0,10};
GLubyte coord[]={1,2,3};
void RenderScene(void)
{

glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f,0.0f,0.0f);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2,GL_FLOAT,0,vertices);
glDrawElements(GL_TRIANGLES,3,GL_UNSIGNED_BYTE,coo rd);
glutSwapBuffers();

}

Rosario Leonardi
01-30-2009, 01:39 AM
You must set correctly your projection & model view matrix in order to set the camera properly.
google for glOrtho, glPerspective and glutLookAt

Another error, you are picking the vertex number 1 2 and 3 of your vector.
x y
20, 0
20, 10
20, 20
The three vertex have the same X coordinate, nothing will be drawn.

Sergiu
01-30-2009, 02:42 AM
the problem was , as you said, the fact that the three vertices had the same x coordinate.thank you for your help