SlideShare a Scribd company logo
1 of 12
Assignment
Drawing of Ghana National Flag in C++ by using OpenGL
Submitted by
Name : SH Rajøn
Batch : 1410
Student of Department of Computer Science and Engineering 0f IUBAT
IUBAT- International University of Business Agriculture and Technology
Date : 25/07/2018
Figure: Ghana National Flag
In this flag there are five primitives are used. Three of them is Quad,one is
triangle.
Assignment’s Description:
This Computer Graphics Assignments as mentioned above draw Flag of Ghana.
As we can see in the Assignments output image above. In this Assignment, there is
no user interaction as well as the Assignment is static one. A basic OpenGL
program has included header files, global variable declaration, draw function, init
function and main function. This program has only these basic functions, since it
not required having anything else. Just draw the primitives to give a propershape
of flag.
Drawing Function for Geometrical Primitives:
For drawing this flag, we need only five geometrical primitives, three of them is
quad,one is triangle and another one in polygon. All objects in this Assignment is
included in draw function. As we can see the flag has four part of different color.
We have use the glBegin(GL_QUADS) to draw the quad shapes, and
glBegin(GL_TRIANGLES) is use to draw the triangle.
First Primitives (1stQuad):
Here is the graph for first primitive of that flag
Codefor this primitive:
glColor3f(0.698, 0.133, 0.133);
glBegin(GL_QUADS);
glVertex2d(30.0,15.0);
glVertex2d(30.0,5.0);
glVertex2d(-30.0,5.0);
glVertex2d(-30.0,15.0);
glEnd();
glFlush();
SecondPrimitive (2nd Quad):
Here is the graph for Second primitive of the flag
Codefor this primitive:
glColor3f(1.000, 0.843, 0.000);
glBegin(GL_QUADS);
glVertex2d(30.0,5.0);
glVertex2d(30.0,-5.0);
glVertex2d(-30.0,-5.0);
glVertex2d(-30.0,5.0);
glEnd();
glFlush();
Third Primitive (3rd
Quad):
Here is the graph for Third primitive of the flag
Codefor this primitive:
glColor3f((-30.0,5.0);
glBegin(GL_QUADS);
glVertex2d(30.0,-5.0);
glVertex2d(30.0,-15.0);
glVertex2d(-30.0,-15.0);
glVertex2d(-30.0,-5.0);
glEnd();
glFlush();
Fourth Primitive (1st Triangle):
Here is the graph for fourth primitive of the flag
Codefor this primitive:
glColor3f(0,0,0);
// Draw a triangle:
glBegin(GL_TRIANGLES);
// Lower left vertex
glVertex2f(-6.0f, 1.5f);
// Lower right vertex
glVertex2f( 6.0f, 1.5f);
// Upper vertex
glVertex2f(-0.0f, -1.0f);
glEnd();
glBegin(GL_TRIANGLES);
// Lower left vertex
glVertex2f(0.5f, -0.0f);
// Lower right vertex
glVertex2f( -3.5f, -5.0f);
// Upper vertex
glVertex2f(- 0.0f, 5.0f);
glEnd();
glBegin(GL_TRIANGLES);
// Lower left vertex
glVertex2f(3.0f, -5.0f);
// Lower right vertex
glVertex2f( -0.0f, 5.0f);
// Upper vertex
glVertex2f(- 1.0f, -0.5f);
glEnd();
glFlush();
Code:
//Name : SH Rajøn
//ID : 1410
//Assignment Name : Flag of Ghana
#include<windows.h>
#include<GL/glut.h>
void flag()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.698, 0.133, 0.133);
glBegin(GL_QUADS);
glVertex2d(30.0,15.0);
glVertex2d(30.0,5.0);
glVertex2d(-30.0,5.0);
glVertex2d(-30.0,15.0);
glEnd();
glFlush();
glColor3f(1.000, 0.843, 0.000);
glBegin(GL_QUADS);
glVertex2d(30.0,5.0);
glVertex2d(30.0,-5.0);
glVertex2d(-30.0,-5.0);
glVertex2d(-30.0,5.0);
glEnd();
glFlush();
glColor3f(0.180, 0.545, 0.341);
glBegin(GL_QUADS);
glVertex2d(30.0,-5.0);
glVertex2d(30.0,-15.0);
glVertex2d(-30.0,-15.0);
glVertex2d(-30.0,-5.0);
glEnd();
glFlush();
glColor3f(0,0,0);
// Draw a triangle:
glBegin(GL_TRIANGLES);
// Lower left vertex
glVertex2f(-6.0f, 1.5f);
// Lower right vertex
glVertex2f( 6.0f, 1.5f);
// Upper vertex
glVertex2f(-0.0f, -1.0f);
glEnd();
glBegin(GL_TRIANGLES);
// Lower left vertex
glVertex2f(0.5f, -0.0f);
// Lower right vertex
glVertex2f( -3.5f, -5.0f);
// Upper vertex
glVertex2f(- 0.0f, 5.0f);
glEnd();
glBegin(GL_TRIANGLES);
// Lower left vertex
glVertex2f(3.0f, -5.0f);
// Lower right vertex
glVertex2f( -0.0f, 5.0f);
// Upper vertex
glVertex2f(- 1.0f, -0.5f);
glEnd();
glFlush();
}
void Initialize()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glClearColor(.96,0.87,0.70,0.0);
glOrtho(-40, 40, -20, 20, -20, 20);
}
int main(int Argc, char** Argv)
{
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(1170,620);
glutInitWindowPosition(50,50);
glutCreateWindow("Flag of Yemen");
Initialize();
glutDisplayFunc(flag);
glutMainLoop();
return 0;
}

More Related Content

What's hot

What's hot (8)

Mini Project final report on " LEAKY BUCKET ALGORITHM "
Mini Project final report on " LEAKY BUCKET ALGORITHM "Mini Project final report on " LEAKY BUCKET ALGORITHM "
Mini Project final report on " LEAKY BUCKET ALGORITHM "
 
OpenGL Introduction
OpenGL IntroductionOpenGL Introduction
OpenGL Introduction
 
Cracking into Doom (1993) WAD Files
Cracking into Doom (1993) WAD FilesCracking into Doom (1993) WAD Files
Cracking into Doom (1993) WAD Files
 
DSC GCOE, Nagpur intro session
DSC GCOE, Nagpur intro sessionDSC GCOE, Nagpur intro session
DSC GCOE, Nagpur intro session
 
Computer Graphics - Lecture 03 - Virtual Cameras and the Transformation Pipeline
Computer Graphics - Lecture 03 - Virtual Cameras and the Transformation PipelineComputer Graphics - Lecture 03 - Virtual Cameras and the Transformation Pipeline
Computer Graphics - Lecture 03 - Virtual Cameras and the Transformation Pipeline
 
Matrix representation of graph
Matrix representation of graphMatrix representation of graph
Matrix representation of graph
 
Computer Graphics Project on Sinking Ship using OpenGL
Computer Graphics Project on Sinking Ship using OpenGLComputer Graphics Project on Sinking Ship using OpenGL
Computer Graphics Project on Sinking Ship using OpenGL
 
Opengl presentation
Opengl presentationOpengl presentation
Opengl presentation
 

Similar to Ghana National Flag

square.cpp Open
 square.cpp Open square.cpp Open
square.cpp Open
MikeEly930
 
Intro to Computer Graphics.ppt
Intro to Computer Graphics.pptIntro to Computer Graphics.ppt
Intro to Computer Graphics.ppt
adil104135
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
amitsarda3
 
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdfimplement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
forladies
 

Similar to Ghana National Flag (20)

Togo National Flag
Togo National FlagTogo National Flag
Togo National Flag
 
Lab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer GraphicsLab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer Graphics
 
Introduction to graphics programming in c
Introduction to graphics programming in cIntroduction to graphics programming in c
Introduction to graphics programming in c
 
Computer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab reportComputer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab report
 
square.cpp Open
 square.cpp Open square.cpp Open
square.cpp Open
 
opengl.ppt
opengl.pptopengl.ppt
opengl.ppt
 
Intro to Computer Graphics.ppt
Intro to Computer Graphics.pptIntro to Computer Graphics.ppt
Intro to Computer Graphics.ppt
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
05-Debug.pdf
05-Debug.pdf05-Debug.pdf
05-Debug.pdf
 
openGL basics for sample program (1).ppt
openGL basics for sample program (1).pptopenGL basics for sample program (1).ppt
openGL basics for sample program (1).ppt
 
openGL basics for sample program.ppt
openGL basics for sample program.pptopenGL basics for sample program.ppt
openGL basics for sample program.ppt
 
Drawing Figures
Drawing FiguresDrawing Figures
Drawing Figures
 
Computer graphics practical(jainam)
Computer graphics practical(jainam)Computer graphics practical(jainam)
Computer graphics practical(jainam)
 
CGLabLec6.pptx
CGLabLec6.pptxCGLabLec6.pptx
CGLabLec6.pptx
 
IGraph a tool to analyze your network
IGraph a tool to analyze your networkIGraph a tool to analyze your network
IGraph a tool to analyze your network
 
Bai 1
Bai 1Bai 1
Bai 1
 
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdfimplement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
 
01.Opengl_intro-2.ppt
01.Opengl_intro-2.ppt01.Opengl_intro-2.ppt
01.Opengl_intro-2.ppt
 
OpenGL
OpenGLOpenGL
OpenGL
 
Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGL
 

More from SH Rajøn (7)

CD/DVD Drive Error Cause Detection and Solution
CD/DVD Drive Error Cause Detection and SolutionCD/DVD Drive Error Cause Detection and Solution
CD/DVD Drive Error Cause Detection and Solution
 
Movie Rating Site [for presentation]
Movie Rating Site [for presentation]Movie Rating Site [for presentation]
Movie Rating Site [for presentation]
 
Random Access Memory [for presentation]
Random Access Memory [for presentation]Random Access Memory [for presentation]
Random Access Memory [for presentation]
 
Airline Management System [for presentation]
Airline Management System [for presentation]Airline Management System [for presentation]
Airline Management System [for presentation]
 
Airline management system
Airline management systemAirline management system
Airline management system
 
Airline ticket reservation system
Airline ticket reservation systemAirline ticket reservation system
Airline ticket reservation system
 
Random Access Memory ( RAM)
Random Access Memory ( RAM)Random Access Memory ( RAM)
Random Access Memory ( RAM)
 

Recently uploaded

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Recently uploaded (20)

%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 

Ghana National Flag