Java Code Examples for com.jogamp.opengl.GL3#glFramebufferTexture()

The following examples show how to use com.jogamp.opengl.GL3#glFramebufferTexture() . 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: Gl_320_fbo_shadow.java    From jogl-samples with MIT License 6 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(1, framebufferName);

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, textureName.get(0), 0);
        gl3.glDrawBuffer(GL_NONE);
        if (!isFramebufferComplete(gl3, framebufferName.get(0))) {
            return false;
        }
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);
        gl3.glDrawBuffer(GL_BACK);
        if (!isFramebufferComplete(gl3, 0)) {
            return false;
        }

        return true;
    }
 
Example 2
Source File: Gl_320_fbo_integer_blit.java    From jogl-samples with MIT License 6 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(Framebuffer.MAX, framebufferName);

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.RENDERBUFFER), 0);
        if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.RENDER))) {
            return false;
        }
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RESOLVE));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.SPLASHBUFFER), 0);
        if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.RESOLVE))) {
            return false;
        }
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);

        return checkError(gl3, "initFramebuffer");
    }
 
Example 3
Source File: Gl_320_fbo_multisample_explicit.java    From jogl-samples with MIT License 6 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(1, framebufferRenderName);
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferRenderName.get(0));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.MULTISAMPLE_COLORBUFFER),
                0);
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, textureName.get(Texture.MULTISAMPLE_DEPTHBUFFER),
                0);

        if (!isFramebufferComplete(gl3, framebufferRenderName.get(0))) {
            return false;
        }
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);

        return true;
    }
 
Example 4
Source File: Gl_320_fbo_blit.java    From jogl-samples with MIT License 6 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(Framebuffer.MAX, framebufferName);

        gl3.glGenRenderbuffers(1, colorRenderbufferName);
        gl3.glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbufferName.get(0));
        gl3.glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y);

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER));
        gl3.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbufferName.get(0));
        if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.RENDER))) {
            return false;
        }
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RESOLVE));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.COLORBUFFER), 0);
        if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.RESOLVE))) {
            return false;
        }
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);

        return checkError(gl3, "initFramebuffer");
    }
 
Example 5
Source File: Gl_320_fbo_srgb.java    From jogl-samples with MIT License 6 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(1, framebufferName);
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.COLORBUFFER), 0);
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, textureName.get(Texture.RENDERBUFFER), 0);

        if (!isFramebufferComplete(gl3, framebufferName.get(0))) {
            return false;
        }

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);

        int encodingLinear = GL_LINEAR;
        int encodingSRGB = GL_SRGB;

        int[] encoding = {0};
        gl3.glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_BACK_LEFT,
                GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, encoding, 0);

        return true;
    }
 
Example 6
Source File: Gl_320_fbo_multisample_integer.java    From jogl-samples with MIT License 6 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(Framebuffer.MAX, framebufferName);

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.MULTISAMPLE), 0);
        if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.RENDER))) {
            return false;
        }
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RESOLVE));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.COLORBUFFER), 0);
        if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.RESOLVE))) {
            return false;
        }
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);

        return checkError(gl3, "initFramebuffer");
    }
 
Example 7
Source File: Gl_330_blend_rtt.java    From jogl-samples with MIT License 6 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(1, framebufferName);
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));

        for (int i = Texture.R; i <= Texture.B; ++i) {
            gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + (i - Texture.R), texture2dName.get(i), 0);
        }

        int[] drawBuffers = new int[3];
        drawBuffers[0] = GL_COLOR_ATTACHMENT0;
        drawBuffers[1] = GL_COLOR_ATTACHMENT1;
        drawBuffers[2] = GL_COLOR_ATTACHMENT2;

        gl3.glDrawBuffers(3, drawBuffers, 0);

        if (!isFramebufferComplete(gl3, framebufferName.get(0))) {
            return false;
        }

        return checkError(gl3, "initFramebuffer");
    }
 
Example 8
Source File: Gl_320_fbo_srgb_blend.java    From jogl-samples with MIT License 6 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(1, framebufferName);
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.COLORBUFFER), 0);

        if (!isFramebufferComplete(gl3, framebufferName.get(0))) {
            return false;
        }
        int encodingLinear = GL_LINEAR;
        int encodingSRGB = GL_SRGB;

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);
        int[] encoding = {0};
        gl3.glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_BACK_LEFT,
                GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, encoding, 0);

        return true;
    }
 
Example 9
Source File: Gl_320_fbo_depth_multisample.java    From jogl-samples with MIT License 6 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        boolean validated = true;

        gl3.glGenFramebuffers(Framebuffer.MAX, framebufferName);
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.DEPTH_MULTISAMPLE));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, textureName.get(Texture.MULTISAMPLE), 0);
        gl3.glDrawBuffer(GL_NONE);

        if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.DEPTH_MULTISAMPLE))) {
            return false;
        }

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);
        return validated && checkError(gl3, "initFramebuffer");
    }
 
Example 10
Source File: Gl_320_primitive_line_msaa.java    From jogl-samples with MIT License 6 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(Texture.MAX, framebufferName);

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Texture.RENDERBUFFER));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.RENDERBUFFER), 0);

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Texture.COLORBUFFER));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.COLORBUFFER), 0);

        if (!isFramebufferComplete(gl3, framebufferName.get(Texture.RENDERBUFFER))) {
            return false;
        }
        if (!isFramebufferComplete(gl3, framebufferName.get(Texture.COLORBUFFER))) {
            return false;
        }

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);
        return true;
    }
 
Example 11
Source File: Gl_320_fbo_blend.java    From jogl-samples with MIT License 5 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(1, framebufferName);
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.COLORBUFFER), 0);

        if (!isFramebufferComplete(gl3, framebufferName.get(0))) {
            return false;
        }

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);
        return true;
    }
 
Example 12
Source File: Gl_320_fbo_integer.java    From jogl-samples with MIT License 5 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(1, framebufferName);

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.RENDERBUFFER), 0);
        if (!isFramebufferComplete(gl3, framebufferName.get(0))) {
            return false;
        }
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);

        return checkError(gl3, "initFramebuffer");
    }
 
Example 13
Source File: Gl_320_fbo_multisample.java    From jogl-samples with MIT License 5 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(Framebuffer.MAX, framebufferName);

        int[] buffersRender = new int[]{GL_COLOR_ATTACHMENT0};
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.MULTISAMPLE), 0);
        gl3.glDrawBuffers(1, buffersRender, 0);
        if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.RENDER))) {
            return false;
        }
        int[] buffersResolve = new int[]{GL_COLOR_ATTACHMENT0};
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RESOLVE));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.COLORBUFFER), 0);
        gl3.glDrawBuffers(1, buffersResolve, 0);
        if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.RESOLVE))) {
            return false;
        }

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);
        gl3.glDrawBuffer(GL_BACK);
        if (!isFramebufferComplete(gl3, 0)) {
            return false;
        }

        return checkError(gl3, "initFramebuffer");
    }
 
Example 14
Source File: Gl_320_fbo_depth_stencil.java    From jogl-samples with MIT License 5 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(1, framebufferName);
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.COLORBUFFER), 0);
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, textureName.get(Texture.RENDERBUFFER), 0);

        if (!isFramebufferComplete(gl3, framebufferName.get(0))) {
            return false;
        }

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);
        return true;
    }
 
Example 15
Source File: Gl_320_fbo_layered.java    From jogl-samples with MIT License 5 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(1, framebufferName);
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureColorbufferName.get(0), 0);

        if (!isFramebufferComplete(gl3, framebufferName.get(0))) {
            return false;
        }

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);
        return true;
    }
 
Example 16
Source File: Gl_320_fbo_depth.java    From jogl-samples with MIT License 5 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(1, framebufferName);
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, textureName.get(Texture.RENDERBUFFER), 0);
        gl3.glDrawBuffer(GL_NONE);

        if (!isFramebufferComplete(gl3, framebufferName.get(0))) {
            return false;
        }

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);
        return true;
    }
 
Example 17
Source File: Gl_320_fbo_blend_points.java    From jogl-samples with MIT License 5 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(1, framebufferName);
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.COLORBUFFER), 0);

        if (!isFramebufferComplete(gl3, framebufferName.get(0))) {
            return false;
        }

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);
        return true;
    }
 
Example 18
Source File: Gl_320_fbo.java    From jogl-samples with MIT License 5 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(1, framebufferName);
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.COLORBUFFER), 0);
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, textureName.get(Texture.RENDERBUFFER), 0);

        if (!isFramebufferComplete(gl3, framebufferName.get(0))) {
            return false;
        }

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);
        return true;
    }
 
Example 19
Source File: Gl_320_fbo_srgb_decode_ext.java    From jogl-samples with MIT License 5 votes vote down vote up
private boolean initFramebuffer(GL3 gl3) {

        gl3.glGenFramebuffers(1, framebufferName);
        gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.COLORBUFFER), 0);
        gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, textureName.get(Texture.RENDERBUFFER), 0);

        if (!isFramebufferComplete(gl3, framebufferName.get(0))) {
            return false;
        }

        gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0);
        return true;
    }
 
Example 20
Source File: GraphDisplayer.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
public void init(GLAutoDrawable drawable) {
    final GL3 gl = drawable.getGL().getGL3();

    String graphVp = null;
    String graphFp = null;
    try {
        graphVp = getVertexShader();
        graphFp = getFragmentShader();
    } catch (final IOException ex) {
        LOGGER.log(Level.SEVERE, "Can''t read graph texture shaders", ex);
    }
    graphTextureShader = GLTools.loadShaderSourceWithAttributes(gl, "graphTex", graphVp, null, graphFp,
            vertexTarget, "position",
            textureCoordinatesTarget, "inputTextureCoordinates",
            ShaderManager.FRAG_BASE, "fragColor");

    graphTextureBatch.initialise(GRAPH_TEXTURE_NUMBER_OF_VERTICES);
    graphTextureBatch.stage(vertexTarget, -1f, -1f);
    graphTextureBatch.stage(vertexTarget, 1f, -1f);
    graphTextureBatch.stage(vertexTarget, -1f, 1f);
    graphTextureBatch.stage(vertexTarget, 1f, 1f);
    graphTextureBatch.stage(textureCoordinatesTarget, 0f, 0f);
    graphTextureBatch.stage(textureCoordinatesTarget, 1f, 0f);
    graphTextureBatch.stage(textureCoordinatesTarget, 0f, 1f);
    graphTextureBatch.stage(textureCoordinatesTarget, 1f, 1f);
    graphTextureBatch.finalise(gl);

    // Create the FBO to draw the graph onto.
    gl.glGenFramebuffers(1, graphFboName, 0);
    gl.glBindFramebuffer(GL3.GL_DRAW_FRAMEBUFFER, graphFboName[0]);

    // Create a texture for colour information.
    gl.glGenTextures(1, graphColorTextureName, 0);
    gl.glBindTexture(GL3.GL_TEXTURE_2D, graphColorTextureName[0]);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
    gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA8, 10, 10, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, null);
    gl.glFramebufferTexture(GL3.GL_DRAW_FRAMEBUFFER, GL3.GL_COLOR_ATTACHMENT0, graphColorTextureName[0], 0);
    graphDrawBuffers[0] = GL3.GL_COLOR_ATTACHMENT0;

    // Create a texture for depth information and attach it.
    gl.glGenTextures(1, graphDepthTextureName, 0);
    gl.glBindTexture(GL3.GL_TEXTURE_2D, graphDepthTextureName[0]);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
    gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_DEPTH_COMPONENT16, 10, 10, 0, GL3.GL_DEPTH_COMPONENT, GL.GL_FLOAT, null);
    gl.glFramebufferTexture(GL3.GL_DRAW_FRAMEBUFFER, GL3.GL_DEPTH_ATTACHMENT, graphDepthTextureName[0], 0);

    graphColorTextureShaderLocation = gl.glGetUniformLocation(graphTextureShader, "graphTexture");
    graphDepthTextureShaderLocation = gl.glGetUniformLocation(graphTextureShader, "depthTexture");
    createShaderLocations(gl);
}