0% found this document useful (0 votes)
41 views2 pages

#Include #Include #Include #Include Void

This document contains code for a computer graphics program that uses OpenGL. It includes header files for OpenGL and GLUT. It defines functions for initializing the window settings and display, including clearing the screen, drawing colored rectangles and a triangle. The main function initializes the GLUT toolkit, sets the window properties, registers the display function, and enters the main loop to redraw the graphics.

Uploaded by

AwwadJomaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views2 pages

#Include #Include #Include #Include Void

This document contains code for a computer graphics program that uses OpenGL. It includes header files for OpenGL and GLUT. It defines functions for initializing the window settings and display, including clearing the screen, drawing colored rectangles and a triangle. The main function initializes the GLUT toolkit, sets the window properties, registers the display function, and enters the main loop to redraw the graphics.

Uploaded by

AwwadJomaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include

#include
#include
#include

<windows.h> // use as needed for your system


<gl/gl.h>
<gl/glu.h>
<gl/glut.h>

void setWindow(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top)


{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(left,right,bottom,top);
}
void myInit(void)
{
glClearColor(0.0,0.0,0.0,0.0);
glPointSize(4.0);
setWindow(0.0,640.0,0.0,480.0);

void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT); // clear the screen
glColor3f(0.0,1.0,0.0);
glRecti(200,100,450,300);
glColor3f(1.0,0.0,0.0);
glRecti(300,100,350,170);
glColor3f(0.0,0.0,1.0);
glBegin(GL_TRIANGLES);
glVertex2f(200,300);
glVertex2f(450,300);
glVertex2f(325,400);
glEnd();
glFlush();
}

void main(int argc, char** argv)


{
glutInit(&argc, argv); // initialize the toolkit
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // set display mode
glutInitWindowSize(640,480); // set window size

glutInitWindowPosition(100, 150); // set window position on screen


glutCreateWindow("First CG Lab"); // open the screen window
glutDisplayFunc(myDisplay); // register redraw function
myInit();
glutMainLoop();
}

You might also like