private Texture loadTexture(GL3 gl, String file) throws GLException, IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); ImageIO.write(ImageIO.read(new File(file)), "png", os); InputStream fis = new ByteArrayInputStream(os.toByteArray()); Texture newTexture = TextureIO.newTexture(fis, true, TextureIO.PNG); newTexture.setTexParameteri(gl, GL3.GL_TEXTURE_WRAP_S, GL3.GL_REPEAT); newTexture.setTexParameteri(gl, GL3.GL_TEXTURE_WRAP_T, GL3.GL_REPEAT); newTexture.setTexParameteri(gl, GL3.GL_TEXTURE_MAG_FILTER, GL3.GL_LINEAR); newTexture.setTexParameteri(gl, GL3.GL_TEXTURE_MIN_FILTER, GL3.GL_LINEAR_MIPMAP_LINEAR); System.out.println("Must flip: " + newTexture.getMustFlipVertically()); return newTexture; }
public void clean(GL3 gl) { if (isWrapSDirty) { texture.setTexParameteri(gl, GL3.GL_TEXTURE_WRAP_S, wrapS.glType); isWrapSDirty = false; } if (isWrapTDirty) { texture.setTexParameteri(gl, GL3.GL_TEXTURE_WRAP_T, wrapT.glType); isWrapTDirty = false; } if (isMinFilterDirty) { texture.setTexParameteri(gl, GL3.GL_TEXTURE_MIN_FILTER, minFilter.glType); isMinFilterDirty = false; } if (isMagFilterDirty) { texture.setTexParameteri(gl, GL3.GL_TEXTURE_MAG_FILTER, magFilter.glType); isMagFilterDirty = false; } }