Java Code Examples for com.jogamp.opengl.util.texture.TextureIO#newTexture()

The following examples show how to use com.jogamp.opengl.util.texture.TextureIO#newTexture() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextureEntity.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
public void render(GL2 gl2) {
	if(textureDirty) {
		// texture has changed, load the new texture.
		if(t == null || t.length()==0) texture = null;
		else {
			try {
				texture = TextureIO.newTexture(FileAccess.open(t), false, t.substring(t.lastIndexOf('.')+1));
			} catch(IOException e) {
				//e.printStackTrace();
				Log.error("I can't load "+t);
			}
			textureDirty=false;
		}
	}
    if(texture==null) {
		gl2.glDisable(GL2.GL_TEXTURE_2D);
    } else {
		gl2.glEnable(GL2.GL_TEXTURE_2D);
    	texture.bind(gl2);
    }
}
 
Example 2
Source File: GLTools.java    From constellation with Apache License 2.0 5 votes vote down vote up
public static Texture loadTexture(final GL3 gl, final InputStream in, final String ext, final int minFilter, final int magFilter, final int wrapMode) throws IOException {
        // NVS-415: Appears to be a bug in JOGL where texture provider for PNG files does not flip the texture.
//         final TextureData data = TextureIO.newTextureData(gl.getGLProfile(), in, false, ext);
        final TextureData data = TextureIO.newTextureData(gl.getGLProfile(), in, false, null);
        final Texture tex = TextureIO.newTexture(data);

        gl.glTexParameteri(GL3.GL_TEXTURE_2D, GL3.GL_TEXTURE_WRAP_S, wrapMode);
        gl.glTexParameteri(GL3.GL_TEXTURE_2D, GL3.GL_TEXTURE_WRAP_T, wrapMode);

        gl.glTexParameteri(GL3.GL_TEXTURE_2D, GL3.GL_TEXTURE_MIN_FILTER, minFilter);
        gl.glTexParameteri(GL3.GL_TEXTURE_2D, GL3.GL_TEXTURE_MAG_FILTER, magFilter);

        return tex;
    }
 
Example 3
Source File: JOGLRenderer.java    From WarpPI with Apache License 2.0 5 votes vote down vote up
static Texture importTexture(File f, final boolean deleteOnExit) throws GLException, IOException {
	final Texture tex = TextureIO.newTexture(f, false);
	if (deleteOnExit && f.exists())
		try {
			if (WarpPI.getPlatform().getSettings().isDebugEnabled())
				throw new IOException("Delete on exit!");
			f.delete();
		} catch (final Exception ex) {
			f.deleteOnExit();
		}
	tex.setTexParameteri(JOGLRenderer.gl, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
	tex.setTexParameteri(JOGLRenderer.gl, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
	f = null;
	return tex;
}
 
Example 4
Source File: TextureShape.java    From MeteoInfo with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Load texture from file
 * @throws IOException 
 */
public void loadTexture() throws IOException {
    this.texture = TextureIO.newTexture(new File(fileName), true);
}