Search Projects

Sunday, March 23, 2014

How to Draw Circle in OpenGL

In the OpenGL Computer graphics there major problem in drawing circle. In this post we are going to study How to Draw Circle in OpenGL. There is no primitive functions like of lines, points, triangles and other polygons for circle, hence drawing a circle need some new method/function from our side. we are going to learn that today.

There are many methods of Drawing circle in OpenGL, we going to discuss one by one each of them. 

First Method - using the indefinite points 

This method used the no of of point to draw a circle. The problem with this method is you need more precession as we use the sine and cosine function with the value of pie as 3.14159, So little error may in the round circle. Put the following code in a simple display function and run the program for your circle. See the Image it's output - 

glBegin(GL_POINTS);
 for(int i=0;i<1000;++i)
  {
  glVertex3f(cos(2*3.14159*i/1000.0),sin(2*3.14159*i/1000.0),0);
  }
 glEnd();

draw circle opengl - using points

Second Method - using the lines 

As Like above program circles can be created using the small sets of lines.We used the bunch of lines, which are closed together to go round forming a circle. For drawing circle in opengl, this method also used the simple sine and cosine maths functions, but we have not used pie instead go for degree for angles.

typedef struct
{
float x;
float y;
}CIRCLE;

CIRCLE circle;

void createcircle (int k, int r, int h) {
    glBegin(GL_LINES);
    for (int i = 0; i < 180; i++)
    {
    circle.x = r * cos(i) - h;
    circle.y = r * sin(i) + k;
    glVertex3f(circle.x + k,circle.y - h,0);
    
    circle.x = r * cos(i + 0.1) - h;
    circle.y = r * sin(i + 0.1) + k;
    glVertex3f(circle.x + k,circle.y - h,0);
    }
    glEnd();
}

If you know about the structures in C then fine you understand the typedef else we have more object oriented approach making use of classes for C++. Same program above in classes.

class circle{
public : float x,y,rot;

public:
void createcircle (int k, int r, int h);

};
void circle::createcircle (int k, int r, int h) {
  glBegin(GL_LINES);
    for (int i = 0; i < 180; i++)
    {
    x = r * cos(i) - h;
    y = r * sin(i) + k;
    glVertex3f(x + k,y - h,0);
    
    x = r * cos(i + 0.1) - h;
    y = r * sin(i + 0.1) + k;
    glVertex3f(x + k,y - h,0);
    }
    glEnd();
}


Friday, March 21, 2014

Tower of Hanoi Computer Graphics Project

Solving Puzzles all of us like to play in our leisure. To day on the same note I am presenting the Tower of Hanoi Computer Graphics Project using OpenGL. This very simple puzzles based on the no of discs and the towers. The objects, rule were discussed in the previous Tower of Hanoi OpenGL project, in which used CONE and TORUS. Similarly in this Computer Graphics Project we are using these same primitive 3d objects.


This has following feature -
  • It has better shaped disc, look more realistic.
  • The options in this Computer graphics Project in C allows to set different backgrounds.
  • The Tower of Hanoi Project has more interaction than previous one as it's allows to have step by step solving the problem. First at the beginning you need to input no of disc. Right Click to Get the options menu - Click on Solve to start solving. Continues to till the problem automatically get solved. 

Also Try These Projects -


Future scope - It can allow to changes the disc from one to other by human's choice and not though some algorithm. Also put levels with no of disc as the base. As the level increases the disc count also need to get increment. We may start level 1 or 0 with 3 discs.

I think your gone like this projects as well, put your comment and let what more need to be added in this. Also help by contributing your projects either modified or new, your project your name.

Monday, March 17, 2014

First Come First Serve Algorithm

First Come First Serve Algorithm is OS based Computer graphics Project. This Project as name suggest demonstrate the working of First Come First Serve Algorithm or FCFS Algorithm.

About First Come First Serve Algorithm

The first come first serve (fcfs) algorithm is one of the scheduling algorithms for Process in Operating System. It has the following algorithm - 
  • In FCFS the process is executed on first come, first serve basis.
  • This algorithm is easy to learn, understand and implement.
  • The performance of this scheduling algorithm is poor as average wait time is high.
Terminology

Arrival Time : Time of Arrival for Process.
Execute Time :  Time taken for execution. 
Waiting Time : Time to wait for process it’s execution.
Average Wait Time : Total waiting time/No of Processes.

Instruction to execute Program

To execute this program - run the program with CTR+F5(in windows). First page will have instruction written on it. Press E or e to run the computer graphics project with default values. To run with your own values, give the inputs. Like in our case - press 4 first to give no of process. Then input 2, 3, 6, 7 for arrival time. Next input the execution time 2, 4, 5, 5. 

We have wait times for each as in the table  -

ProcessWait TimeExecution Time
102
214
325
465
Average Wait time = 0+1+2+6/4=9/4=2.25

You easily understand and demonstrate the concept in OS - First Come First Serve Algorithm. With learning from this project do your own the other scheduling algorithms projects on OpenGL. Download the free source and put your comments with respect to this projects.

Note: If You enhanced modify this project plz share your code with, it is a humble request as I single can't help student reach that much of projects. Your Code Will be publish as your with your name only! Thanks !

Saturday, March 15, 2014

Encryption Decryption Computer Graphics Projects

As you get to know about the projects in this post via title itself. The Encryption Decryption Computer Graphics Projects in OpenGL demonstrate the how encryption is done. This projects is quite simple and easy to understand as well as design and code. 



What is Encryption?

The encryption is the process of encoding messages(data) with some secret key for secure transmission over the network. This helps the Unauthorized access to critical messages. The encrypted message is called as Cipher.

What is Decryption?

The process of getting the plain text message from the encrypted messages is decryption. It also use some key to decrypt the secret message.

This computer graphics projects in c++ with source code showcase the process of Encryption and Decryption. A message is passed by sender which is added with some key. This new message with secret key became the cipher. The Cipher travel via network and reaches receiver. At this point receiver decrypt the message to plain text by removing the secret key.

This OpenGL Computer graphics projects has used simple design with two computer for sender and receiver. A route at each of the part. Transmission is shown with movement of boxes. It is easy to code the text with some function. In most of the cases Primitive shapes are used for drawing and just logic is the movement of text message. Logic includes how the message add with key to became cipher and how cipher return with removal of key as plain text.

Download Free Source code - computer graphics mini projects using opengl with source code free download

Thursday, March 6, 2014

Hawkeye Computer Graphics Projects in C++

We have seen so many Computer Graphics Projects in C++ which consist of games while in them we have not include any related to cricket. Today i am going to show you a clean clear computer graphics projects on cricket. This projects on cricket is Hawkeye - the technology to show the movement of ball in the games.

About Hawkeye?

A Hawkeye is a complex computer system which is used in the sports like Cricket, Tennis, Soccer etc. This is a system which used the different 6 (or 7) high performing camera installed in the stadium. The footage taken from these cameras combined to create a three-dimensional representation of the trajectory of the ball. This helps in taking some of the vital decision. In the Cricket this technology used for Umpire Decision Review System. If You Knows little about cricket, have interest in it you got to know about the UDRS. Let not make more on it rather focus on our Hawkeye Computer Graphics Projects in C++.

Features of Hawkeye Computer Graphics Projects in C++

In this Project there are many things included in it. Lets have a look what is inside the projects -

  • This opengl projects is very simple and easy to code.
  • As the whole projects made with simple primitive objects like square, rectangles and other polygons it is not that hard to explain to other and understand yourself.
  • Comments in the project can easily helps you what that piece of code do.
  • Bitmap fonts used for this Computer Graphics Projects in C++ to write the instructions.

Hawkeye Computer Graphics Projects in C++ Works

As per as functionality is concern it is easy and simple. Only mouse interaction has been used. Left and the right mouse button is assigned the task for moving and pitching the ball. As the program runs, press left mouse button to move the ball, press the right mouse button to the position where it need to pitch. The ball will take the direction and if possible may hit the stumps if it came in the path of ball.

Future Improvement of Hawkeye Computer Graphics Projects -

  1. Add auto movement and pitching
  2. Add sounds as it pitch.
  3. Ball Should have different pace and angle of movement that need to be added.
  4. It should have the replay of the action.
  5. Good front end to get included in the project. 
Download free source code for Hawkeye Computer Graphics Projects in C++