Search Projects

Tuesday, July 15, 2014

OpenGL Project on Binary Tree

In C/C++ Binary Tree is one of the tree data structure in which each node has at most two children. These data structure has two child -right node (right child) and left node(left child). In a binary tree, the degree of each node can be at most two. You can read more about binary tree on wikipedia.

As we have different operation with binary tree in c/c++, same operations can be done as demo in this projects. This OpenGL Project on Binary Tree, the elements are taken as input from the user which then form the Binary Tree according to the rule. See the image below which show how the a binary tree formed with sample input.

OpenGL Project on Binary Tree

How the Project works? It's the big question for all. It used the structures with 3 nodes input -left, right and parent. The structure also has data as the element for that very node. The input is taken from the user using the primary cin function in the console. The input is recorded and it is arranged in the order of the rules of binary tree. One condition put in this project to determine the termination is that last input should be 0.

The OpenGL Project on Binary Tree

Download the Project

Wednesday, July 2, 2014

New graphics editor Opengl mini Projects

We came across with graphics editor Opengl mini Projects in our earlier post. In this post we are going to see new graphics editor project. It is similar to in work with the previous project but an advance version. It is also a replica of MS paint provides many options that are not in the previous projects like - Triangle, Square, Circle, Parallelepiped, Pencil, Ellipse etc. These extra option like Triangle standalone draw the figure so you need not to work on the line most of the time, one click figure, thus saving the time.

New graphics editor Opengl mini Projects


Before we go on to the functionality let's clear about the few feature of this Opengl mini Projects.

1. The whole application has three user interface block - first the figures selectors (tools), second draw panel, third and last the color panel for selecting the specific color.

2. There are range of figures or tools to choose - LINE, TRIANGLE, SQUARE, ERASER, CIRCLE, EXIT, CCTRIANGLE, CCSQUARE, CYLINDER, BULLET, PARALLELEPIPED, SPRAY, MESH, TEXT, PENCIL, BRUSH, ELLIPSE, CLEAR. All these tools are having functionality as per their name.

3. The TEXT tool allows to have text typed rather than drawing it. There is no option for font family and sizes.

4. The color option having many shades to choose for the drawing. The only thing that lack is the color eavesdropping.

5. In the Draw panel we can see different shapes that can be drawn there by moving the mouse with the tools selected in appropriated color.

6. The last Exit button in the tools allows to close the program.

This Opengl mini Projects uses the important glut functions, that I am going to discuss here. The function are - glutMotionFunc() and glutPassiveMotionFunc(). These functions provides for the motion detection of mouse.It is similar like we detect the mouse click with glutMouseFunc(). The glutMotionFunc() detects the active motion (mouse is moved and button is pressed) while the glutPassiveMotionFunc() detects passive motion (mouse is moved but button is not pressed).

The signatures for the GLUT functions are as follows: 

void glutMotionFunc(void (*func) (int x,int y)); 
void glutPassiveMotionFunc(void (*func) (int x, int y)); 

Parameters: func - the function that will be responsible for the respective type of motion. 

The parameters for the motion processing function are the (x,y) coordinates of the mouse relatively to the upper left corner of the window's client area.

The Mouse click and motion are the major functionality of the project while we have figure predefined with primitive calls. Color selection and display uses the array. Keyboard function for entering the text when text tool is selected. There are whole bunch of things there. 

How you like this project? Download the source code of the project and do comments about it in the comment box.

Advance graphics editor Opengl mini Projects Source Code -