OGforever
11-28-2005, 07:00 PM
Hi
this is probably a silly question
But I wonder why my triangle is not drawn
Here's a bit of the code
OG regards
void display()
{
/* Draw a grid on the screen */
int x, y, w, h;
w = glutGet(GLUT_WINDOW_WIDTH);
h = glutGet(GLUT_WINDOW_HEIGHT);
/* Clear the screen */
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
/* Set color to light grey */
glColor3f(0, 1.0, 0);
/* Loop over all points and set those that are on a multiple of five in
either coordinate to grey, this will give a 5x5 grid */
glVertex3f(2.0f, 2.0f, 2.0f); // lower left vertex
glVertex3f( 1.0f, 1.0f, 1.0f); // lower right vertex
glVertex3f( 0.0f, 0.0f, 0.0f);
glEnd();
/* Force the commands to complete */
glFlush();
}
void idle()
{
/* Update the GUI */
if(!tickGUI())
{
/* The GUI window has been closed */
exit(EXIT_SUCCESS);
}
}
void reshape(int width, int height)
{
/* Setup the viewport and transformations that must be used for
the project */
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(44.0f, width/height, 0.2f, 255.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
this is probably a silly question
But I wonder why my triangle is not drawn
Here's a bit of the code
OG regards
void display()
{
/* Draw a grid on the screen */
int x, y, w, h;
w = glutGet(GLUT_WINDOW_WIDTH);
h = glutGet(GLUT_WINDOW_HEIGHT);
/* Clear the screen */
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
/* Set color to light grey */
glColor3f(0, 1.0, 0);
/* Loop over all points and set those that are on a multiple of five in
either coordinate to grey, this will give a 5x5 grid */
glVertex3f(2.0f, 2.0f, 2.0f); // lower left vertex
glVertex3f( 1.0f, 1.0f, 1.0f); // lower right vertex
glVertex3f( 0.0f, 0.0f, 0.0f);
glEnd();
/* Force the commands to complete */
glFlush();
}
void idle()
{
/* Update the GUI */
if(!tickGUI())
{
/* The GUI window has been closed */
exit(EXIT_SUCCESS);
}
}
void reshape(int width, int height)
{
/* Setup the viewport and transformations that must be used for
the project */
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(44.0f, width/height, 0.2f, 255.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}