Search Projects

Tuesday, May 30, 2017

Flag of South Africa

We have a great computer graphics OpenGL Projects on Flag Hoisting. Following that we have developed another graphics program based on Flag. The projects will draw the flag of South Africa.


Projects Description : 

This Computer Graphics projects as mentioned above draw Flag of South Africa. As you can see in the projects output image above, we have flag with flagpole. In this projects there is no user interaction as well as the project is static one. This projects only draw the flag and flagpole nothing else, there is no motion or animation in it.

A basic OpenGL program have included header files, global variable declaration, draw function, init function and main function. This program have only these basic functions, since it not required to have anything else.just draw the primitives to give a proper shape of flag. 

Draw Function

All objects in this project is included in draw function. As you can see the flag have three strips of different color. Also left part have triangular strips, along with a middle rectangular strip. There is also a long with small width rectangle for pole and last but not least the three rectangular flag base. All these strips are drawn with the help of polygon. We have use the glBegin(GL_POLYGON) and glBegin(GL_TRIANGLES) to draw the rectangular (polygon) and triangular objects respectively. 

One of the important thing and the main part is to understand the coordinate system. So, before draw have a sketch of the flag and point out the proper coordinate.  Unlike other complex projects, this projects is simple hence assign the proper coordinate is not a tough task.

glColor3f(1,0,0);
glBegin(GL_POLYGON);
glVertex2f(-15,30);
glVertex2f(-15,23.34);
glVertex2f(15,23.34);
glVertex2f(15,30);
glEnd();

The above mentioned is code snippet of this projects which draw the upper rectangular portion of flag. Similarly with proper coordinate, color section and use of glBegin(GL_POLYGON); (glBegin(GL_TRIANGLES); for triangular) the whole projects can be completed.

What Can be added to this projects

There are many things that can be added to it including the user interaction or waving of flag. many other idea we might find in our previous flag projects. As as creative students you may come up with new idea and implement to make this projects far better.

One of the good part of this projects is that it can be used as framework for drawing other flags.

Video Demo



No comments:

Post a Comment