From 697d631bc0333b92689972ff3e621e3549fb6c80 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Sat, 18 Feb 2012 18:37:41 +0100
Subject: JOGL'fy dualDepthPeeling demo (Using JOGL ShaderState/Code/Program)

---
 src/demos/dualDepthPeeling/GLHelper.java | 53 ++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 src/demos/dualDepthPeeling/GLHelper.java

(limited to 'src/demos/dualDepthPeeling/GLHelper.java')

diff --git a/src/demos/dualDepthPeeling/GLHelper.java b/src/demos/dualDepthPeeling/GLHelper.java
new file mode 100644
index 0000000..cf1cccc
--- /dev/null
+++ b/src/demos/dualDepthPeeling/GLHelper.java
@@ -0,0 +1,53 @@
+package demos.dualDepthPeeling;
+
+
+// Translated from C++ Version see below:
+//
+// GLSLProgramObject.h - Wrapper for GLSL program objects
+//
+// Author: Louis Bavoil
+// Email: sdkfeedback@nvidia.com
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+////////////////////////////////////////////////////////////////////////////////
+import javax.media.opengl.GL2;
+
+public class GLHelper
+{
+	public static void setTextureUnit(GL2 gl, int progId, String texname, int texunit)
+	{
+		int[] params = new int[]{0};
+		gl.glGetProgramiv( progId, GL2.GL_LINK_STATUS, params, 0);
+		if ( params[0] != 1 ) {
+			System.err.println( "Error: setTextureUnit needs program to be linked.");
+		}
+		int id = gl.glGetUniformLocation(progId, texname );
+		if (id == -1) {
+			System.err.println( "Warning: Invalid texture " + texname );
+			return;
+		}
+		gl.glUniform1i(id, texunit);
+	}
+
+
+	public static void bindTexture(GL2 gl, int target, int texid, int texUnit)
+	{
+		gl.glActiveTexture(GL2.GL_TEXTURE0 + texUnit);
+		gl.glBindTexture(target, texid);
+		gl.glActiveTexture(GL2.GL_TEXTURE0);
+	}
+
+
+	public static void bindTexture2D(GL2 gl, int texid, int texUnit) {
+		bindTexture(gl, GL2.GL_TEXTURE_2D, texid, texUnit);
+	}
+
+	public static void bindTexture3D(GL2 gl, int texid, int texUnit) {
+		bindTexture(gl, GL2.GL_TEXTURE_3D, texid, texUnit);
+	}
+
+	// g_shaderDualPeel.bindTextureRECT(gl, g_shaderState, s_DepthBlenderTex, g_dualDepthTexId[prevId]);
+	public static void bindTextureRECT(GL2 gl, int texid, int texUnit) {
+		bindTexture(gl, GL2.GL_TEXTURE_RECTANGLE_ARB, texid, texUnit);
+	}
+};
-- 
cgit v1.2.3