Please help me?
Having combined some poached circle code and a sample program, my supposedly red circle doesn’t appear. Is “(GL_COLOR_BUFFER_BIT);” in the wrong place, or is it something more serious? I don’t think the “double buffer” problem applies in this case.
Thanks…
/* 4th attempt to draw a red circle on a white background*/
#include <GL/glut.h>
#include <stdlib.h>
#include <math.h>
void myinit(void)
{
/* attributes */
glClearColor(1.0, 1.0, 1.0, 1.0); /* white background */
glColor3f(1.0, 0.0, 0.0); /* draw in red */
/* set up viewing /
/ 500 x 500 window with origin lower left */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 500.0, 0.0, 500.0);
glMatrixMode(GL_MODELVIEW);
}
void display( void )
{
GLint t;
GLfloat CIRCLE_RES;
GLfloat M_PI;
glClear(GL_COLOR_BUFFER_BIT); /*clear the window */
glBegin(GL_LINE_LOOP);
for(t=0;t<CIRCLE_RES;t++)
{
GLfloat angle=((GLfloat)t/(GLfloat)CIRCLE_RES)*2.0*M_PI;
glVertex2f(cos(angle), sin(angle));
}
glEnd();
glFlush(); /* clear buffers */
}
void main(int argc, char** argv)
{
/* Standard GLUT initialization */
glutInit(&argc,argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); /* default, not needed */
glutInitWindowSize(500,500); /* 500 x 500 pixel window */
glutInitWindowPosition(0,0); /* place window top left on display */
glutCreateWindow("Circle"); /* window title */
glutDisplayFunc(display); /* display callback invoked when window opened */
myinit(); /* set attributes */
glutMainLoop(); /* enter event loop */
}