Search Projects

Saturday, December 24, 2016

Fighter Jet CG Programs in C

There are many 2D program in our blog, today we are presenting Fighter Jet CG Programs in C. This cg opengl game look like video game. The game have a Fighter jet which moves in all direction and also fires bullets. User have control over the movement of jet and bullet.

Fighter Jet CG Programs in C


In this program the Fighter Jet is drawn with the help of simple line code using GL_LINE_STRIP and GL_LINE_LOOP. The Jet also have shield. The activation also is control by user with keyboard function. 

If the shield flag is turn on, drawshield() function is called. This will then activate shield. The shield is not shaped like cg opengl circle but some what similar to it. With sine and cosine functions and GL_LINE_LOOP it get close to circle. You can find cg opengl tutorial on circle in our blog. 

After Jet and Shield, next is bullet. In the Fighter Jet CG Programs in C GL_POINTS is used with for loop function to draw the bullet points. The entry flag set the entry point for bullet firing, allocate the bullet when to fire. The allocBullet function check if bullet is in use.

User Interaction Fighter Jet CG Programs in C

This cg Opengl program have keyboard interaction. Both alpha keys and navigation keys are allocated to the keyboard functions. 
ESC : Quit
S and s :
C and c : Show and Hide Cursor (More functionality is added by functions)
z and Z : Add 20 point in direction of motion.
f and F : Enter game mode.
l : Exit game mode
P and p : Pause the game
Q and q and Space : Fire bullet from fighter jet.

This cg opengl program have many keyboard functions. There are 4 keyboard functions  - key, keyup, special, specialup. 

Key function have the user interaction indicated above in the post. While in the Key function s, S setup the shield flag to one the same is set to keyup. Since different set of windows are created, it set the platform of shield and it's activation.  

The special and specialup function have up, left and right which give the thrust, left and right movement. 

Try downloading this program and execute. Give your feedback about it in comment.

Sunday, December 18, 2016

OpenGL Glut Create Menu Example

OpenGL Glut program can be mainly divided into 4 Parts. First part includes initialization with library and necessary files. Second Part include other necessary functions and third is the display functions which draw the object on screen. Final part is the main function. In this OpenGL Glut Create Menu Example, we will see these 4 parts separately.

This program will teach us how to add menu and submenu in opengl program. The menu can be created with click of right mouse button. In the OpenGL Glut Create Menu Example program menu and submenu in opengl id demonstration. The menu create have different types of structures whose color can be changed with selection of color in respective submenu.




FUNCTION USED

In this program we have three function - main, display, menu and createmenu used. We all know what main function do, so no tension about it. The function - display, menu and createmenu need to be understand.

The display function have all the code abou the objects that is going to show on the screen. The various object drawn are - Teaport, Torus, Sphere and Cone. Each of these objects are coded separately and placed in the display function. A global variable declared which helps in determination color and the object combination. Hence we are able to screen the objects in different colors as per the user selection in submenu. All these has been done with nested if else statement.

The createmenu Function lets us create menu and submenu. In main function first createmenu() is called. In the createmenu function glutCreateMenu(menu) is called for creation of each of the menu. Each selected menu entry passes the value passed for the callback.

Next is to add menu.The glutAddMenuEntry() function  will add the menu which passed to createmenu() along with the name of menu. For each menu a separate glutAddMenuEntry() function is required along with the different integer callback. If name of menu is same there will be now error while if integer callback is same, compiler error will show up.

Then we have glutAddSubMenu() function which create the submenu inside a menu item. It works in same way as glutAddMenuEntry() function. Different color is set in each of menu as submenu so that object in different color can be displayed.

OBJECTS USED IN THE PROGRAM

These are following functions used in the program along with the opengl functions.

  1. Teapot - glutSolidTeapot(r);
  2. Sphere - glutWireSphere(r, w, h);
  3. Torus - glutWireTorus(r, f, w, h);
  4. Cone - glutWireCone(r, f, w, h);
The color of each object used - Red,White,Yellow. Green and Blue attached with the menu in this OpenGL Glut Create Menu Example. Hence there are 5*4=20 objects can be drawn in display.

To trigger the menu and popup the menu, it can be attached to right or left mouse button with glutAttachMenu(). 

To attach it to right mouse button  - glutAttachMenu(GLUT_RIGHT_BUTTON);
To attach it to left mouse button - glutAttachMenu(GLUT_LEFT_BUTTON);


In our program we have used the GLUT_RIGHT_BUTTON so menu will appear on right click of mouse.

Download the source code.

Friday, December 2, 2016

2D game using OpenGL and Glut

You have seen a OpenGL Glut 3D Game by Mr. Jonathan Gonzalez Cortes of  FACULTAT D'INFORMÀTICA DE BARCELONA UPC - FIB Barcelona School of Informatics. He named the game as Ballenger. The game has so many features where user can play the game effectively. It was the single player game. Same Computer Engineer developed the 2D game using OpenGL and Glut. He named it as Tiny Quest. This game is more interesting and have more fun while playing. It will give you the feel of mario game, which you all might have played.

This game is also developed in C++ using OpenGL, with the use of the GLUT library. In the game custom GLSL shaders also used in the code. While the level design is original, the tilesets and sprites used are modified versions of the ones found in Sword of Mana.

Features of 2D game using OpenGL and Glut

There are two levels in the game.
There is animated players, enemies and the FX in the game.
The depth simulation is being done via Layered level design.
Smart challenging AI.
In the game you will find the meaningful audiovisual feedback.
There is Dynamic GUI.

View the video 2D game using OpenGL and Glut demo

 

If you have gone through the video, you might have get all the views about the game. Do share your observation as well as comments via our comment box below.

Download the source code, binaries and executable from the website.

Thursday, December 1, 2016

OpenGL Glut 3D Game

A Game - Ballenger OpenGL Glut 3D Game developed by Mr. Jonathan Gonzalez Cortes, Computer Science Engineer. The game name by him Ballenger developed during his academic at FACULTAT D'INFORMÀTICA DE BARCELONA UPC - FIB Barcelona School of Informatics. This OpenGL Glut 3D Game is single player skill game, with so many features.


OpenGL Glut 3D Game - Features 

  • The game have a wide range of area for exploring in 3D
  • There are about 16 Challengers in the game.
  • There are 5 keys in the game that can be collected by exploring in the game.
  • There are several check points which make the game more interesting and playable.
  • It used the original assets and design arts never used before.
  • One-way shortcuts to avoid undoing the paths taken
View the video demo of this OpenGL Glut 3D Game.


This interesting OpenGL Glut 3D Game is developed in C++ using the opengl.There is proper use of the GLUT library and custom GLSL shaders in this program. The world map and the models which were used in the game were designed in Photoshop and Blender. There are some problem in the game. The terrains and other parts get little litle strains. In some computer with less graphics the game may struck. The game may go slow in some computers as well.

You can download the source code and the executables from the website. Do comment about the game in the comment sections. Share your feedback as well.