[go: up one dir, main page]

0% found this document useful (0 votes)
62 views5 pages

Lab-2 Task

Download as txt, pdf, or txt
Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1/ 5

#include <GL/gl.

h>
#include <GL/glut.h>

#include <conio.h>
void display(void)
{
/* clear all pixels */
glClear (GL_COLOR_BUFFER_BIT);
/* draw white polygon (rectangle) with corners at
* (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
*/

/* Ma'am, i create this with my own color choice */

// Here First star code With Left line Draw code


glColor3f (200.0, 0.0, 0.0);
glBegin(GL_LINES);
glVertex3f (0.00, 0.56, 0.0);
glVertex3f (0.34, 0.56, 0.0);
glEnd();

glColor3f (200.0, 0.0, 0.0);


glBegin(GL_POLYGON);
glVertex3f (0.56, 0.56, 0.0);
glVertex3f (0.48, 0.53, 0.0);
glVertex3f (0.48, 0.59, 0.0);
glEnd();

glColor3f (200.0, 0.0, 0.0);


glBegin(GL_POLYGON);
glVertex3f (0.48, 0.53, 0.0);
glVertex3f (0.48, 0.59, 0.0);
glVertex3f (0.42, 0.59, 0.0);
glVertex3f (0.42, 0.53, 0.0);
glEnd();

glColor3f (200.0, 0.0, 0.0);


glBegin(GL_POLYGON);
glVertex3f (0.48, 0.59, 0.0);
glVertex3f (0.42, 0.59, 0.0);
glVertex3f (0.45, 0.67, 0.0);
glEnd();

glColor3f (200.0, 0.0, 0.0);


glBegin(GL_POLYGON);
glVertex3f (0.42, 0.53, 0.0);
glVertex3f (0.42, 0.59, 0.0);
glVertex3f (0.34, 0.56, 0.0);
glEnd();

glColor3f (200, 0.0, 0.0);


glBegin(GL_POLYGON);
glVertex3f (0.42, 0.53, 0.0);
glVertex3f (0.48, 0.53, 0.0);
glVertex3f (0.45, 0.45, 0.0);
glEnd();

// End First star code here

// Here Second star code With Left line Draw code


glColor3f (0.0, 180.0, 180.0);
glBegin(GL_LINES);
glVertex3f (0.56, 0.78, 0.0);
glVertex3f (0.56, 1.00, 0.0);
glEnd();

glColor3f (0.0, 180.0, 180.0);


glBegin(GL_POLYGON);
glVertex3f (0.56, 0.56, 0.0);
glVertex3f (0.53, 0.64, 0.0);
glVertex3f (0.59, 0.64, 0.0);
glEnd();

glColor3f (0.0, 180.0, 180.0);


glBegin(GL_POLYGON);
glVertex3f (0.53, 0.64, 0.0);
glVertex3f (0.59, 0.64, 0.0);
glVertex3f (0.59, 0.70, 0.0);
glVertex3f (0.53, 0.70, 0.0);
glEnd();

glColor3f (0.0, 180.0, 180.0);


glBegin(GL_POLYGON);
glVertex3f (0.59, 0.64, 0.0);
glVertex3f (0.59, 0.70, 0.0);
glVertex3f (0.67, 0.67, 0.0);
glEnd();

glColor3f (0.0, 180.0, 180.0);


glBegin(GL_POLYGON);
glVertex3f (0.53, 0.70, 0.0);
glVertex3f (0.59, 0.70, 0.0);
glVertex3f (0.56, 0.78, 0.0);
glEnd();

glColor3f (0.0, 180.0, 180.0);


glBegin(GL_POLYGON);
glVertex3f (0.53, 0.64, 0.0);
glVertex3f (0.53, 0.70, 0.0);
glVertex3f (0.45, 0.67, 0.0);
glEnd();

// End Second star code here

// Here Third star code With Left line Draw code

glColor3f (150.0, 150.0, .0);


glBegin(GL_LINES);
glVertex3f (0.78, 0.56, 0.0);
glVertex3f (1.00, 0.56, 0.0);
glEnd();
glColor3f (150.0, 150.0, 0.0);
glBegin(GL_POLYGON);
glVertex3f (0.67, 0.45, 0.0);
glVertex3f (0.64, 0.53, 0.0);
glVertex3f (0.70, 0.53, 0.0);
glEnd();

glColor3f (150.0, 150.0, 0.0);


glBegin(GL_POLYGON);
glVertex3f (0.64, 0.53, 0.0);
glVertex3f (0.70, 0.53, 0.0);
glVertex3f (0.70, 0.59, 0.0);
glVertex3f (0.64, 0.59, 0.0);
glEnd();

glColor3f (150.0, 150.0, 0.0);


glBegin(GL_POLYGON);
glVertex3f (0.64, 0.59, 0.0);
glVertex3f (0.70, 0.59, 0.0);
glVertex3f (0.67, 0.67, 0.0);
glEnd();

glColor3f (150.0, 150.0, 0.0);


glBegin(GL_POLYGON);
glVertex3f (0.64, 0.53, 0.0);
glVertex3f (0.64, 0.59, 0.0);
glVertex3f (0.56, 0.56, 0.0);
glEnd();

glColor3f (150.0, 150.0, 0.0);


glBegin(GL_POLYGON);
glVertex3f (0.70, 0.53, 0.0);
glVertex3f (0.70, 0.59, 0.0);
glVertex3f (0.78, 0.56, 0.0);
glEnd();

// End Third Star code Here

// Here Fourth star code With Left line Draw code

glColor3f (160.0, 0.0, 160.0);


glBegin(GL_LINES);
glVertex3f (0.56, 0.34, 0.0);
glVertex3f (0.56, 0.00, 0.0);
glEnd();

glColor3f (160.0, 0.0, 160.0);


glBegin(GL_POLYGON);
glVertex3f (0.45, 0.45, 0.0);
glVertex3f (0.53, 0.42, 0.0);
glVertex3f (0.53, 0.48, 0.0);
glEnd();
glColor3f (160.0, 0.0, 160.0);
glBegin(GL_POLYGON);
glVertex3f (0.53, 0.42, 0.0);
glVertex3f (0.59, 0.42, 0.0);
glVertex3f (0.59, 0.48, 0.0);
glVertex3f (0.53, 0.48, 0.0);
glEnd();

glColor3f (160.0, 0.0, 160.0);


glBegin(GL_POLYGON);
glVertex3f (0.53, 0.48, 0.0);
glVertex3f (0.59, 0.48, 0.0);
glVertex3f (0.56, 0.56, 0.0);
glEnd();

glColor3f (160.0, 0.0, 160.0);


glBegin(GL_POLYGON);
glVertex3f (0.59, 0.42, 0.0);
glVertex3f (0.67, 0.45, 0.0);
glVertex3f (0.59, 0.48, 0.0);
glEnd();

glColor3f (160.0, 0.0, 160.0);


glBegin(GL_POLYGON);
glVertex3f (0.53, 0.42, 0.0);
glVertex3f (0.56, 0.34, 0.0);
glVertex3f (0.59, 0.42, 0.0);

glEnd();

// End Fourth Star code Here

glFlush ();

}
void init (void)
{
/* select clearing (background) color */
glClearColor (0.0, 0.0, 0.0, 0.0);
/* initialize viewing values */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
/*
* Declare initial window size, position, and display mode
* (single buffer and RGBA). Open window with "hello"
* in its title bar. Call initialization routines.
* Register callback function to display graphics.
* Enter main loop and process events.
*/
int main(int argc, char** argv)
{

glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (700, 700);
glutInitWindowPosition (300, 15);
glutCreateWindow ("Iftekhar Uddin 181-15-11313 J");
init ();
glutDisplayFunc(display);
glutMainLoop();

return 0; /* ISO C requires main to return int. */


}

You might also like