Search Projects

Sunday, August 31, 2014

Phases of Moon - VTU 6th sem mini project

We have seen many OpenGL Projects for vtu 6th sem mini project, but this is quite as simple as of others. Today we are going to talk about the project related to moon. There are many phase of moon , it is define as - The lunar phase or phase of the moon is the shape of the illuminated portion of the Moon as seen by an observer, usually on Earth

phase of moon vtu mini project

Today for VTU 6th sem mini project in the computer graphics lab we are going to have the phases of moon. In the this program we showcase the camera orbits a lit moon to simulate the phases of the moon. This program used the OOP used in C++, the use of the classes and the methods.

First we create a class for the moon.  In the class moon we create an OpenGL display list, which is  created with create(), and the draw() method calls it.We have use the sphere to feature the moon, which has radius 1 centered at the origin. Another class which we have created is orbiter, this is an object that flies on a circle of a certain radius on the xz plane. The radius to it is supplied at the time construction. Since there is one one moon so it must be static, hence we declared the moon to be static variable. 

How we are showing the phase? It's easy by using the lightning property of OpenGL. We have used the GL_LIGHT0 to focus the light on the moon, making the all phase visible as it go. Pointing in the direction of vertex 1,1,1 it's is possible to show all the moon phases.

Future Addition to phase of moon vtu mini project

  • Add the name of the phases of moon as it's go.
  • Add interaction to the project.
  • In this, adding the zoom option is wonderful thought.

Sunday, August 24, 2014

How to Draw Different Types of Triangles in OpenGL

To draw a triangle in opengl  we just need to use simple primitive functions. There are many ways you can draw but using primitive function is one of easy method. In this post we are going to draw few triangles using the different primitive functions defined in OpenGL graphics Library.

One of the blog reader requested to have the code for Triangle. Hence to help and all other reader in this post we going to see many types of triangles. We are going to have full source code with explanation. So get the code and spread the knowledge, don't forget to tell other and share the post.

Draw First Type of Triangle in OpenGL

Here we are going to use the GL_TRINAGLES and glVertex() to draw our triangle in a simple manner. Her we have drawn two triangles -red and white, both as right angled triangle. You can change the vertexes to make others varities of Triangle. 

#include "glut.h"

void Display(void)
 {
 glClear(GL_COLOR_BUFFER_BIT);

 glBegin(GL_TRIANGLES);
  glColor3f(1,1,1);
  glVertex3f(0,0,0);
  glVertex3f(-1,0,0);
  glVertex3f(0,1,0);

  glColor3f(1,0,0);
  glVertex3f(0,0,0);
  glVertex3f(1,0,0);
  glVertex3f(0,-1,0);
 glEnd();

 glFlush();
 }

int main(void)
 {
 glutCreateWindow("MY Triangle");
 glutDisplayFunc(Display);
 glutMainLoop();
 return 0;
 }

Draw Striped Triangle in OpenGL C++

You may have heard about the Strip triangles, now we are going to see it. Just as in above are using glVertex() but this time GL_TRIANGLE_STRIP.

#include "glut.h"

void Display(void)
 {
 glClear(GL_COLOR_BUFFER_BIT);

 glBegin(GL_TRIANGLE_STRIP);
 glVertex3f(0,0,0);
 glVertex3f(1,0,0);
 glVertex3f(0,1,0);
 glVertex3f(0.9,0.9,0);
 glVertex3f(1,-1,0);
 glEnd();

 glFlush();
 }

int main(void)
 {
 glutCreateWindow("MY STRIP TRIANGLE");
 glutDisplayFunc(Display);
 glutMainLoop();
 return 0;
 }

Draw Triangle Fan in OpenGL

Now its time to Draw a Triangle Fan. You might have seen this as used in our Nuclear Power Plant Project in OpenGL, where the turbine have it.

#include "glut.h"

void Display(void)
 {
 glClear(GL_COLOR_BUFFER_BIT);

 glBegin(GL_TRIANGLE_STRIP);
 glVertex3f(0,0,0);
 glVertex3f(1,0,0);
 glVertex3f(0,1,0);
 glVertex3f(-1,0,0);
 glVertex3f(-1,-1,0);
 glEnd();

 glFlush();
 }

int main(void)
 {
 glutCreateWindow("Triangle Fans");
 glutDisplayFunc(Display);
 glutMainLoop();
 return 0;
 }

Tuesday, August 19, 2014

Noof : the external - opengl projects using visual c++

Today we are going to see Opengl projects using visual c++ that is quite interesting. This computer graphics project is something different from all other we have mentioned in this blog. You can see the pic below.


You must have not noted much about it viewing the image and determined it as simple project to submit for your VTU but it is not. It is one of the good project that has a lot of potential to show, how much you know about the OpenGL. As in the image you see nothing that attract, but there more in this than simple solar system project. When you execute this projects in using visual c++ (MS visual studio) you will got to see the real potential. 


Noof the external is the name of this opengl project. We have coded opengl projects using visual c++. On execution the leafs will move, turn and twist from different part of screen. It likes the rocket when leaves the cloud in the sky. You got see like same as it fill the entire screen with cloud of leaves twisted motion. As the petals of flowers twist to form a beautiful object we are going to see same here. We have paired object shapes that form foam of cloud in the screen. Watch the video at vine to see how it actually works. 

This opengl projects using visual c++ has used many things like using the colors vectors, motion vectors to control how the object form and have it's motion with it. The use of glShadeModel and glBlendFunc is also crucial. 

Wednesday, August 6, 2014

Tetris game projects in Opengl computer graphics

There are many computer graphics games projects in the opengl. We have discussed many of them like ludo, snake xenia, mancala etc. Here are we have a new game projects in computer graphics. You may remember the childhood video game where we play the game of tetris. Here we are going ti implements the game of tetris in Opengl computer graphics.

The project is some what complex but not long. It has fewer lines of code. Logic is to have the function that define a random change of blocks or the shapes when key is press . With key press the angles are changes and hence the shape of the blocks are determines in each key press. The change is also selective and act on chosen shapes, means a shape of of long line may have four block in horizontal and vertices and no other shapes. The color is also randomly selected while for shapes changes it remain same. 

Tetris game projects in Opengl computer graphics


Keyboard Interaction -

Up arrow key - changes the shape in positive direction of angle
Down arrow key -  changes the shape in negative direction of angle
Right arrow key - move the blocks to right
Left arrow key - move the blocks to right
Esc - Closed the program

The important feature that this project lac is the disappearance of blocks as the line get filled. While timers and scores can be added in future to this projects along with sounds in the Opengl computer graphics.

I hope this computer graphics games projects would helped you in CG course or other ways. Download the source code Tetris game projects in Opengl computer graphics and comments for any query, problem, suggestion or alteration.