So I am trying draw text to the screen with a custom font, which I have done. The issue comes when using textures at the same time.
I load my textures like this:
int Texture{
try {
InputStream in = new FileInputStream(filelocation);
PNGDecoder decoder = new PNGDecoder(in);
ByteBuffer buffer = BufferUtils.createByteBuffer(4
* decoder.getWidth() * decoder.getHeight());
decoder.decode(buffer, decoder.getWidth() * 4, Format.RGBA);
buffer.flip();
in.close();
//glBindTexture(GL_TEXTURE_2D, Texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, decoder.getWidth(),
decoder.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE,
buffer);
glBindTexture(GL_TEXTURE_2D, 0);
} catch (FileNotFoundException ex) {
System.err
.println("Textures are not in their correct location.");
Display.destroy();
System.exit(1);
} catch (IOException ex) {
System.err
.println("Textures are not in their correct location.");
Display.destroy();
System.exit(1);
}
}
And my font like this
public static void load(float size) {
try {
InputStream inputStream = ResourceLoader.getResourceAsStream(filelocation);
Font awtFont = Font.createFont(Font.TRUETYPE_FONT, inputStream);
awtFont = awtFont.deriveFont(size);
fontname = new TrueTypeFont(awtFont, true);
} catch (Exception e) {
e.printStackTrace();
}
}
What is happening is some how the inputstreams have become 'mixed up' and the text I want is draw with the texture I loaded.
I load the font before the game loop from the Font.class and the textures are loaded from the class they are used in, which is called during the game loop.
I have googled the issue and cannot find anything. If you can understand me, thanks in advance.