Originally posted by airseb:
Topic: what is the problem with this little program ?
}
… a lot … (if this is your code word for word …)
Try This;
#include <glut.h>
void Init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0) ;
}
void Reshape(int w, int h)
{
glMatrixMode(GL_PROJECTION);
glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0) ;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void Display(void)
{
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0 );
glBegin (GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd();
glFlush();
}
void main (int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB);
glutInitWindowSize(300, 300); // Any Window Size will do
glutInitWindowPosition(100, 100); // Again any Window position will do
glutCreateWindow(“Any Name you like”);
glutDisplayFunc(Display);
glutReshapeFunc(Reshape);
glutMainLoop();
}
A FEW POINTERS:
You neither registered a diplay function nor a Reshape function (glutDisplayFunc() & glutReshapeFunc() respectively).
Your projection transform (glOrtho)was concatenated with the model commands
(Minor) you leave spaces between commands and the semi-colon e.g. glWhatever(void)_;
You did not include the header file glut.h, assuming that’s what you wanted to use …
'Looks as if you’re very very new to OpenGL. I suggest you study the 1st 4 chapters of the OpenGL programming guide (aka. the Red Book) before trying to write any more programs …