How to add a texture to the following example?

Hello,
I’ve the following code with shaders in opengl ES. I would like to add a texture to the square we display… How could I do simply?
Thanks in advance
Xavier

the current java code :
protected ShaderState shaderState = new ShaderState();;
protected ShaderProgram shaderProgram = new ShaderProgram();
protected GL2ES2 gl;

public static void main(String[] args)
{
	GLCapabilities capabilities = new GLCapabilities(GLProfile.getGL2ES2()); 
	 
	GLCanvas canvas = new GLCanvas(capabilities);
	Frame frame = new Frame("Simple JOGL Application with shaders"); 

	canvas.addGLEventListener(new SimpleShader());
	frame.add(canvas);
	frame.setSize(640, 480);
	final Animator animator = new Animator(canvas);
	frame.addWindowListener(new WindowAdapter()
	{
		@Override
		public void windowClosing(WindowEvent e)
		{
			// Run this on another thread than the AWT event queue
			// so that Animator.stop() completes before exiting
			new Thread(new Runnable()
			{
				public void run()
				{
					animator.stop();
					System.exit(0);
				}
			}).start();
		}
	});
	frame.setLocationRelativeTo(null);
	frame.setVisible(true);
	animator.start();
}

public void init(GLAutoDrawable drawable)
{
	gl = drawable.getGL().getGL2ES2();

	 // Create & Compile the shader objects
    ShaderCode vertexShaderCode = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, SimpleShader.class,
                                        "shader", "shader/bin", "simpleshader");
    ShaderCode fragmentShaderCode = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, SimpleShader.class,
                                        "shader", "shader/bin", "simpleshader");
	shaderProgram.add(vertexShaderCode);
    shaderProgram.add(fragmentShaderCode);
    if(!shaderProgram.link(gl, System.err)) {
        throw new GLException("Couldn't link program: "+shaderProgram);
    }
    
    shaderState.attachShaderProgram(gl, shaderProgram);
	shaderState.glUseProgram(gl, true);
	
    GLArrayDataClient vertices = GLArrayDataClient.createGLSL(gl, "mgl_Vertex", 3, GL2ES2.GL_FLOAT, false, 4);
    {
        // Fill them up
        FloatBuffer verticeb = (FloatBuffer)vertices.getBuffer();
        verticeb.put(-2);  verticeb.put(  2);  verticeb.put( 0);
        verticeb.put( 2);  verticeb.put(  2);  verticeb.put( 0);
        verticeb.put(-2);  verticeb.put( -2);  verticeb.put( 0);
        verticeb.put( 2);  verticeb.put( -2);  verticeb.put( 0);
    }
    vertices.seal(gl, true); 

    gl.glClearColor(0, 0, 0, 1);
    shaderState.glUseProgram(gl, false);
}

public void display(GLAutoDrawable drawable)
{ 
    shaderState.glUseProgram(gl, true);

    gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT );
    // Draw a square
    gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4);

    shaderState.glUseProgram(gl, false);
}

The current fragment shader code :

void main() {
gl_FragColor = vec4(1.0,1.0,0.0,1.0);
}

The current vertex shader code :

attribute vec4 mgl_Vertex;
void main() {
gl_Position = mgl_Vertex;
}

I’ve tried the following code without success… Any help?

Java code:

public class SimpleShaderExampleWithTexture implements GLEventListener {
protected ShaderState shaderState = new ShaderState();;
protected ShaderProgram shaderProgram = new ShaderProgram();
protected GL2ES2 gl;
protected String str ="";
protected Texture aTexture ;
protected int[] texturesIDs = new int[1];

public static void main(String[] args) {
	GLCapabilities capabilities = new GLCapabilities(GLProfile.getDefault());

	GLCanvas canvas = new GLCanvas(capabilities);
	Frame frame = new Frame("Simple JOGL Application with shaders");

	canvas.addGLEventListener(new SimpleShaderExampleWithTexture());
	frame.add(canvas);
	frame.setSize(640, 480);
	final Animator animator = new Animator(canvas);
	frame.addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			// Run this on another thread than the AWT event queue
			// so that Animator.stop() completes before exiting
			new Thread(new Runnable() {
				public void run() {
					animator.stop();
					System.exit(0);
				}
			}).start();
		}
	});
	frame.setLocationRelativeTo(null);
	frame.setVisible(true);
	animator.start();
}

public void init(GLAutoDrawable drawable) {
	gl = drawable.getGL().getGL2ES2();

	// Create & Compile the shader objects
	ShaderCode vertexShaderCode = ShaderCode.create(gl,
			GL2ES2.GL_VERTEX_SHADER, 1, SimpleShaderExampleWithTexture.class, "shader",
			"shader/bin", "simpleexample");
	ShaderCode fragmentShaderCode = ShaderCode.create(gl,
			GL2ES2.GL_FRAGMENT_SHADER, 1, SimpleShaderExampleWithTexture.class, "shader",
			"shader/bin", "simpleexample");
	shaderProgram.add(vertexShaderCode);
	shaderProgram.add(fragmentShaderCode);
	if (!shaderProgram.link(gl, System.err)) {
		str ="Couldn't link program: " + shaderProgram;
		 throw new GLException("Couldn't link program: " + shaderProgram);
	}

	shaderState.attachShaderProgram(gl, shaderProgram);
	shaderState.glUseProgram(gl, true);

	GLArrayDataClient vertices = GLArrayDataClient.createGLSL(gl,
			"mgl_Vertex", 3, GL2ES2.GL_FLOAT, false, 4);
	{
		// Fill them up
		FloatBuffer verticeb = (FloatBuffer) vertices.getBuffer();
		verticeb.put(-2);
		verticeb.put(2);
		verticeb.put(0);
		verticeb.put(2);
		verticeb.put(2);
		verticeb.put(0);
		verticeb.put(-2);
		verticeb.put(-2);
		verticeb.put(0);
		verticeb.put(2);
		verticeb.put(-2);
		verticeb.put(0);
	}
	vertices.seal(gl, true);
	TextureData tdata=null;
	try {
		tdata = TextureIO.newTextureData(new URL("myFileURLToBeDefined"),
		       true,
		       ".jpg");
	} catch (MalformedURLException e) {
		e.printStackTrace();
	} catch (IOException e) {
		e.printStackTrace();
	}
	gl.glGenTextures(1, texturesIDs, 0);
    gl.glBindTexture(GL.GL_TEXTURE_2D, texturesIDs[0]);  
    gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB, 2, 2, 0, GL.GL_RGB, 
             GL.GL_UNSIGNED_BYTE, tdata.getBuffer());

    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
	
	gl.glClearColor(0, 0, 0, 1);
	shaderState.glUseProgram(gl, false);
}

public void display(GLAutoDrawable drawable) {
	shaderState.glUseProgram(gl, true);
	
	gl.glActiveTexture(GL.GL_TEXTURE0);
	int samplerloc = gl.glGetUniformLocation(shaderProgram.id(),"s_texture");
	
	gl.glActiveTexture(GL.GL_TEXTURE0);
	gl.glBindTexture(GL.GL_TEXTURE_2D, texturesIDs[0]); 
	gl.glUniform1i(samplerloc, 0);

	gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT);
	// Draw a square
	gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);

	shaderState.glUseProgram(gl, false);
}

public void reshape(GLAutoDrawable drawable, int x, int y, int width,
		int height) {
}

public void dispose(GLAutoDrawable drawable) {
}

public void displayChanged(GLAutoDrawable drawable, boolean modeChanged,
		boolean deviceChanged) {
}

}

Vexter code

attribute vec4 mgl_Vertex;
attribute vec2 a_texCoord;
varying vec2 v_texCoord;
void main() {
gl_Position = mgl_Vertex;
v_texCoord = a_texCoord;
}

Fragment code
varying vec2 v_texCoord;
uniform sampler2D s_texture;
void main() {
gl_FragColor = texture2D(s_texture, v_texCoord);
}

Hi!

Don’t store the GL instance. Put this in the method display(GLAutoDrawable) too:

gl = drawable.getGL().getGL2ES2();

Some other changes might be necessary. Look at the examples on the JOGL page on Project Kenai.

It looks you never set the texture coordinates, but your shader use them (a_texCoord).

With a little clean up, it looks like this:

import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.net.MalformedURLException;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;

import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;

import com.sun.opengl.util.Animator;
import com.sun.opengl.util.BufferUtil;
import com.sun.opengl.util.GLArrayDataClient;
import com.sun.opengl.util.glsl.ShaderCode;
import com.sun.opengl.util.glsl.ShaderProgram;
import com.sun.opengl.util.glsl.ShaderState;
import com.sun.opengl.util.texture.TextureData;
import com.sun.opengl.util.texture.TextureIO;


public class SimpleShaderExampleWithTexture implements GLEventListener {

    private final ShaderState   shaderState   = new ShaderState();   ;
    private final ShaderProgram shaderProgram = new ShaderProgram();

    public static void main(final String[] args) {

        final GLCapabilities capabilities = new GLCapabilities(GLProfile.getGL2ES2());

        final GLCanvas canvas = new GLCanvas(capabilities);
        final Animator animator = new Animator(canvas);
        final Frame frame = new Frame("Simple JOGL Application with shaders");

        canvas.addGLEventListener(new SimpleShaderExampleWithTexture());

        frame.addWindowListener(new WindowAdapter() {

            @Override public void windowClosing(final WindowEvent e) {

                new Thread(new Runnable() {

                    public void run() {

                        animator.stop();
                        System.exit(0);

                    }

                }).start();

            }
        });

        frame.setSize(640, 480);
        frame.setLocationRelativeTo(null);
        frame.add(canvas);
        frame.setVisible(true);
        animator.start();

    }

    public void init(final GLAutoDrawable drawable) {

        GL2ES2 gl = drawable.getGL().getGL2ES2();


        final ShaderCode vertexShaderCode = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, SimpleShaderExampleWithTexture.class, "shader", "shader", "vertex.glsl");
        final ShaderCode fragmentShaderCode = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, SimpleShaderExampleWithTexture.class, "shader", "shader", "fragment.glsl");

        shaderProgram.add(vertexShaderCode);
        shaderProgram.add(fragmentShaderCode);

        if (!shaderProgram.link(gl, System.err)) throw new GLException("Couldn't link program: " + shaderProgram);

        shaderState.attachShaderProgram(gl, shaderProgram);
        shaderState.glUseProgram(gl, true);


        final GLArrayDataClient vertices = GLArrayDataClient.createGLSL(gl, "a_Vertex", 3, GL.GL_FLOAT, false, 4);
        final FloatBuffer verticeb = (FloatBuffer) vertices.getBuffer();
        verticeb.put(-0.5f);  verticeb.put(0.5f);   verticeb.put(0);
        verticeb.put(0.5f);   verticeb.put(0.5f);   verticeb.put(0);
        verticeb.put(-0.5f);  verticeb.put(-0.5f);  verticeb.put(0);
        verticeb.put(0.5f);   verticeb.put(-0.5f);  verticeb.put(0);
        vertices.seal(gl, true);

        final GLArrayDataClient texcords = GLArrayDataClient.createGLSL(gl, "a_TexCoord", 2, GL.GL_FLOAT, false, 4);
        final FloatBuffer texcordsb = (FloatBuffer) texcords.getBuffer();
        texcordsb.put(0);  texcordsb.put(0);
        texcordsb.put(1);  texcordsb.put(0);
        texcordsb.put(0);  texcordsb.put(1);
        texcordsb.put(1);  texcordsb.put(1);
        texcords.seal(gl, true);


        TextureData tdata = null;
        try {

            tdata = TextureIO.newTextureData(this.getClass().getClassLoader().getResourceAsStream("blub.png"), false, "png");

        } catch (final MalformedURLException e) {

            e.printStackTrace();

        } catch (final IOException e) {

            e.printStackTrace();

        }


        final IntBuffer buffer = BufferUtil.newIntBuffer(1);
        gl.glActiveTexture(GL.GL_TEXTURE0);
        gl.glGenTextures(1, buffer);
        gl.glBindTexture(GL.GL_TEXTURE_2D, buffer.get(0));

        gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
        gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);

        gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);
        gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB, tdata.getWidth(), tdata.getHeight(), 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, tdata.getBuffer());

        shaderState.glUseProgram(gl, false);

    }

    public void display(final GLAutoDrawable drawable) {

        GL2ES2 gl = drawable.getGL().getGL2ES2();

        gl.glClear(GL.GL_COLOR_BUFFER_BIT);

        shaderState.glUseProgram(gl, true);
        final int samplerloc = gl.glGetUniformLocation(shaderProgram.id(), "s_Texture");

        gl.glActiveTexture(GL.GL_TEXTURE0);
        gl.glUniform1i(samplerloc, GL.GL_TEXTURE0);

        gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);

        shaderState.glUseProgram(gl, false);

    }


    public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {}

    public void dispose(final GLAutoDrawable drawable) {}

    public void displayChanged(final GLAutoDrawable drawable, final boolean modeChanged, final boolean deviceChanged) {}

    /*
     * vertex.glsl.vp:
     * 
     * attribute vec4 a_Vertex;
     * attribute vec2 a_TexCoord;
     * varying vec2 v_TexCoord;
     * 
     * void main() {
     * 
     *    gl_Position = a_Vertex;
     *    v_TexCoord = a_TexCoord;
     * 
     * }
     */

    /*
     * fragment.glsl.fp:
     * 
     * varying vec2 v_TexCoord;
     * uniform sampler2D s_Texture;
     * 
     * void main() {
     * 
     *    gl_FragColor = texture2D(s_Texture, v_TexCoord);
     * 
     * }
     */

}

But I don’t use ES or the JOGL util Classes, so there are possibly thinks not solid correct (nevertheless it run).

Anyway, I hope it helps.

Regards,
Fancy

Thanks a lot both for having spent some times on this example…

I’ve still this exception when trying to run the exemple… Any clue?
Exception in thread “AWT-EventQueue-0” javax.media.opengl.GLException: No shader code found (source nor binary) for src: shader/vertex.glsl.vp, bin: null

Concerning the demo examples provided with jogl, there are a lot valuable things but it is quite hard for new comer to have a good overall view of how doing things… Opengl is so vaste between opengl1, 2, ES1, ES2, use of glsl, of cg, use of utility tool classes or not and so on… and many examples ar too complex at first… certainly some examples could be added (like the previous one) to help beginners to well develop applications according to their needs (for instance my need are to try to develop with shaders properly).

best regards

Have you put the shaders at the right place (posted at the end of the source)?
In eclipse it should be run with src/shader/vertex.glsl.vp and src/shader/fragment.glsl.fp.
Your SimpleShaderExampleWithTexture / Class / JAR (whatever) must be able to find the shaders at runtime.

Regards,
Fancy

Hi Fancy,
Thanks for the advice…
I’ve still problems with the code :

  1. I can only have a texture in tga format (not as you in png)
  2. once launched, I’ve only a black screen on display

Any clue?

regards
Xavier

Here is a working example without loading a texture from a file.

Java source code :

package essai2;

import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;

import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;

import com.sun.opengl.util.Animator;
import com.sun.opengl.util.BufferUtil;
import com.sun.opengl.util.GLArrayDataClient;
import com.sun.opengl.util.glsl.ShaderCode;
import com.sun.opengl.util.glsl.ShaderProgram;
import com.sun.opengl.util.glsl.ShaderState;

public class SimpleShaderExampleWithTexture2 implements GLEventListener {

private   ShaderState   shaderState   = null;   ;
private   ShaderProgram shaderProgram = null;

public static void main(final String[] args) {

    final GLCapabilities capabilities = new GLCapabilities(GLProfile.getGL2ES2());

    final GLCanvas canvas = new GLCanvas(capabilities);
    final Animator animator = new Animator(canvas);
    final Frame frame = new Frame("Simple JOGL Application with shaders");

    canvas.addGLEventListener(new SimpleShaderExampleWithTexture2());

    frame.addWindowListener(new WindowAdapter() {

        @Override public void windowClosing(final WindowEvent e) {
            new Thread(new Runnable() {
                public void run() {
                    animator.stop();
                    System.exit(0);
                }
            }).start();

        }
    });

    frame.setSize(640, 480);
    frame.setLocationRelativeTo(null);
    frame.add(canvas);
    frame.setVisible(true);
    animator.start();

}

public void init(final GLAutoDrawable drawable) {
	shaderState   = new ShaderState();   ;
    shaderProgram = new ShaderProgram();

    GL2ES2 gl = drawable.getGL().getGL2ES2();


    final ShaderCode vertexShaderCode = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, SimpleShaderExampleWithTexture2.class, "shader", "shader", "vertex.glsl");
    final ShaderCode fragmentShaderCode = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, SimpleShaderExampleWithTexture2.class, "shader", "shader", "fragment.glsl");

    shaderProgram.add(vertexShaderCode);
    shaderProgram.add(fragmentShaderCode);
    if (!shaderProgram.link(gl, System.err)) throw new GLException("Couldn't link program: " + shaderProgram);

    shaderState.attachShaderProgram(gl, shaderProgram);
    shaderState.glUseProgram(gl, true);

    final GLArrayDataClient vertices = GLArrayDataClient.createGLSL(gl, "a_Vertex", 3, GL.GL_FLOAT, false, 4);
    final FloatBuffer verticeb = (FloatBuffer) vertices.getBuffer();
    verticeb.put(-0.5f);  verticeb.put(0.5f);   verticeb.put(0f);
    verticeb.put(0.5f);   verticeb.put(0.5f);   verticeb.put(0f);
    verticeb.put(-0.5f);  verticeb.put(-0.5f);  verticeb.put(0f);
    verticeb.put(0.5f);   verticeb.put(-0.5f);  verticeb.put(0f);
    vertices.seal(gl, true);

    final GLArrayDataClient texcords = GLArrayDataClient.createGLSL(gl, "a_TexCoord", 2, GL.GL_FLOAT, false, 4);
    final FloatBuffer texcordsb = (FloatBuffer) texcords.getBuffer();
    texcordsb.put(0f);  texcordsb.put(0f);
    texcordsb.put(1f);  texcordsb.put(0f);
    texcordsb.put(0f);  texcordsb.put(1f);
    texcordsb.put(1f);  texcordsb.put(1f);
    texcords.seal(gl, true);
    
    final IntBuffer buffer = BufferUtil.newIntBuffer(2);
    {
		ByteBuffer dataBuffer1 = ByteBuffer.allocate(12);
		dataBuffer1.put(0,(byte)0);dataBuffer1.put(1,(byte)255);dataBuffer1.put(2,(byte)0);
		dataBuffer1.put(3,(byte)255);dataBuffer1.put(4,(byte)0);dataBuffer1.put(5,(byte)0);
		dataBuffer1.put(6,(byte)0);dataBuffer1.put(7,(byte)0);dataBuffer1.put(8,(byte)255); 
		dataBuffer1.put(9,(byte)255);dataBuffer1.put(10,(byte)255);dataBuffer1.put(11,(byte)0); 

        gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);
        
        // Each texture is defined by GL_TEXTURE{n} in the order of definition of the texture
        gl.glActiveTexture(GL.GL_TEXTURE0);
        // we get the ID for the texture 1 and put it in the ids buffer
        gl.glGenTextures(0, buffer);
        // we tell opengl that the texture {n} is a 2D texture
        gl.glBindTexture(GL.GL_TEXTURE_2D, buffer.get(0));
	

        // we send the texture to the GPU; but we don't tell for the moment where to use the texture and how
        gl.glTexImage2D(GL2ES2.GL_TEXTURE_2D, 0, GL2ES2.GL_RGB, 2, 2, 0, GL2ES2.GL_RGB, GL2ES2.GL_UNSIGNED_BYTE, dataBuffer1);
    	gl.glTexParameteri(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST );
		gl.glTexParameteri(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST );
    }

    shaderState.glUseProgram(gl, false);
}

public void display(final GLAutoDrawable drawable) {

    GL2ES2 gl = drawable.getGL().getGL2ES2();
    shaderState.glUseProgram(gl, true);

    gl.glClear(GL.GL_COLOR_BUFFER_BIT);

    {
        // we define a constant which will be used  into the fragment
        final int samplerloc = gl.glGetUniformLocation(shaderProgram.id(), "s_Texture0");

        // we define the Texture0 as the active one
        gl.glActiveTexture(GL.GL_TEXTURE0);
        // once made, we  assign the texture 0 to the  s_texture constant
        gl.glUniform1i(samplerloc, GL.GL_TEXTURE0);
    }

    // we display the vertexes ; here we have a rectangle
    gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);

    shaderState.glUseProgram(gl, false);
}


public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {}

public void dispose(final GLAutoDrawable drawable) {}

public void displayChanged(final GLAutoDrawable drawable, final boolean modeChanged, final boolean deviceChanged) {}

}

vertex shader :
attribute vec4 a_Vertex;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;

void main() {
gl_Position = a_Vertex;
v_TexCoord = a_TexCoord;
}

fragment shader :
varying vec2 v_TexCoord;
uniform sampler2D s_Texture;

void main() {
gl_FragColor = texture2D(s_Texture, v_TexCoord);
}

TGA is not easy, because the TextureIO seems not to support the full range of possible TGA files. (But you should see en Exception when you run my sample code! Assumedly: “TGADecoder Compressed True Color images not supported”)

(If you see: “java.io.IOException: Stream was null” then your image is at the wrong place)

So you have the following possibilities:

  1. save your textures as tga (uncompressed, true color)
  2. save your textures in a fully supported format like png
  3. use a third party image decoder (google)
  4. do it yourself (JOGL / NeHe)

Regards,
Fancy