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



Friday, May 19, 2017

A Movable Car

For those of you, who want to have a very simple projects here we came a new but simple project. A Movable Car, unlike our car racing projects this is very simple projects, which include  only just a car. So, you will able to learn also how to draw a car from this project. We have also added a simple user interaction which allow user to move the car in all four directions with navigation keys.


A movable Car is very simple OpenGL C program, in which as show in figure we display a Car, which can be move in up,down, left and right with corresponding arrow key. The Car is drawn in red color to match it with Red Ferrari, and there black shield and windows. 

This program in opengl c/c++ is good for beginners, who want to learn opengl from scratch as it has tons of comments for almost all the lines, which highlights the use of each of the function or callbacks used. The function that we have used to draw the car, itself have all the comments which show the parts which are drawing whether it's roof, windows, bumper or skirt. In the comment the left or right side is also mentioned, which let you understand if it is of left or right part.

We have used only keyboard interaction for the user to move the car in the direction they want. In this opengl c programm we have used the function key for the first time. In almost all the use of function key was nil, we have used it here. You might be thinking it to be hard, but it is as normal as we implement return key or esc key for any action. Below is glimpse of how we have used  the function key.

if(key == GLUT_KEY_F2 )
{
//logic goes here
}

if(key == GLUT_KEY_F1 )
{
//logic goes here

Now you all understand how to use the function key. For all special functions visit opengl.org glutSpecialFunc documents.

Keyboard Interaction of Program

Below is description of what action car will perform when user press the mentioned keys.

Up - Car move forward
Down  - Allow to reverse the car
Right - Move in right direction
Left -  Move toward left direction
F1 -  Car turns right backwards
F2 - Car turns left backwards

Future Scope

For those of you, who want to develop something new by taking some code snippet. This project is for you. Download the free source code and develop some unique program like car racing game, car parking game, car simulator etc.

Source code

You can have free access to the source code o A Movable car opengl c++ program. Kindly download it by visiting the Download link. Share your experience, and creativity with the code.