Search the Blog

Tuesday, November 24, 2015

Scenery - Java OpenGL Graphics Programming

In this post we are going to learn about the Java OpenGL Graphics Programming or Java OGL Programming. Like C++ OpenGL API Library are also used in Java programming. According to Wikipedia - Java OpenGL (JOGL) is a wrapper library that allows OpenGL to be used in the Java programming language.

Opengl programming in java is compare to C++ is little bit tricky but no hard as you might think. C/ C++ are considered tougher than java, yeah they truly are. In this post we are going to learn Java OpenGL Graphics Programming. For that First we need to understand our requirements.


Tools installed in your computer - 
  • Java JDK with proper path setup - Download from Oracle.
  • Java Binding for OpenGL - Downlaod it here.
  • IDE like Eclipse with OGL configured (Optional).
For learning Opengl programming in java you must have above tool properly configured. Since Eclipse is most preferred for Working in Java you might like to use it or go for other IDE. You must have the JDK configured and also the check Java OpenGL properly configured. Two folder jar and lib are most important, descriptions are given below. 

jar/ - contains all of the Java bytecode (.class files) for JOGL grouped into .JAR files.
lib/ - contains the native libraries (.so for Linux / OS X, .dll for Windows) for your platform.

About Scenery Opengl programming in java

First we need to know about what we are going to program here. We will program a simple scenery in Java Opengl. The scenery will contain the sun, sky, mountain, tree, road, cars and flag post. You can view the image below.
opengl programming in java

OpenGL in java give you power for graphics programming in java. You can make powerful Java OpenGL Graphics Programming with the use of API. 

First Step :  Create Package

First create a package name it sceneryjogl. Define the class in the package as well. 

package sceneryjogl

public class sceneryjogl{

Initialize the basic codes

Each of the Java Graphics program we will have some basic code that are required to get stated with. First you need to extend the class to proper Applet. Call the init functions and the graphics component functions as well.

Import the Java Packages

Note As you start coding you need to import java AWT and Applet and other packages, import them. Most important don't forget to import the OGL packages. Here is all the imports -

import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;
import java.applet.*;

Extend the  Package Class

Here we will extend the main class to JApplet to our program. This help access the necessary files for graphical user interface. Also define the init function and call the paint.

public class sceneryjogl extends JApplet{

public static void main (String [] args){

public void init () {  

public void paintComponent (Graphics g) {
super.paintComponent (g);

Next Move is to fill the code. Yeah! Call the Jframe, the container give it title and other attributes to it. Initialize the component and add it to the container. "Edi Haryanto | 8011171 | Absen : 28" can be changed as you want the text to appear. The Program will exit on closing the window.

public static void main (String [] args){ 
JFrame frame= new JFrame ();
frame.setTitle("Edi Haryanto | 8011171 | Absen : 28");
JApplet applet= new sceneryjogl ();
public void init () {  
JPanel panel4 = new Panel2D ();

Now we have to draw the objects. First choose the color you want to add and then fill the object with proper coordinates. Below is the code for green bushes, place the code in paintComponent. Rest of the code can be download with full source code.

//Gambar Tanaman
g.fillOval(0, 500, 30,30);
g.fillOval(25, 500, 30,30);
g.fillOval(50, 500, 30,30);
g.fillOval(15, 480, 30,30);
g.fillOval(32, 480, 30,30);
g.fillOval(90, 500, 30,30);
g.fillOval(115, 500, 30,30);
g.fillOval(140, 500, 30,30);
g.fillOval(105, 480, 30,30);
g.fillOval(122, 480, 30,30);
g.fillOval(180, 500, 30,30);
g.fillOval(205, 500, 30,30);
g.fillOval(230, 500, 30,30);
g.fillOval(195, 480, 30,30);
g.fillOval(212, 480, 30,30);
g.fillOval(270, 500, 30,30);
g.fillOval(295, 500, 30,30);
g.fillOval(320, 500, 30,30);
g.fillOval(285, 480, 30,30);
g.fillOval(302, 480, 30,30);
g.fillOval(510, 500, 30,30);
g.fillOval(535, 500, 30,30);
g.fillOval(560, 500, 30,30);
g.fillOval(525, 480, 30,30);
g.fillOval(542, 480, 30,30);
g.fillOval(600, 500, 30,30);
g.fillOval(625, 500, 30,30);
g.fillOval(650, 500, 30,30);
g.fillOval(615, 480, 30,30);
g.fillOval(632, 480, 30,30);
g.fillOval(690, 500, 30,30);
g.fillOval(715, 500, 30,30);
g.fillOval(740, 500, 30,30);
g.fillOval(705, 480, 30,30);
g.fillOval(722, 480, 30,30);
g.fillOval(780, 500, 30,30);
g.fillOval(805, 500, 30,30);
g.fillOval(830, 500, 30,30);
g.fillOval(795, 480, 30,30);
g.fillOval(812, 480, 30,30);
g.fillOval(870, 500, 30,30);
g.fillOval(895, 500, 30,30);
g.fillOval(920, 500, 30,30);
g.fillOval(885, 480, 30,30);
g.fillOval(902, 480, 30,30);
g.fillOval(960, 500, 30,30);
g.fillOval(985, 500, 30,30);
g.fillOval(1010, 500, 30,30);
g.fillOval(975, 480, 30,30);
g.fillOval(992, 480, 30,30); 

Similarly other objected can be painted using the paint. Download the whole source code for this Java OpenGL Graphics Programming and share you views. If you have any doubt don't hesitate to put your comment and ask the same. Keep learning!

Download the Source file -  Name it as java file and run on your computer.


Thursday, October 8, 2015

A Guide to OpenGL Programming in C#

Most of us didn't try for the OpenGL Programming in C# but it is one of the key area in graphics programming. In this post I will take you to the tour of OpenGL and C# programming.

OpenGL C# Example with Source Code

Solar System is simple and base for all our OpenGL programming and so do we have for OpenGL and C#. The 3D solar system implementation with OpenGL and C#. This is created by programmer name - Vasily Tserekh who had made it simple because it's only meant for educational purposes. It contains the sun, the planets, our moon, the planet’s orbit and some stars. It is programmed in Microsoft Visual Studio, utilizing the TAO namespace and the .NET Framework with Shadowengine. 

Download the OpenGL C# Source code and read more about the Program and it's implementation.

Wednesday, September 23, 2015

Video Demo for implementation of OpenGL Minesweeper

We have tried to figured out many classical implementation through the knowledge of OpenGL and Computer graphics. We have done so many opengl games programs and toady we are going to see another one.

In the previous OpenGL Minesweeper program there are many flaws which cannot be seen in this new program. This OpenGL Minesweeper projects have so many different features that make it worth doing. It. 

Some of the Features of OpenGL Minesweeper - 

  1. Large area of the board.
  2. Number are more clearly visible within the boards.
  3. Different colors being used in the program.
  4. Easy Navigation with the 4 up, down, left, right navigation key.
  5. Game is more colorful version of OpenGL Minesweeper.
Now you have seen this wonderful program and know about some of it's feature. It is better you do in your own way. It would be an idea for you 6th sem vtu student to implement such a great idea for your mini project. 

Watch the Demo below for OpenGL Minesweeper - 


Wednesday, September 9, 2015

VTU CG Lab Projects Report for Clock Programs

Many of the VTU 6th sem students doing mini projects in computer graphics, are looking for CG Lab Projects Report. Though it is difficult to give all the CG Lab Projects Report for all the projects. When ever the source code or the report is available to us, we share with you. 
In most of the cases we try to give the source code and report free but when we have to create the new report or code we have to invest the time. Since we are investing our valuable time so we are charging little amount for CG Lab Projects Report from you.  

Any one looking for CG Lab Projects Report Contact 8147656011 or email at, for just at Rs 500.

We have posted the CG Lab Projects on Clock and we are giving you the Report and the PPT for this. The report contains 11 chapters including the essentials snapshots. Download the Project report and power point presentation for the Clock program.

Below is some content for the Clock CG Lab Projects Report.

               This project has been designed such that it works on the windows platform. The project can be designed using different languages and better graphical interfaces. The following features can be incorporated.
ü  A simple monthly calendar can be displayed along with the clock.
ü  A simple digital timer can be implemented.
ü  Better graphical features like options for the user to change the clock’s color and shape of the clock.
ü  A different style for the digits on the clock, for example, Roman Numbers.


Note  - This Report and PPT is submitted by DHRUVA  M (1AY10CS017) of ACHARAYA INSTITUTE OF TECHNOLOGY. Thanks for this!
Kindly submit the Reports and PPT and even Source Code with you to help other students.

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.