Example usage for org.lwjgl.opengl GL30 GL_RENDERBUFFER

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

Introduction

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

Prototype

int GL_RENDERBUFFER

To view the source code for org.lwjgl.opengl GL30 GL_RENDERBUFFER.

Click Source Link

Document

Accepted by the target parameter of BindRenderbuffer, RenderbufferStorage, and GetRenderbufferParameteriv, and returned by GetFramebufferAttachmentParameteriv.

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.flowpowered.caustic.lwjgl.gl30.GL30FrameBuffer.java

License:MIT License

@Override
public void attach(AttachmentPoint point, RenderBuffer buffer) {
    checkCreated();/*  w w  w  .  ja v  a 2 s  .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();/* ww w .  ja va 2  s .c  om*/
    // 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.flowpowered.caustic.lwjgl.gl30.GL30RenderBuffer.java

License:MIT License

@Override
public void setStorage(InternalFormat format, int width, int height) {
    checkCreated();//from   w w w.j a  va 2 s .  c om
    if (format == null) {
        throw new IllegalArgumentException("Format cannot be null");
    }
    if (width <= 0) {
        throw new IllegalArgumentException("Width must be greater than zero");
    }
    if (height <= 0) {
        throw new IllegalArgumentException("Height must be greater than zero");
    }
    this.format = format;
    this.width = width;
    this.height = height;
    // Bind the render buffer
    GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, id);
    // Set the storage format and size
    GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, format.getGLConstant(), width, height);
    // Unbind the render buffer
    GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, 0);
    // Check for errors
    LWJGLUtil.checkForGLError();
}

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

License:MIT License

@Override
public void bind() {
    checkCreated();//from   w w w . j ava  2s .  c  o m
    // Bind the render buffer
    GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, id);
    // Check for errors
    LWJGLUtil.checkForGLError();
}

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

License:MIT License

@Override
public void unbind() {
    checkCreated();/*from w w w . ja va 2  s. c o  m*/
    // Unbind the render buffer
    GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, 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;/*from   ww  w  .  j a v  a2  s.co 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);
        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;//ww w . java2 s  .  c  om

    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.//from   ww  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:com.samrj.devil.gl.RBO.java

final int tempBind() {
    int oldID = GL11.glGetInteger(GL30.GL_RENDERBUFFER_BINDING);
    if (oldID != id)
        GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, id);
    return oldID;
}