Created
March 23, 2017 15:50
-
-
Save ubongofaidas/09bff3d2fc03aa717f90404e86a4fe2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//THE FOOTBALL FIELD PROJECT | |
//All steps involves different primitives shapes that make the whole program | |
/*1.FIRST STEP | |
Include all specific libraries that can be used for graphic /image outputs here use (GL/freeglut.h) also remember there some primitives use mathematics to be executed here use( math.h).consider here below we declare,*/ | |
#include <freeglut.h> | |
#include <math.h> | |
/* 2.SECOD STEP | |
Declare the void draw function that is executed every frame of the program whatever primitives written in the body of draw will be run*/ | |
void Draw() | |
//Now begin to write primitives properties | |
{ | |
// The first primitive shape is the green yard | |
glClear(GL_COLOR_BUFFER_BIT); //Call color from memory | |
glColor3f(0.0, 1.0, 0.0);// Greencolor | |
glBegin(GL_QUAD_STRIP); | |
glVertex3f(0.1, 0.1, 0.0); | |
glVertex3f(0.1, 0.9, 0.0); | |
glVertex3f(0.9, 0.1, 0.0); //GreenYard Vertex | |
glVertex3f(0.9, 0.9, 0.0); | |
glEnd(); | |
glFlush(); | |
//The second shape is the middle line with white color | |
glBegin(GL_LINES); | |
glColor3f(1.0, 1.0, 1.0); | |
glVertex3f(0.5, 0.1, 0.0); //Mid Line ( Ground Divider ) | |
glVertex3f(0.5, 0.9, 0.0); | |
glEnd(); | |
glFlush(); | |
//The code for circle at the middle line white color | |
float x1,y1,x2,y2; | |
float angle; | |
double radius=0.1; | |
x1 = 0.5,y1=0.5; | |
glColor3f(1.0,1.0,1.0); | |
glBegin(GL_LINE_STRIP); | |
glVertex2f(x1,y1); | |
for (angle=0.0f;angle<360.0f;angle+=0.1) | |
{ | |
x2 = x1+sin(angle)*radius; | |
y2 = y1+cos(angle)*radius; | |
glVertex2f(x2,y2); | |
} | |
glEnd(); | |
// Left side of the Ground white colored line | |
glBegin(GL_LINES); | |
glColor3f(1.0,1.0, 1.0); | |
glVertex3f(0.25, 0.25, 0.0); // Goal keeper Front line | |
glVertex3f(0.25, 0.75, 0.0); | |
glEnd(); | |
glFlush(); | |
//goal keeper front circle white color | |
float m1,n1,m2,n2; | |
float theta; | |
double fradius=0.05; | |
m1 = 0.25,n1=0.5; | |
glColor3f(1.0,1.0,1.0); | |
glBegin(GL_LINE_STRIP); | |
glVertex2f(m1,n1); | |
for (theta=0.0f;theta<3.2f;theta+=0.1) | |
{ | |
m2 = m1+sin(theta)*fradius; | |
n2 = n1+cos(theta)*fradius; | |
glVertex2f(m2,n2); | |
} | |
glEnd(); | |
glBegin(GL_LINES); | |
glColor3f(1.0, 1.0, 1.0); | |
glVertex3f(0.1, 0.75, 0.0); //Goal Keeper left Line | |
glVertex3f(0.25, 0.75, 0.0); | |
glEnd(); | |
glFlush(); | |
glBegin(GL_LINES); | |
glColor3f(1.0, 1.0, 1.0); | |
glVertex3f(0.1, 0.25, 0.0); //Goal Keeper Right Line | |
glVertex3f(0.25, 0.25, 0.0); | |
glEnd(); | |
glFlush(); | |
glBegin(GL_QUAD_STRIP); | |
glColor3f(1, 1, 1); | |
glVertex3f(0.1, 0.35, 0.0); | |
glVertex3f(0.1, 0.65, 0.0); //Inner White Quad found at left | |
glVertex3f(0.17, 0.35, 0.0); | |
glVertex3f(0.17, 0.65, 0.0); | |
glEnd(); | |
glFlush(); | |
//point found infront of left quad | |
glPointSize(7); | |
glColor3f(0.0,0.0,.0); | |
glBegin(GL_POINTS); | |
glVertex2f(0.2,0.5); | |
glEnd(); | |
glutSwapBuffers(); | |
// Right Side of the Ground white color | |
glBegin(GL_LINES); | |
glColor3f(1.0, 1.0, 1.0); | |
glVertex3f(0.75, 0.25, 0.0); //Goal Keeper front line | |
glVertex3f(0.75, 0.75, 0.0); | |
glEnd(); | |
glFlush(); | |
//goal keeper front circle | |
float p1,q1,p2,q2; | |
float a; | |
double frradius=0.05; | |
p1 = 0.75,q1=0.5; | |
glColor3f(1.0,1.0,1.0); | |
glBegin(GL_LINE_STRIP); | |
glVertex2f(p1,q1); | |
for(a=0.0f ; a<3.2f ; a+=0.1) | |
{ | |
p2 = p1+-sin(a)*frradius; | |
q2 = q1+cos(a)*frradius; | |
glVertex2f(p2,q2); | |
} | |
glEnd(); | |
glBegin(GL_LINES); | |
glColor3f(1.0, 1.0, 1.0); | |
glVertex3f(0.75, 0.25, 0.0); //Goal Keeper Left Line | |
glVertex3f(0.9, 0.25, 0.0); | |
glEnd(); | |
glFlush(); | |
glBegin(GL_LINES); | |
glColor3f(1.0, 1.0, 1.0); | |
glVertex3f(0.75, 0.75, 0.0); //Goal Keeper ki Right wali line | |
glVertex3f(0.9, 0.75, 0.0); | |
glEnd(); | |
glFlush(); | |
//point infront of the right side quad | |
glPointSize(7); | |
glColor3f(0.0,0.0,0.0); | |
glBegin(GL_POINTS); | |
glVertex2f(0.8,0.5); | |
glEnd(); | |
glutSwapBuffers(); | |
glBegin(GL_QUAD_STRIP); | |
glColor3f(1, 1, 1); | |
glVertex3f(0.9, 0.35, 0.0); | |
glVertex3f(0.9, 0.65, 0.0); | |
glVertex3f(0.83, 0.35, 0.0); //Inner White Quad found at right side | |
glVertex3f(0.83, 0.65, 0.0); | |
glEnd(); | |
glFlush(); | |
} | |
//In this part we declare the background color as black coffee | |
void Initialize() | |
{ | |
glClearColor(0.30, 0.40, 0.12, 0.20); | |
glMatrixMode(GL_PROJECTION); | |
glLoadIdentity(); | |
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); | |
} | |
//This part represent the main function | |
int main(int iArgc, char** cppArgv) | |
{//Initialize the the GLUT Library and negotiating a session with window system during this process | |
glutInit(&iArgc, cppArgv); | |
//Set initialize display mode | |
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); | |
//The size of the window | |
glutInitWindowSize(700,600); | |
//the position of the window | |
glutInitWindowPosition(300, 100); | |
//this show the name of the program on the displayed window | |
glutCreateWindow("Football Field"); | |
Initialize(); | |
// | |
glutDisplayFunc(Draw); | |
glutMainLoop(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment