PDA

View Full Version : Texture map problem



01-30-2004, 04:00 AM
Hi i am currently trying to implement a texture into a game i have been doing, only problem is the code i think seems fine just i get an exception when executed, the code will compile. heres the code, if anyone can spot a problem please i will be very grateful to you.

//create array to hold 1 texture for now
int[] texture = new int[1];

//load texture
public void LoadGLTextures() {

PngTextureLoader texLoader = new PngTextureLoader(gl, glu);
texLoader.readTexture("Image1.png");
if(texLoader.isOk())

{
//Create Texture

gl.glGenTextures(1, texture);
gl.glBindTexture(GL_TEXTURE_2D, texture[0]);
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

gl.glTexImage2D( GL_TEXTURE_2D, 0, 3, texLoader.getImageWidth(),
texLoader.getImageHeight(), 0, GL_RGB,
GL_UNSIGNED_BYTE, texLoader.getTexture());

}
}

public void RenderBackgroundTexture()
{ gl.glBindTexture(GL_TEXTURE_2D, texture[0]);
gl.glEnable(GL_TEXTURE_2D);
gl.glBegin(GL_QUADS);
//Front Face
gl.glTexCoord2f(0.0f, 0.0f);
gl.glVertex3f(-3,2,-1f);
//Bottom Left Of The Texture and Quad
gl.glTexCoord2f(1.0f, 0.0f);
gl.glVertex3f( -3,3,-1f);
//Bottom Right Of The Texture and Quad
gl.glTexCoord2f(1.0f, 1.0f);
gl.glVertex3f( 2, 2,-1f);
//Top Right Of The Texture and Quad
gl.glTexCoord2f(0.0f, 1.0f);
gl.glVertex3f(-3, 2,-1f);
//Top Left Of The Texture and Quad
gl.glEnd();
gl.glDisable(GL_TEXTURE_2D);
}

//call loadtexture from init method
LoadGLTextures();


my texture is 128 * 128, the exception i get is

exception occured during event dispatching
java.lang.NoClassDefFoundError : com/sixlegs/image/png/Image
at gl4java.utils.textures.IOTextureLoader.readTexture (IOTLoader.java33

etc, etc.

please help!

Honk
01-30-2004, 05:19 AM
Looks like a typical classpath problem, make sure all the required jar's are listet in the classpath.

01-31-2004, 04:01 AM
thanks honk, i had a manual program to do this, but it didnt specify where the glutffonts.jar and the other jar files was, so did this in sysedit autoexec.bat and changed the classpath! U learn something new everyday!

Thanks

Honk
01-31-2004, 05:03 AM
You are welcome.