Monday, August 31, 2015

Bubble Shooter Game Computer Graphics Programs in C

We have shown many Computer Graphics Programs in C but this is special one. This is the Bubble Shooter game written with the use of  OpenGL. You might have played Bubble Shooter game online and would have liked it very much. Do you want to have the bubble shooter games online free play? If yes we have the game out here. This not only free to play and kill time but you can submit this as your mini project in your college.

Bubble Shooter Game Online - Computer Graphics Programs in C

The Bubble Shooter game has two version which is totally written in C. This Computer Graphics Programs in C have exactly the same as you have Bubble Shooter game online. You might want to develop this game and learn to make it more interesting and innovative. Do you want to submit a game project as your cg lab project then I would like to suggest this. It is not only interesting but will let you learn almost all the concept of OpenGL while knowing about how it works.

Features of the Computer Graphics Programs in C

Most important feature of these Computer Graphics Programs in C is that there are two version of Bubble Shooter Game, each with different codes. These codes are written in C language and programmed, debugged, tested in the integrated development environment (IDE) MS Visual Studio.

First version of Bubble Shooter game is simpler one. In this the player have to use both Mouse and Keyword for playing the game. Click the left mouse button to and give direction and press the spacebar to release the bubble. Player can change the screen color or background with options appear via the right click of mouse.

The second version of Bubble Shooter game is better than the first one and it utilized the navigation keys. Player have to use the both left and right navigation key to give direction, for releasing the bubble it's again the spacebar. I feel the second one is better but both these Computer Graphics Programs in C pointing to a good goal. It's your wish to choose either or both for presenting the mini project.

Download the Executable of the both versions Computer Graphics Programs in C.

Read more...

Advance Traffic Signal C Source Code Projects

OpenGL from CGI has many feature that make it one of the best graphics API. VTU had one of the subject dedicated to the OpenGL Computer graphics, the lab for it as well. The CGV lab projects is written in c/c++. Earlier in the blog we posted many C Source Code Projects including the cgv projects for 6th sem cse about traffic signal. Today in this post we are going to show your Advance Traffic Signal project.

Features of the Projects

This C Source Code Projects have many of the good features. We are listing the features below -

  1. Traffic light with three signals.
  2. House with tree and lake around it.
  3. Cloud and Sun in the Sky in the day while moon in the night.
  4. There are few vehicles that cross the road with signal installed.
  5. There is user interaction to change the signal color.
  6. User can choose between day and night.
  7. The airplane and comet in the sky can be sought by user.

User Interaction

As all the good projects have a great UI, this C Source Code Projects also have it. There is following UI that help make the project a better option for you to choose for the CGV lab projects. 

Mouse - 
  • RIGHT MOUSE BUTTON to display menu.
  • Choose from SubMenu - 1. Aeroplane 2. Comet
  • LEFT MOUSE BUTTON to quit the program
Keyboard - 

  • Press 'r' or 'R' to change the signal light to red.
  • Press 'g' or 'G' to change the signal light to green.
  • Press 'd' or 'D' to make it day.
  • Press 'n' or 'N' to make it night.
Download this C Source Code Projects in OpenGL.


Read more...

Tuesday, August 25, 2015

OpenGL ES Tutorial for Android - draw triangle in OpenGL ES

How to draw a triangle in Android OpenGL ES?

There are about billions of Android devices activated till date, and more will add to the list in coming days. These billions of devices have so many of games which uses the graphics to render the objects. These games use OpenGL API to show high performing graphics game.  These games are developed by designers, programmers, developers and others, but to begin this we need to start from a small step. Hence in this OpenGL ES Android tutorial we are going to learn how to draw a triangle in Android OpenGL ES.

Prerequisite

For this OpenGL ES Android tutorial you must know the OpenGL, basic Java, and about  Android Programming. Also your system should have the Android Studio (or Eclipse with ADT Plugin) and Android SDK installed. This Android game Development tutorial will use Android Studio.

Creating the new Project

1.       First Step in this OpenGL ES tutorial is to create a new project without any activity.
2.       Next we need to create 3 classes (3 separate java files) - “MainActivity.java” , “MainRenderer.java” and “MainSurfaceView.java”. These classes are essential for almost all OpenGL ES programming in Android. You can name them a Renderer, SurfaceView or whatever but it is good practice to do like this, it will help in understanding the files.

Main Activity

3.       In the MainActivity we are going to check if Android device support OpenGL ES with specific version. For this check out our previous OpenGL ES tutorial for Android.

MainSurfaceView

4.       Extend the MainSurfaceView with GLSurfaceView and create the constructor in the class. Also include all required imports. Following is the code snippet -

package in.ruks.openglobjects;
import android.content.Context;
import android.opengl.GLSurfaceView;
public class MainSurfaceView extends GLSurfaceView {
    public MainSurfaceView(Context context) {
        super(context);
    }
}

MainRenderer

5.       MainRenderer class will implement the GLSurfaceView.Renderer.  Call all the unimplemented methods in the class. Check the code below –

package in.ruks.openglobjects;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
public class MainRenderer implements GLSurfaceView.Renderer {
    @Override
    public void onSurfaceCreated(GL10 gl10, EGLConfig eglConfig) {
    }

    @Override
    public void onSurfaceChanged(GL10 gl10, int i, int i2) {
    }

    @Override
    public void onDrawFrame(GL10 gl10) {
    }
}

We are going to render our object here in this class and draw the object. 

Our Triangle Class

6.       Next Step is to create a new class, name  it “Triangle.java”.  This is the class where we are going to define vertices for our object (which is triangle). Here are going to define color for the vertices as well. We have to create buffer for each.
private FloatBuffer vertexBuffer;
    private float vertices[] = {
        0.0f , 0.5f,0.0f,
        -0.5f , -0.5f, 0.0f,
        0.0f , 0.5f, 0.0f
    };
    private float color[] = new float[]{ 0 .0f ,0.5f,0.0f,1.0f };  
           
First we have defined the buffer, which will contain the vertices. Next we have defined the vertices for each side of the triangle.



Final Thought

Reference

http://developer.android.com/reference/android/pm/ ConfigurationInfo.html
http://developer.android.com/guide/topics/graphics/opengl.html


Read more...

OpenGL Camera and Lightning Project

One of the best way to improve your skills is to go through the minutes part of the subject rather than the profile concepts. We need to learn the basic first and repeat it as much as possible. Keeping this in mind today we are going to see a new project which test your basic knowledge of OpenGL.

There are vast topics in OpenGL which you need to master. One of the basic level concept is about camera. It is important to understand the camera, it's position and views. Another basic concept is about the Lightning which co-exit with camera. In this project we will use these concept to develop the program.


Features of the Projects -

This project has many features which will show the use of Camera and Lightning in OpenGL. The object featured in the projects are -

  • Cube
  • Torus
  • Sphere
  • Car
These objects can have more than one color with option menu. The Lightning options in the menu can also make sure the different lightning conditions. 

Check the Code and Executable on this website.
Read more...

Friday, July 31, 2015

How to check if Android Device Supports OpenGL ES 2.0

OpenGL ES stands for OpenGL for Embedded Systems also called as GLES. It is subset of OpenGL Computer graphics API for rendering 2D and 3D computer graphics particularly focusing on Hardware Accelerated using GPU. It is used in embedded systems like Smartphones (iPhone, Android Phones), Tablets (iPad, Android Tablets), Video game Consoles (Xbox, Play Station) and PDA (Personal Digital Assistant). Due to it openness and cross platform support, it is quite popular as well as most used graphics API in Smartphone and Tablets.

In this post we are going to know programically if Android Device Supports OpenGL ES 2.0. This is tutorial for OpenGL ES Android Programming . To check if Android Device Supports OpenGL ES 2.0 or not we are going to use very simple code. Let’s get started with it.

Prerequisite

For this our OpenGL ES Android tutorial it is assumed that you basic level of Java and Android Programming. It is also assumed that you are familiar with OpenGL as well. We are going to need some software installed on your computer to begin with our OpenGL ES Android tutorial. We need the following tools –
  • Android Studio (or Eclipse with ADT Plugin)
  • Android SDK

Android Studio is official IDE for Android Development so here I will show the tutorial in it, but you are free to use Eclipse (But why?).

Creating the Project

11.  First Step is to create a new project in Android Studio. Open Android Studio and create a new project but don’t create any activity for this as we are not going to need. You should choose “Add No Activity”. If required for further programming you can create Activity then.

22. Next Step is to create a class “MainActivity.java” (Right click on your package name under java -> new ->class). In this activity class just create the “onCreate” method. In the method we will use the logic to identify OpenGL 2.0. In a condtion we will check the status of OpenGL ES2.0 and toast  the result. Check the code below.

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityManager activityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
        ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo() ;
Boolean supportes2 = (info.reqGlEsVersion>= 0x20000);
        Boolean supportes2 = (info.reqGlEsVersion>= 0x20000);
        if(supportes2){
            Toast.makeText(getApplicationContext(),"Your Device Support OpenGL es2",Toast.LENGTH_LONG).show();
        }
        else{
Toast.makeText(getApplicationContext(),"Your Device doesn’t  Support OpenGL ES2",Toast.LENGTH_LONG).show();
            Log.d("OpenGL ES2", "Your Device doesn't  Support ES2. ("+ info.reqGlEsVersion+")");
        }
    }

Explanation

First we created ActitivtyManager object to access or interact with the system services. Now we created ConfigurationInfo object and retrieve the hardware configuration of the device. This object will help us know the GLES version used.  Next we created the variable  supportes2. With reqGlEsVersion we checked the version from the condition we used and stored  result in our Boolean variable. We have used the condition with “0x20000” which represent the GLES version upper 16 bits for major version while lower 16 bits for minor version.

33.  Final Step is to run and check if Android Device Supports OpenGL ES 2.0. Go to Run menu and select “Run ‘app’” or use shortcut shift+f10. Check which toast is called.

Final Thought

Google added support for OpenGL ES 2.0 in Android 2.0 through NDK and Android 2.2 through Java. Today’s Modern Phone almost support the OpenGL ES 2.0 so if you wonder to check higher version like OpenGL ES 3.0 replace  0x20000 with 0x30000 in “Boolean supportes2 = (info.reqGlEsVersion>= 0x20000);” which is supported from Android 4.3.

Please comment below how you liked this tutorial. Give us feedback so we can improve on our OpenGL ES Android tutorial. Stay tune for more tutorials.

Reference



Read more...