Setting Up Eclipse IDE and JIRR on Windows

Discussion about Irrlicht's Java wrapper
Post Reply
Serg Nechaeff
Posts: 162
Joined: Wed Nov 26, 2003 5:24 pm
Location: Europe

Setting Up Eclipse IDE and JIRR on Windows

Post by Serg Nechaeff »

Setting Up Eclipse IDE and JIRR on Windows

This is a short tutorial on how to start programming amazing 3d graphics in Java language using Irrlicht IDE. First of all, you have to:

Download necessary packages

Eclipse IDE (http://www.eclipse.org/downloads/) about ~100Mbs.
Jirr (https://sourceforge.net/projects/jirr/) about ~10Mbs.

Download jirr_bin and jirr packages. jirr_3rd_party is used to combine Swing and Irrlicht and you may need it later.

Setup Eclipse IDE

All you have to do is to unzip the archive you have downloaded to any folder. Unzip jirr_bin to any folder. Start Eclipse IDE Go to the folder you have unzipped the Eclipse package to and click 'eclipse.exe' file. If you experience any problems starting Eclipse, check out the eclipse web-site, read FAQs, ask people etc. Eclipse is very very popular and you will not spend much time looking for an answer.

Image

Create the project

Create the folder anywhere you like, name it for example: JirrTest Make a few subfolders:
src
classes
media
lib

Copy:

all DLL files from JIRR distribution package's bin folder to JirrTest root folder;
all files from JIRR distribution package's lib folder to JirrTest/lib folder;
all files from JIRR's media folder to JirrTest/media folder;
Now your new JirrTest folder should look like the one on the picture:

Image

Setup the project in Eclipse IDE

In Eclipse go to File->New->Project->Java Project

Image

Click Next

Image

Image

Click OK and the Finish

Image

Create Demo class

Go to File->New->Class:

Image

Copy and paste the following code (comes with the sources of Jirr in the examples folder):

Code: Select all

package com.leadercode;

import net.sf.jirr.*;

public class Demo {

	static {
		System.loadLibrary("irrlicht_wrap");
	}

	public static void main(String argv[]) {

		IrrlichtDevice device = Jirr.createDeviceJava(E_DRIVER_TYPE.EDT_OPENGL,
				640, 480, 16, false, false, false, null);
		System.out.println("idevice = " + device);
		String windowCaption = "Java@Hello World! - Irrlicht Engine Demo";
		device.setWindowCaption(windowCaption);
		IVideoDriver driver = device.getVideoDriver();
		ISceneManager smgr = device.getSceneManager();
		IGUIEnvironment guienv = device.getGUIEnvironment();

		String text = "Hello World! This is the Irrlicht Software engine for Java!";
		recti rect = new recti(10, 10, 280, 30);
		IGUIStaticText staticText = guienv.addStaticText(text, rect, true,
				true, null, -1);

		IAnimatedMesh mesh = smgr.getMesh("media/sydney.md2");
		IAnimatedMeshSceneNode node = smgr.addAnimatedMeshSceneNode(mesh, null,
				-1, new vector3df(0, 0, 0), new vector3df(0, 0, 0),
				new vector3df(1, 1, 1));

		if (node != null) {
			node.setMaterialFlag(E_MATERIAL_FLAG.EMF_LIGHTING, false);
			node.setFrameLoop(0, 99999);
			node
					.setMaterialTexture(0, driver
							.getTexture("media/sydney.bmp"));
		}

		smgr.addCameraSceneNode(null, new vector3df(0, 10, -60), new vector3df(
				0, 0, 0), -1);

		final int step = 100;
		int counter = 0;
		double diff = 0;
		long timer1 = System.currentTimeMillis();
		long timer2 = 0;
		while (device.run()) {

			int a = 0;
			int r = 100;
			int g = 100;
			int b = 100;

			driver.beginScene(true, true, new SColor(a, r, g, b));

			smgr.drawAll();
			guienv.drawAll();

			driver.endScene();

			try {
				// Thread.sleep(5);
			} catch (Exception e) {
			}

			counter++;
			if (counter >= step) {
				timer2 = System.currentTimeMillis();
				diff = 1000.0 / ((timer2 - timer1) / (double) step);
				counter = 0;
				timer1 = System.currentTimeMillis();
				text = "This is the Irrlicht Software engine for Java! FPS: "
						+ diff;
				staticText.setText(text);
			}
		}

		device.closeDevice();
	}
}
Go to Run->Run As->Java Application

Image

Voila! Irrlicht is up and running! That's all folks.[/code]
Last edited by Serg Nechaeff on Wed Apr 18, 2007 6:30 pm, edited 1 time in total.
http://www.javazing.com
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
Stratus
Posts: 1
Joined: Mon Mar 19, 2007 4:07 am
Contact:

Good Post

Post by Stratus »

Verry good Post, this little tutorial helps me to start writing Irrllicht With Java and Eclipse.

Please correct te URL's of the pictures in order that we can see them
Con Precisión de Ingeniero y Pasión de Montañista
---
http://www.imatec.cl
Post Reply