summaryrefslogtreecommitdiffstats
path: root/src/demos/dualDepthPeeling/GLHelper.java
diff options
context:
space:
mode:
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);
+ }
+};