Java Code Examples for javax.media.opengl.GL#glUseProgramObjectARB()
The following examples show how to use
javax.media.opengl.GL#glUseProgramObjectARB() .
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: BloomOpenGL.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void init(GLAutoDrawable glAutoDrawable) { GL gl = glAutoDrawable.getGL(); if (texture == null) { texture = TextureIO.newTexture(image, false); } // create the blur shader blurShader = createFragmentProgram(gl, new String[] { blurShaderSource }); gl.glUseProgramObjectARB(blurShader); int loc = gl.glGetUniformLocationARB(blurShader, "baseImage"); gl.glUniform1iARB(loc, 0); gl.glUseProgramObjectARB(0); // create the bright-pass shader brightPassShader = createFragmentProgram(gl, new String[] { brightPassShaderSource }); gl.glUseProgramObjectARB(brightPassShader); loc = gl.glGetUniformLocationARB(brightPassShader, "baseImage"); gl.glUniform1iARB(loc, 0); gl.glUseProgramObjectARB(0); // create the FBOs if (gl.isExtensionAvailable("GL_EXT_framebuffer_object")) { int[] fboId = new int[1]; int[] texId = new int[1]; createFrameBufferObject(gl, fboId, texId, image.getWidth(), image.getHeight()); frameBufferObject1 = fboId[0]; frameBufferTexture1 = texId[0]; createFrameBufferObject(gl, fboId, texId, image.getWidth(), image.getHeight()); frameBufferObject2 = fboId[0]; frameBufferTexture2 = texId[0]; } }
Example 2
Source File: BloomOpenGL.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void enableBlurFragmentProgram(GL gl, int program, float textureWidth, float textureHeight) { gl.glUseProgramObjectARB(program); int kernelWidth = 5; int kernelHeight = 5; float xoff = 1.0f / textureWidth; float yoff = 1.0f / textureHeight; float[] offsets = new float[kernelWidth * kernelHeight * 2]; int offsetIndex = 0; for (int i = -kernelHeight / 2; i < kernelHeight / 2 + 1; i++) { for (int j = -kernelWidth / 2; j < kernelWidth / 2 + 1; j++) { offsets[offsetIndex++] = j * xoff; offsets[offsetIndex++] = i * yoff; } } int loc = gl.glGetUniformLocationARB(program, "offsets"); gl.glUniform2fv(loc, offsets.length, offsets, 0); float[] values = createGaussianBlurFilter(2); loc = gl.glGetUniformLocationARB(program, "kernelVals"); gl.glUniform1fvARB(loc, values.length, values, 0); }
Example 3
Source File: BloomOpenGL.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void enableBrightPassFragmentProgram(GL gl, int program, float threshold) { gl.glUseProgramObjectARB(program); int loc = gl.glGetUniformLocationARB(program, "brightPassThreshold"); gl.glUniform1fARB(loc, threshold); }
Example 4
Source File: BloomOpenGL.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 4 votes |
private static void disableFragmentProgram(GL gl) { gl.glUseProgramObjectARB(0); }