box

Hola everyone.

I am currently working on my own two game projects: one project is of mobile phone game and other is 2.5 or side-scrolling 3d game, not much sure. So for second project i am making an small engine that will be used to make 2.5D game or side scrolling 3d game, Just simple and fun game. I have chosen LWJGL, which is a java binding for Opengl to make my game. So first thing i need to work on loading images.texture mapping in lwjgl. I found some pretty much useful tutorials and great help from lwjgl forums. But atlast i got something that i was looking for from the forum.

I came to know about slick-util which is free and open source lib to load images and play sounds. Its very easy to pick up and implement it. Its just worked flawlessly and smoothly for me. You can download the slick-util from here. PNG, GIF, JPG, TGA are supported and WAV, OGG, XM sounds are supported by slick-util.

So here i’l show u how easily i loaded images and mapped to a 3D BOX. First u have to setup lwjgl and slick-util with netbeans. Yeah i am using netbeans to write my program. You can see my post to setup lwjgl with netbeans. Now we will set up slick-util, its a continuation to the steps that we did to setup lwjgl.

Continued…

Step 1: We just have to configure the project properties so that project can find the lib to compile and run.

1

2

Ok that was it. Now slick-util lib has been set up.Now first i’l show u how to load image and bind it , full source will be at the end.

Texture texture;

Texture is an interface having description of texture which will be loaded.

texture = TextureLoader.getTexture(“PNG”, new FileInputStream(“Data/Crate.png”));

now we are loading the texture using TextureLoader utility class. Just smooth and simple.

texture.bind();

Now we are binding the texture.

So thats what u need to load the image and map them to objects. Download this image to use it in this program.

Crate

Full Code:

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package com.gaanza.engine.test2;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.lwjgl.LWJGLException;
import org.lwjgl.Sys;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.GLU;
import org.newdawn.slick.opengl.Texture;
import org.newdawn.slick.opengl.TextureLoader;

/**
*
* @author Java Guy
*/
public class EngineTest {

private static boolean gameRunning=true;
private static int targetWidth = 800;
private static int targetHeight = 600;

private float xrot=0.1f;
private float yrot=0.1f;
private float zrot=0.1f;

/** The texture that's been loaded */
private Texture texture;

public static void main(String[] args){
EngineTest app=new EngineTest();
initDisplay(false);
initGL();
app.init();
app.run();
}

private static void initDisplay(boolean fullscreen){

DisplayMode chosenMode = null;

try {
DisplayMode[] modes = Display.getAvailableDisplayModes();

for (int i=0;i

Gracias.