Search Projects

Monday, March 30, 2020

Electromagnetic induction demo with opengl graphic program

Electromagnetic induction or magnetic induction or simply induction is process in which electric current or voltage is passed through a conductor when it is placed in postion around varying magnetic field. Induction also produce current when a conducting material constantly moves around a static magnetic field. The current run through conducting material due to electromagnetic force. Michael Faraday has been credited for discoverey of  Law of Induction in 1831. The laws is now called Faraday laws of Electromagnetic induction. We are going demo with help of computer graphics how Electromagnetic induction work. The graphic will be coded in c++ with opengl graphic library.


With help of opengl program computer graphics we are going to demo the Electromagnetic induction. 

Faraday laws of Electromagnetic induction.

Before we get into details of the program first you need to understand what Faraday laws of Electromagnetic induction is all about. This will help us in properly demo the Electromagnetic induction with opengl program graphically.

There are two faraday's law of electromagnetic induction as stated below - 
  1. First law : change in magnetic flux linked with a closed coil, an induced emfis  produced and current flows through the coil. This induced e.m.f. remains till the flux changes. 
  2. Second law : The induced emf in a coil is equal to the rate of change of flux linkage.
There are many things like equation, maxwell farady law, Lenz law, right thumb rule but we will not focus on them.

There are many application of  Electromagnetic induction including electrical components such as inductors and transformers, and devices such as electric motors and generators. The ATM swipe in pos also use the Electromagnetic induction.

Description of opengl program

Our opengl program demo Electromagnetic induction graphically. We are going to code the program with user interface. 

The opengl program will create two basic model one for static magnet another for rotating magnet. First a wireframe cylinder is needed which will act as conductor or coil. This coil then attached to spherical object which is bulb. A rectangular magnet is also designed. When magnet is place in coil the emf is produced and bulb glows as current runs in coil. Color of sphere is black when there is no current and for current same will change to yellow.

In another scenario we will rotate magnet and produce current. Rapid movement of magnet can be shown using pencils like cone with rectangular middle. 

User Interface

Following keyboard interface and functionity as given below is used in this opengl program - 

'S/s' key - start the program
'M/m' key - move the magnet
'T/t' key - toggle
'F/f' key - increase the flow
'Esc/e/E' key - to exit any time.

Email us @ for source code and reports.

Monday, January 14, 2019

The Classroom CG lab Programs VTU


OpenGL is used in the CG lab Programs VTU 6th SEM for learning the graphics. The aim of this blog is to give as much exposure to students so they can learn create and explore the new ideas of implementing the Computer graphics.

We have share many projects with free source code. We have also provided the free opengl tutorials in our blog. We have shre multiple programs snippets of c/c++ source code in OpenGL. There are many simple projects that can be used for large program with some library based program that can be complex in nature. With the same aim we have come up a program that act as the first part of our complex journey. We name the Program as  - "The Classroom".


The Classroom CG lab Programs for VTU 6th SEM student comprised of showing jouney of education when we all are child and start learning the basics. This program will show the graphical representation of the the classroom where a teacher try to teaches student "A for apple B for Ball ...".


CG lab Programs which  we have come up with have so many components or functions. These functions are basically code for small objects like roof, floor, blackboard tube light etc. Different parts of the classroom have different functions to create the objects.

We have created the lady teachers by using the different objects. Like the face we have used the circle to draw it. Similarly the hair we use the semi circle (created code for it). The other parts like nose we have use the lines and vertices with proper coordinates.

There are four kids which are facing towards the teachers has been rendered in this The Classroom CG lab Programs VTU 6th SEM. We have created two benches and each benches consist of two students. 

There is dark mode of the program where you can switch off the tubelight and whole class would be in dark.

User Interactions

n - to continues form start screen and proceed to next.
b- back to previous screen
r- restart the screen

Video Demo

Source Code

To get the source code write to with the project title.

Sunday, August 26, 2018

OpenGL Chess Board in C++ with Source Code

Chess is interesting game with 8X8 checker of black and white. Hence we are going to see a program in OpenGL that implement Chess Board in C++ with free Source Code.

This program implements with the three functions:

1. Init function - this initalise the opengl program.
2. Chess Boards - this calculate the chess and sqaure and draw the same in the screen.
3.  Main function - this is the must and common program for each and every oepngl program.

chessboard() this function is used for the calculation of the end point of the cordinates of the box to make and is also mainly responsible for calling the drawSquare()
It is also a display function which is called from the main function which is responsible for sending graphics to the display window.

The forming of boxes is made through iterating first of all from 1st row and making 1st column then 2nd and then till 8th column as a single chessbord contains 8 column.

The similiar above operation is repeated till all the 8 rows have been iterated making a total 64 boxes (8 rows and 8 column).

The finally the chessboard() function contains a opengl glFlush()  which process all opengl routine as quickly as possible means it flushes all the matter on the display window for the next display.

This similar to our earlier chess board opengl program.


        The program OpenGL Chess Board in C++ can be use in the chess board game as well as in making the floor of the house or any other structure.

Source Code : 

int c = 0;
void init()
// For displaying the window color
glClearColor(0, 1, 1, 0);
// Choosing the type of projection
// for setting the transformation which here is 2D
gluOrtho2D(0, 800, 0,600);

void drawSquare(GLint x1, GLint y1, GLint x2, GLint y2, GLint x3, GLint y3, GLint x4, GLint y4)
// if color is 0 then draw white box and change value of color = 1
if (c == 0)
glColor3f(1, 1, 1); // white color value is 1 1 1
c = 1;
// if color is 1 then draw black box and change value of color = 0
glColor3f(0, 0, 0); // black color value is 0 0 0
c = 0;

// Draw Square
glVertex2i(x1, y1);
glVertex2i(x2, y2);
glVertex2i(x3, y3);
glVertex2i(x4, y4);
void chessboard()
glClear(GL_COLOR_BUFFER_BIT); // Clear display window
GLint x, y;

for (x = 0; x <= 800; x += 100)
for (y = 0; y <= 600; y += 75)
drawSquare(x, y + 75, x + 100, y + 75, x + 100, y, x, y);
// Process all OpenGL routine s as quickly as possible

int main(int agrc, char ** argv)
// Initialize GLUT
glutInit(&agrc, argv);
// Set display mode
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
// Set top - left display window position.
glutInitWindowPosition(100, 100);
// Set display window width and height
glutInitWindowSize(800, 600);
// Create display window with the given title
glutCreateWindow("Chess Board using OpenGL in C++");
// Execute initialization procedure
// Send graphics to display window
// Display everything and wait.

Wednesday, May 9, 2018

AirPlane Game Computer Graphics Project

In our blog we have seen many projects that deals with gaming. Today we are introducing one of the most complex game which we called the "AirPlane Game". It is not similar to copter game in openGL we have seen earlier. It is more complex and used SOIL.

Objective :

The objective of the project is to built a game using opengl and c++, which use the airplane as tool of game. The Computer Graphics game Project use playing have to run the airplane through the scene avoiding the danger as well as keeping the fuel up. As the fuel goes down user game ends, same when you hit by incoming object.

Features : 

1. Splash Screen 
2. Options to Choose the plane
3. Option to choose the scence
4. Different menu as mentioned below.

A menu with screen with the following items: 

• Play 
• Settings 
• Instructions 
• Credits 
• High Scores 
• Exit 

The game use SOIL to load the image hence you have to first set the soil in your project. 

For source code and documents email to

Friday, April 6, 2018

OpenGL Code Traffic Signals

Presenting to you another OpenGL Code on Traffic Signals. We have already seen the Advance Traffic Signal OpenGL Program, now we will see another good program for same.

OpenGL Code Traffic Signals


The OpenGL Code  we presenting have many of the good features. Some of the features is listed below -

  1. Light Options - As in any traffic signal you will see the three lights - red, yellow and green. All the options has been implemented.
  2. Vehicles - To keep the OpenGL Code simple for all only three vehicles has been added. Though, if you like to add more do it, you are welcome.
  3. Lanes -  The right and left lane options is implemented in the program.
  4. User Interactions - Both mouse and keyboard interaction has been added to the OpenGL Code. All the user interactions has been listed in the post below.
  5. There is options to speed up the traffic is also in the code.
  6. Program has include the front page for introduction.

User Interactions

As mentioned earlier both mouse and keyboard user interaction has been added to this OpenGL Code. 
  • Keyboard Interactions
  1. Enter - From First Introduction screen to screen press Enter key at beginning.
  2. Help -  Press 'h'to get the help screen.
  3. Left to right movement - press 'l' to allow only left to right movement of traffic.
  4. Right to left movement - press 'r' to allow only right to left movement of traffic.
  5. Speed up - To speed up the traffic press 's'.
  • Mouse Interactions
  1. Left Mouse Button - This will stop the traffic as Red light gets on.
  2. Right Mouse Button (on hold) - Press right mouse button and keep on hold for yellow light. 
  3. Right Mouse Button (released) - After releasing the right mouse button the light changes from yellow to green and traffic moves.

Video Demo


You can download the OpenGL Code from the Google Drive link.