Example usage for org.lwjgl.opengl GL30 glFramebufferRenderbuffer

List of usage examples for org.lwjgl.opengl GL30 glFramebufferRenderbuffer

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL30 glFramebufferRenderbuffer.

Prototype

public static void glFramebufferRenderbuffer(@NativeType("GLenum") int target,
        @NativeType("GLenum") int attachment, @NativeType("GLenum") int renderbuffertarget,
        @NativeType("GLuint") int renderbuffer) 

Source Link

Document

Attaches a renderbuffer as a logical buffer to the currently bound framebuffer object.

Usage

From source file:com.adavr.player.globjects.Framebuffer.java

License:Open Source License

public void attachRenderBuffer(int renderBuffer) {
    GL30.glFramebufferRenderbuffer(target, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER, renderBuffer);
}

From source file:com.badlogic.gdx.backends.jglfw.JglfwGL30.java

License:Apache License

@Override
public void glFramebufferRenderbuffer(int target, int attachment, int renderbuffertarget, int renderbuffer) {
    GL30.glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
}

From source file:com.flowpowered.caustic.lwjgl.gl30.GL30FrameBuffer.java

License:MIT License

@Override
public void attach(AttachmentPoint point, RenderBuffer buffer) {
    checkCreated();/*from   w w  w  .ja va 2s.c om*/
    CausticUtil.checkVersion(this, buffer);
    buffer.checkCreated();
    // Bind the frame buffer
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, id);
    // Attach the render buffer
    GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, point.getGLConstant(), GL30.GL_RENDERBUFFER,
            buffer.getID());
    // Add it to the color outputs if it's a color type
    if (point.isColor()) {
        outputBuffers.add(point.getGLConstant());
    }
    // Update the list of output buffers
    updateOutputBuffers();
    // Unbind the frame buffer
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
    // Check for errors
    LWJGLUtil.checkForGLError();
}

From source file:com.flowpowered.caustic.lwjgl.gl30.GL30FrameBuffer.java

License:MIT License

@Override
public void detach(AttachmentPoint point) {
    checkCreated();//  w w w  .ja  v  a2s.c  o  m
    // Bind the frame buffer
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, id);
    // Detach the render buffer
    GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, point.getGLConstant(), GL30.GL_RENDERBUFFER, 0);
    // Remove it from the color outputs if it's a color type
    if (point.isColor()) {
        outputBuffers.remove(point.getGLConstant());
    }
    // Update the list of output buffers
    updateOutputBuffers();
    // Unbind the frame buffer
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
    // Check for errors
    LWJGLUtil.checkForGLError();
}

From source file:com.mtbs3d.minecrift.FBOParams.java

License:LGPL

public FBOParams(String fboName, int textureType, int internalFormat, int baseFormat, int bufferType,
        int fboWidth, int fboHeight) throws Exception {
    Minecraft mc = Minecraft.getMinecraft();
    _textureType = textureType;/* w w  w.j  a  v  a2  s  . com*/

    if (fboSupport == FBO_SUPPORT.USE_EXT_UNKNOWN) {
        // The framebuffer, which regroups 0, 1, or more textures, and 0 or 1 depth buffer.
        try {
            _frameBufferId = GL30.glGenFramebuffers();
            fboSupport = FBO_SUPPORT.USE_GL30;
        } catch (IllegalStateException ex) {
            System.out.println(
                    "[Minecrift] FBO creation: GL30.glGenFramebuffers not supported. Attempting to use EXTFramebufferObject.glGenFramebuffersEXT");
            fboSupport = FBO_SUPPORT.USE_EXT;

            try {
                _frameBufferId = EXTFramebufferObject.glGenFramebuffersEXT();
            } catch (IllegalStateException ex1) {
                System.out.println(
                        "[Minecrift] FBO creation: EXTFramebufferObject.glGenFramebuffersEXT not supported, FBO creation failed.");
                throw ex1;
            }
        }
    } else if (fboSupport == FBO_SUPPORT.USE_GL30) {
        _frameBufferId = GL30.glGenFramebuffers();
    } else {
        _frameBufferId = EXTFramebufferObject.glGenFramebuffersEXT();
    }

    if (fboSupport == FBO_SUPPORT.USE_GL30) {
        _colorTextureId = GL11.glGenTextures();
        _depthRenderBufferId = GL30.glGenRenderbuffers();

        GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, _frameBufferId);
        checkGLError("FBO bind framebuffer");

        GL11.glBindTexture(textureType, _colorTextureId);
        checkGLError("FBO bind texture");

        GL11.glEnable(textureType);
        GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
        GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
        GL11.glTexImage2D(textureType, 0, internalFormat, fboWidth, fboHeight, 0, baseFormat, bufferType,
                (java.nio.ByteBuffer) null);

        System.out.println("[Minecrift] FBO '" + fboName + "': w: " + fboWidth + ", h: " + fboHeight);

        GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, textureType,
                _colorTextureId, 0);

        checkGLError("FBO bind texture framebuffer");

        GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, _depthRenderBufferId); // bind the depth renderbuffer
        GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL14.GL_DEPTH_COMPONENT24, fboWidth, fboHeight); // get the data space for it
        GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER,
                _depthRenderBufferId);
        checkGLError("FBO bind depth framebuffer");
    } else {
        _colorTextureId = GL11.glGenTextures();
        _depthRenderBufferId = EXTFramebufferObject.glGenRenderbuffersEXT();

        EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, _frameBufferId);
        checkGLError("FBO bind framebuffer");

        GL11.glBindTexture(textureType, _colorTextureId);
        checkGLError("FBO bind texture");

        GL11.glEnable(textureType);
        GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
        GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
        GL11.glTexImage2D(textureType, 0, internalFormat, fboWidth, fboHeight, 0, baseFormat, bufferType,
                (java.nio.ByteBuffer) null);
        System.out.println("[Minecrift] FBO '" + fboName + "': w: " + fboWidth + ", h: " + fboHeight);

        EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
                EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, textureType, _colorTextureId, 0);

        checkGLError("FBO bind texture framebuffer");

        EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT,
                _depthRenderBufferId); // bind the depth renderbuffer
        EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT,
                GL14.GL_DEPTH_COMPONENT24, fboWidth, fboHeight); // get the data space for it
        EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
                EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT,
                _depthRenderBufferId);
        checkGLError("FBO bind depth framebuffer");
    }

    if (!checkFramebufferStatus()) {
        // OK, if we have an error here - then throw an exception
        System.out.println("[Minecrift] FAILED to create framebuffer!!");
        throw new Exception("Failed to create framebuffer");
    }
}

From source file:com.mtbs3d.minecrift.render.FBOParams.java

License:LGPL

public FBOParams(String fboName, int textureType, int internalFormat, int baseFormat, int bufferType,
        int fboWidth, int fboHeight) throws Exception {
    Minecraft mc = Minecraft.getMinecraft();
    _textureType = textureType;//  w  ww . j  a va2s . c o m

    if (fboSupport == FBO_SUPPORT.USE_EXT_UNKNOWN) {
        // The framebuffer, which regroups 0, 1, or more textures, and 0 or 1 depth buffer.
        try {
            _frameBufferId = GL30.glGenFramebuffers();
            fboSupport = FBO_SUPPORT.USE_GL30;
        } catch (IllegalStateException ex) {
            System.out.println(
                    "[Minecrift] FBO creation: GL30.glGenFramebuffers not supported. Attempting to use EXTFramebufferObject.glGenFramebuffersEXT");
            fboSupport = FBO_SUPPORT.USE_EXT;

            try {
                _frameBufferId = EXTFramebufferObject.glGenFramebuffersEXT();
            } catch (IllegalStateException ex1) {
                System.out.println(
                        "[Minecrift] FBO creation: EXTFramebufferObject.glGenFramebuffersEXT not supported, FBO creation failed.");
                throw ex1;
            }
        }
    } else if (fboSupport == FBO_SUPPORT.USE_GL30) {
        _frameBufferId = GL30.glGenFramebuffers();
    } else {
        _frameBufferId = EXTFramebufferObject.glGenFramebuffersEXT();
    }

    if (fboSupport == FBO_SUPPORT.USE_GL30) {
        _colorTextureId = GL11.glGenTextures();
        _depthRenderBufferId = GL30.glGenRenderbuffers();

        GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, _frameBufferId);
        mc.checkGLError("FBO bind framebuffer");

        GL11.glBindTexture(textureType, _colorTextureId);
        mc.checkGLError("FBO bind texture");

        GL11.glEnable(textureType);
        GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
        GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
        GL11.glTexImage2D(textureType, 0, internalFormat, fboWidth, fboHeight, 0, baseFormat, bufferType,
                (java.nio.ByteBuffer) null);

        //System.out.println("[Minecrift] FBO '" + fboName + "': w: " + fboWidth + ", h: " + fboHeight);

        GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, textureType,
                _colorTextureId, 0);

        mc.checkGLError("FBO bind texture framebuffer");

        GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, _depthRenderBufferId); // bind the depth renderbuffer
        GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL14.GL_DEPTH_COMPONENT24, fboWidth, fboHeight); // get the data space for it
        GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER,
                _depthRenderBufferId);
        mc.checkGLError("FBO bind depth framebuffer");
    } else {
        _colorTextureId = GL11.glGenTextures();
        _depthRenderBufferId = EXTFramebufferObject.glGenRenderbuffersEXT();

        EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, _frameBufferId);
        mc.checkGLError("FBO bind framebuffer");

        GL11.glBindTexture(textureType, _colorTextureId);
        mc.checkGLError("FBO bind texture");

        GL11.glEnable(textureType);
        GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
        GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
        GL11.glTexImage2D(textureType, 0, internalFormat, fboWidth, fboHeight, 0, baseFormat, bufferType,
                (java.nio.ByteBuffer) null);
        //System.out.println("[Minecrift] FBO '" + fboName + "': w: " + fboWidth + ", h: " + fboHeight);

        EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
                EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, textureType, _colorTextureId, 0);

        mc.checkGLError("FBO bind texture framebuffer");

        EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT,
                _depthRenderBufferId); // bind the depth renderbuffer
        EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT,
                GL14.GL_DEPTH_COMPONENT24, fboWidth, fboHeight); // get the data space for it
        EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
                EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT,
                _depthRenderBufferId);
        mc.checkGLError("FBO bind depth framebuffer");
    }

    if (!checkFramebufferStatus()) {
        // OK, if we have an error here - then throw an exception
        System.out.println("[Minecrift] FAILED to create framebuffer!!");
        throw new Exception("Failed to create framebuffer");
    }
}

From source file:com.samrj.devil.gl.FBO.java

License:Open Source License

/**
 * Attaches the given render buffer to this frame buffer. This frame buffer
 * must be bound./*  w w  w.  j  a va 2  s .c  o m*/
 * 
 * @param rbo The render buffer to attach.
 * @param attachment The attachment type.
 */
public void renderBuffer(RBO rbo, int attachment) {
    ensureBound();
    GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, attachment, GL30.GL_RENDERBUFFER, rbo.id);
}

From source file:me.thehutch.fusion.engine.render.opengl.gl30.OpenGL30FrameBuffer.java

License:Open Source License

@Override
public void attachBuffer(int point, RenderBuffer buffer) {
    // Bind the frame buffer
    GL30.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
    // Attach the render buffer to the frame buffer
    GL30.glFramebufferRenderbuffer(GL_FRAMEBUFFER, point, GL_RENDERBUFFER, buffer.getId());
    RenderUtil.checkGLError();//from w ww.  jav a  2s . c om
    // Add the attachment to the outputs if it is a colour type
    if (isColourAttachment(point)) {
        this.outputBuffers.add(point);
    }
    // Update the output buffers
    updateOutputBuffers();
    // Check to see if the frame buffer is complete
    if (GL30.glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
        throw new IllegalStateException("Unable to complete frame buffer!");
    }
    // Unbind the frame buffer
    GL30.glBindFramebuffer(GL_FRAMEBUFFER, 0);

    // Check for errors
    RenderUtil.checkGLError();
}

From source file:me.thehutch.fusion.engine.render.opengl.gl30.OpenGL30FrameBuffer.java

License:Open Source License

@Override
public void detach(int point) {
    // Bind the frame buffer
    GL30.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
    // Detach the render buffer from the frame buffer
    GL30.glFramebufferRenderbuffer(GL_FRAMEBUFFER, point, GL_RENDERBUFFER, 0);
    // Remove the attachment from the outputs if it is a colour type
    if (isColourAttachment(point)) {
        this.outputBuffers.remove(point);
    }/*  www  . ja v a  2s. com*/
    // Update the output buffers
    updateOutputBuffers();
    // Check to see if the frame buffer is complete
    if (GL30.glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
        throw new IllegalStateException("Unable to complete frame buffer!");
    }
    // Unbind the frame buffer
    GL30.glBindFramebuffer(GL_FRAMEBUFFER, 0);

    // Check for errors
    RenderUtil.checkGLError();
}

From source file:net.smert.frameworkgl.opengl.helpers.FrameBufferObjectHelper.java

License:Apache License

public void attachRenderBuffer(int attachment, int rboID) {
    GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, attachment, GL30.GL_RENDERBUFFER, rboID);
}