This projects uses Java's OpenGL Library to render low level graphics in java programs.
It illustrates two scenes, one of an old residential area in Saudi Arabia, and another futuristic one. The scenes are built using 3D and 2D primitive shapes of OpenGL. For example, cubes were used to construct buildings of different designs, clouds, benches, solar panels and bins. Cylinders were used to build satellites and water tanks. And textures were used to simulate shopfronts and the drawings on walls. And other primitive shapes, like a sphere for the masjid dome, quads for cars and icosahedrons for plants and rocks.
OpenGL is a cross-language, cross-platform application programming interface (API) that's used for rendering 2D and 3D vector graphics. This project uses Java OpenGL, which is a wrapper library that allows OpenGL to be used by the Java programming language.
A link to a video demo will be added soon!
The project is well encapsulated, every logical object is written in a separate function that draws it in order to simplify the integration of objects in a scene. This is especially important when dealing with small details that need to be rendered in precise places. The encapsulated functions follow this style:
// The market is one logical building, therfore this function draws it
public static void market(GL gl, GLUT glut){...}
// So is the cilnic
public static void clinic(GL gl, GLUT glut){...}
// The park is one logical *area*, therefore it is also drawn in one peice of code
public static void park(GL gl, GLUT glut){...}
// The car is one logical object, and also one that we wanted to copy many times,
// therfore its header takes in different colors (RGB).
public static void drawCar(GL gl, GLUT glut, float r, float g, float b){...}
This is how objects in the display() [main function] look like:
// Market
gl.glPushMatrix();
gl.glTranslatef(3f, 0f, 5f);
gl.glScalef(0.6f, 0.6f, 0.6f);
market(gl, glut);
gl.glPopMatrix();
- Launch NetBeans.
- Go to Tools > Plugins.
- Go to the Downloads tab, then click on Add Plugins.
- Select all the plugins you downloaded from OpenGL, then click Open.
- Check all the plugins except the GLSL editor module (It does not work in NetBeans 7.1 and above, it causes errors if you try to install it).
- Click the Install button.
To run a project, simply open it in NetBeans (File > Open project), then choose Run > Run project (shortcut F6).