thanx for the help … I know I didn’t explain it all that well so I’ll try to do it better now …
- Yip the first textures loads just fine … my landscape texture …
- never tried but I just took one of the nehe codes for this so I presume this shouldn’t be a problem.
- never tried either
- goes wrong when I want to display my texture on something. He doesn’t give any faults, but either doesn’t show the texture I bind or uses another one.
I’ll now give some parts of my code so you get a better idea …
First of all use the TextureReader from Pepijn Van Eeckhoudt and his common gl classes.
the loading part is as follows:
/**
* @param gl
* @param i
* @param string
*/
public static void loadLinearGLTextures(
GL gl,
int textureID,
String textureName)
throws IOException {
gl.glGenTextures(1, new int[] { Renderer.g_TexturesID[textureID] });
TextureReader.Texture texture = TextureReader.readTexture(textureName);
//Create Linear Filtered Texture
gl.glBindTexture(GL.GL_TEXTURE_2D, Renderer.g_TexturesID[textureID]);
gl.glTexParameteri(
GL.GL_TEXTURE_2D,
GL.GL_TEXTURE_MAG_FILTER,
GL.GL_LINEAR);
gl.glTexParameteri(
GL.GL_TEXTURE_2D,
GL.GL_TEXTURE_MIN_FILTER,
GL.GL_LINEAR);
gl.glTexImage2D(
GL.GL_TEXTURE_2D,
0,
3,
texture.getWidth(),
texture.getHeight(),
0,
GL.GL_RGB,
GL.GL_UNSIGNED_BYTE,
texture.getPixels());
}
then in my Renderer class:
/** Array of all the textures references */
public static int[] g_TexturesID = new int[TextureNames.MAXIMUM_TEXTURES];
and finally from my different classes I call this from init method:
public void init(GLDrawable glDrawable) {
GL gl = glDrawable.getGL();
try {
TextureLoader.loadLinearGLTextures(
gl,
Renderer.g_TexturesID[TextureNames.SIMPLE_FONT_TEXTURE],
"Data/Font/fonts.png");
} catch (IOException e) {
throw new RuntimeException(e);
}
of coarse is SIMPLE_FONT_TEXTURE a unique int value for the texture.
I already tried lots of different ways and this is my last one, but if someone has something comparable. Then I mean loading textures from different classes orso, he may always send the source codes to me at kozen@pandora.be
Hope this helps already something …
Thanx already