0% found this document useful (0 votes)
1 views

abdure

Uploaded by

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

abdure

Uploaded by

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

#include <GL/glut.

h>
#include <math.h>

void disp();
void drawStripe(float r, float g, float b, float yMin, float yMax) {
glColor3f(r, g, b); // set color for the stripe
glBegin(GL_QUADS); // draw a rectangle for the stripe
glVertex2f(-0.5f, yMin); // bottom left
glVertex2f(1.0f, yMin); // bottom right
glVertex2f(1.0f, yMax); // top right
glVertex2f(-0.5f, yMax); // top left
glEnd();

glFlush();
}

void drawCircle(float x, float y, float radius, float r, float g, float b) {


glColor3f(r, g, b); // set color
glBegin(GL_TRIANGLE_FAN); // use triangle fan to draw a filled circle
glVertex2f(x, y); // center of the circle
for (int i = 0; i <= 100; i++) {
float angle = 2.0f * M_PI * i / 100.0f;
float dx = radius * cos(angle);
float dy = radius * sin(angle);
glVertex2f(x + dx, y + dy);
glClearColor(0,0,1,0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0f,0.0f,0.0f);
glLineWidth(2.0);
glBegin(GL_LINE_LOOP);
glVertex2f(0,0);
glVertex2f(-0.5,0.5);
glVertex2f(0.5,0.5);
glVertex2f(-0.5,0.2);
glVertex2f(0.2,0.7);

}
glEnd();

void disp() {
glClearColor(0, 0, 0, 0); // black background
glClear(GL_COLOR_BUFFER_BIT); // clear the color
glColor3f(0, 0, 1); // set color for the stripe
glBegin(GL_QUADS); // draw a rectangle for the stripe
glVertex2f(-0.5,1);
glVertex2f(-0.6,1);
glVertex2f(-0.6,-2);
glVertex2f(-0.5,-2);
glEnd();
// Draw the stripes of the Ethiopian flag
drawStripe(0, 0.5f, 0, 0.13f,o.8f); // green stripe
drawStripe(1, 0.8f, 0, -0.13f ,0.13f); // yellow stripe
drawStripe(1, 0, 0, -0.8f, -0.13f); // red stripe

// Draw the blue circle in the center for the emblem


drawCircle(0.0f, 0.0f, 0.3f, 0.0f, 0.0f, 1.0f); // blue circle

// Draw the yellow star inside the blue circle


// drawStar(0.0f, 0.0f, 0.2f, 0.1f, 5); // yellow star

glFlush(); // flush the drawing commands


}

int main(int argc, char *argv[]) {


glutInit(&argc, argv);
glutInitWindowSize(940, 980);
glutInitWindowPosition(10, 10);
glutCreateWindow("Ethiopian Flag"); // window title
glutDisplayFunc(disp);
glutMainLoop();
return 0;
}

You might also like