/*******************************************************************************
 * Caleydo - Visualization for Molecular Biology - http://caleydo.org
 * Copyright (c) The Caleydo Team. All rights reserved.
 * Licensed under the new BSD license, available at http://caleydo.org/license
 *******************************************************************************/
package org.caleydo.core.view.opengl.layout2;

import com.jogamp.opengl.util.texture.Texture;

/**
 * Render image and set setSize to size of image on loading.
 * 
 * @author Thomas Geymayer
 * 
 */
public class GLImageElement extends GLElement {

	/**
	 * Path to the texture to display
	 */
	protected String texturePath;

	protected Texture texture;

	public GLImageElement(String path) {
		texturePath = path;

		// Default size to prevent culling (will be updated
		// during first render pass)
		setSize(32, 32);
	}

	@Override
	protected void renderImpl(GLGraphics g, float w, float h) {
		if (texture == null) {
			texture = g.getTexture(texturePath);
			setSize(texture.getWidth(), texture.getHeight());
			relayout();
		}

		g.fillImage(texture, 0, 0, w, h);
	}

}

@@ -408,16 +408,78 @@
 yout2;%0A%0A
+import javax.media.opengl.GL;%0Aimport javax.media.opengl.GL2;%0A%0A
 import c
@@ -585,17 +585,16 @@
 ding.%0A *
- 
 %0A * @aut
@@ -615,17 +615,16 @@
 mayer%0A *
- 
 %0A */%0Apub
@@ -1154,16 +1154,192 @@
 );%0A%09%09%7D%0A%0A
+%09%09// Alpha test (required to use depth base picking)%0A%09%09g.gl.glPushAttrib(GL.GL_COLOR_BUFFER_BIT);%0A%09%09g.gl.glAlphaFunc(GL.GL_GREATER, 0.3f);%0A%09%09g.gl.glEnable(GL2.GL_ALPHA_TEST);%0A%0A
 %09%09g.fill
@@ -1365,15 +1365,38 @@
 , w, h);
+%0A%0A%09%09g.gl.glPopAttrib();
 %0A%09%7D%0A%0A%7D%0A

Enable alpha test for GLImageElement