Java Code Examples for javax.media.opengl.GL#glBindFramebufferEXT()

The following examples show how to use javax.media.opengl.GL#glBindFramebufferEXT() . 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 6 votes vote down vote up
private static void createFrameBufferObject(GL gl, int[] frameBuffer,
                                            int[] colorBuffer, int width,
                                            int height) {
    gl.glGenFramebuffersEXT(1, frameBuffer, 0);
    gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, frameBuffer[0]);

    gl.glGenTextures(1, colorBuffer, 0);
    gl.glBindTexture(GL.GL_TEXTURE_2D, colorBuffer[0]);
    gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA,
                    width, height,
                    0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE,
                    BufferUtil.newByteBuffer(width * height * 4));
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
    gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT,
                                 GL.GL_COLOR_ATTACHMENT0_EXT,
                                 GL.GL_TEXTURE_2D, colorBuffer[0], 0);
    gl.glBindTexture(GL.GL_TEXTURE_2D, 0);

    int status = gl.glCheckFramebufferStatusEXT(GL.GL_FRAMEBUFFER_EXT);
    if (status == GL.GL_FRAMEBUFFER_COMPLETE_EXT) {
        gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0);
    } else {
        throw new IllegalStateException("Frame Buffer Oject not created.");
    }
}
 
Example 2
Source File: BloomOpenGL.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void renderBlur(GL gl, float width, float height) {
    // Draw into the FBO
    gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, frameBufferObject2);
    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

    enableBlurFragmentProgram(gl, blurShader, width, height);
    gl.glBindTexture(GL.GL_TEXTURE_2D, frameBufferTexture1);

    renderTexturedQuad(gl, width, height, texture.getMustFlipVertically());

    gl.glBindTexture(GL.GL_TEXTURE_2D, 0);
    disableFragmentProgram(gl);

    gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0);
}
 
Example 3
Source File: BloomOpenGL.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void renderBrightPass(GL gl, float width, float height) {
    // Draw into the FBO
    gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, frameBufferObject1);
    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    enableBrightPassFragmentProgram(gl, brightPassShader, threshold);
    gl.glBindTexture(GL.GL_TEXTURE_2D, texture.getTextureObject());

    renderTexturedQuad(gl, width, height, texture.getMustFlipVertically());

    gl.glBindTexture(GL.GL_TEXTURE_2D, 0);
    disableFragmentProgram(gl);

    gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0);
}
 
Example 4
Source File: BloomOpenGL.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void renderImage(GL gl, float width, float height) {
    // Draw into the FBO
    gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, frameBufferObject2);
    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

    gl.glBindTexture(GL.GL_TEXTURE_2D, texture.getTextureObject());
    renderTexturedQuad(gl, width, height, texture.getMustFlipVertically());
    gl.glBindTexture(GL.GL_TEXTURE_2D, 0);

    gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0);
}