0% found this document useful (0 votes)
48 views1 page

"Stdafx.h" : #Include #Include Void

This document contains C++ code for drawing a 2D polygon using OpenGL. It defines functions for drawing, initializing the display, and the main program. The draw function sets the background color, clears the buffer, sets the drawing color, and draws the polygon by specifying vertex points. It ends the polygon and flushes the buffer. The initialize function sets the projection as orthographic. The main function initializes GLUT, sets up the window, calls initialize, sets the draw function, and enters the main loop.
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)
48 views1 page

"Stdafx.h" : #Include #Include Void

This document contains C++ code for drawing a 2D polygon using OpenGL. It defines functions for drawing, initializing the display, and the main program. The draw function sets the background color, clears the buffer, sets the drawing color, and draws the polygon by specifying vertex points. It ends the polygon and flushes the buffer. The initialize function sets the projection as orthographic. The main function initializes GLUT, sets up the window, calls initialize, sets the draw function, and enters the main loop.
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/ 1

#include "stdafx.

h"
#include<GL/glut.h>

void Draw() {
glClearColor (0.0,0.0,0.0,0.0);
glClear (GL_COLOR_BUFFER_BIT);
glColor3f(1.0,5.0,1.0);
glBegin(GL_POLYGON);

glVertex3f(0.25,0.45,0.0);
glVertex3f(0.75,0.75,0.0);

glVertex3f(0.75,0.75,0.0);
glVertex3f(0.75,0.25,0.0);

glVertex3f(0.55,0.55,0.0);
glVertex3f(0.25,0.75,0.0);

glVertex3f(0.25,0.25,0.0);
glVertex3f(0.25,0.75,0.0);

glVertex3f(0.15,0.15,0.0);
glVertex3f(0.25,0.75,0.0);

glVertex3f(0.95,0.95,0.0);
glVertex3f(0.55,0.55,0.0);

glVertex3f(0.15,0.15,0.0);
glVertex3f(0.25,0.75,0.0);

glVertex3f(0.95,0.95,0.0);
glVertex3f(0.55,0.55,0.0);

glEnd();
glFlush();

void Initialize() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(1.0,1.0,1.0,1.0,-1.1,1.0);
}

int main(int iArgc, char** cppArgv) {


glutInit(&iArgc, cppArgv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(250,250);
glutInitWindowPosition(350,350);
glutCreateWindow("Mhd akbar Ramadhan_QuiZ");
Initialize();
glutDisplayFunc(Draw);
glutMainLoop();
return 0;
}

You might also like