Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  fill
Language: C/C++
Code:
#include <windows.h> // use as needed for your system
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
 // *************** myInit() **************
void myInit(void)
{
 glClearColour(1.0,1.0,1.0,0.0); // set white background colour
 glColour3f(0.0f, 0.0f, 0.0f); // set the drawing colour
 glPointSize(4.0); // One ‘dot’ is a 4 by 4 pixel
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 gluOrtho2D(0.0, 800.0, 0.0, 600.0);
}
 // *********************** myDisplay() ***********
void myDisplay(void)
{
 glClear(GL_COLOUR_BUFFER_BIT); // clear the screen
 glBegin(GL_POLYGON); //Draw the polygon with the following vertex
point
 glVertex2i(100,100);
 glVertex2i(100,300);
 glVertex2i(400,300);
 glVertex2i(600,150);
 glVertex2i(400,100);
 glEnd();
 glFlush(); // send all output to the display
}
 // ****************** main function ********************
void main(int argc, char** argv)
{
glutInit(&argc, argv); // initialise the toolkit
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // set display mode
glutInitWindowSize(800,600); // set window size
glutInitWindowPosition(100,100); // set window position on your screen
glutCreateWindow(“OpenGL Window”); // Open the screen window with this name
glutDisplayFunc(myDisplay); // register redraw function
myInit();
glutMainLoop(); // go into a perpetual loop

          
Comments: