Fredric
04-09-2000, 04:13 PM
I'm at the point in my OpenGL book where the author explains how to plot points on the screen and make a polygon. I tried, for myself, to display a polygon in a window with the following code:
#include 'windows.h'
#include 'gl/gl.h'
#include 'gl/glaux.h'
#include 'conio.h'
void CALLBACK DrawScene()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //r,g,b,a
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON); // begin drawing the square
glColor3f(0.0f, 1.0f, 0.0f);
glVertex2f(0.0, 0.0);
glVertex2f(50.0, 0.0);
glVertex2f(50.0, 50.0);
glVertex2f(0.0, 5.0);
glEnd();
glFlush(); // force drawing
}
void main()
{
auxInitDisplayMode(AUX_SINGLE | AUX_RGBA);
auxInitPosition(100,100,250,250);
auxInitWindow("A simple square");
auxMainLoop(DrawScene);
cprintf("Push any key to close the coloured window...\n");
getch();
}
I get no compile-time errors, and the application runs fine. It opens the window, but it doesn't display the polygon that I defined in the code. Can anyone help me out here?
#include 'windows.h'
#include 'gl/gl.h'
#include 'gl/glaux.h'
#include 'conio.h'
void CALLBACK DrawScene()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //r,g,b,a
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON); // begin drawing the square
glColor3f(0.0f, 1.0f, 0.0f);
glVertex2f(0.0, 0.0);
glVertex2f(50.0, 0.0);
glVertex2f(50.0, 50.0);
glVertex2f(0.0, 5.0);
glEnd();
glFlush(); // force drawing
}
void main()
{
auxInitDisplayMode(AUX_SINGLE | AUX_RGBA);
auxInitPosition(100,100,250,250);
auxInitWindow("A simple square");
auxMainLoop(DrawScene);
cprintf("Push any key to close the coloured window...\n");
getch();
}
I get no compile-time errors, and the application runs fine. It opens the window, but it doesn't display the polygon that I defined in the code. Can anyone help me out here?