summaryrefslogtreecommitdiffstats
path: root/src/demos/dualDepthPeeling/GLHelper.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-02-18 18:37:41 +0100
committerSven Gothel <[email protected]>2012-02-18 18:37:41 +0100
commit697d631bc0333b92689972ff3e621e3549fb6c80 (patch)
tree842ce0ed8b2e17c2d187566f7df2679fbb190058 /src/demos/dualDepthPeeling/GLHelper.java
parent390ef63a8da4c3e89b2f61526b641b1b2b82f42d (diff)
JOGL'fy dualDepthPeeling demo (Using JOGL ShaderState/Code/Program)
Diffstat (limited to 'src/demos/dualDepthPeeling/GLHelper.java')
-rw-r--r--src/demos/dualDepthPeeling/GLHelper.java53
1 files changed, 53 insertions, 0 deletions
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
+//
+// 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);
+ }
+};