Example usage for org.lwjgl.opengl GL30 GL_FRAMEBUFFER

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

Introduction

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

Prototype

int GL_FRAMEBUFFER

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

Click Source Link

Document

Accepted by the target parameter of BindFramebuffer, CheckFramebufferStatus, FramebufferTexture{1D|2D|3D}, FramebufferRenderbuffer, and GetFramebufferAttachmentParameteriv.

Usage

From source file:com.xrbpowered.gl.res.buffers.MultisampleBuffers.java

License:Open Source License

protected void create(int w, int h, int samples, boolean depthBuffer, boolean hdr) {
    colorMSTexId = GL11.glGenTextures();
    GL11.glBindTexture(GL32.GL_TEXTURE_2D_MULTISAMPLE, colorMSTexId);
    GL32.glTexImage2DMultisample(GL32.GL_TEXTURE_2D_MULTISAMPLE, samples, hdr ? GL30.GL_RGB16F : GL11.GL_RGB, w,
            h, false);/*from  ww w .  j a  v a  2 s  .  com*/
    GL11.glBindTexture(GL32.GL_TEXTURE_2D_MULTISAMPLE, 0);
    GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, colorMSTexId, 0);

    depthMSTexId = 0;
    if (depthBuffer) {
        depthMSTexId = GL11.glGenTextures();
        GL11.glBindTexture(GL32.GL_TEXTURE_2D_MULTISAMPLE, depthMSTexId);
        GL32.glTexImage2DMultisample(GL32.GL_TEXTURE_2D_MULTISAMPLE, samples, GL30.GL_DEPTH24_STENCIL8, w, h,
                false);
        GL11.glBindTexture(GL32.GL_TEXTURE_2D_MULTISAMPLE, 0);
        GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, depthMSTexId, 0);
    }
    checkStatus();
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
}

From source file:com.xrbpowered.gl.res.buffers.OffscreenBuffers.java

License:Open Source License

public OffscreenBuffers(int w, int h, boolean depthBuffer, boolean depthTexture) {
    super(GL30.glGenFramebuffers(), w, h);
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fbo);
    create(w, h, depthBuffer, depthTexture);
}

From source file:com.xrbpowered.gl.res.buffers.OffscreenBuffers.java

License:Open Source License

protected void create(int w, int h, boolean depthBuffer, boolean hdr) {
    colorTexId = GL11.glGenTextures();/* w  w w  .ja  va2  s . co  m*/
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, colorTexId);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, hdr ? GL30.GL_RGB16F : GL11.GL_RGB, w, h, 0, GL11.GL_RGB,
            GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
    GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, colorTexId,
            0);

    depthTexId = 0;
    if (depthBuffer) {
        depthTexId = GL11.glGenTextures();
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, depthTexId);
        GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL14.GL_DEPTH_COMPONENT16, w, h, 0, GL11.GL_DEPTH_COMPONENT,
                GL11.GL_FLOAT, (ByteBuffer) null);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
        GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL11.GL_TEXTURE_2D,
                depthTexId, 0);
    }
    checkStatus();
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
}

From source file:com.xrbpowered.gl.res.buffers.RenderTarget.java

License:Open Source License

public void use() {
    GL11.glViewport(0, 0, getWidth(), getHeight());
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fbo);
}

From source file:com.xrbpowered.gl.res.buffers.RenderTarget.java

License:Open Source License

protected static void checkStatus() {
    int status = GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER);
    if (status != GL30.GL_FRAMEBUFFER_COMPLETE)
        throw new RuntimeException(String.format("Framebuffer not complete: %04X", status));
}

From source file:cuchaz.jfxgl.prism.JFXGLContext.java

License:Open Source License

@Override
public void bindFBO(int nativeFBOID) {
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, nativeFBOID);
}

From source file:cuchaz.jfxgl.prism.JFXGLContext.java

License:Open Source License

@Override
public int createFBO(int texId) {

    int id = GL30.glGenFramebuffers();
    bindFBO(id);/*w w w.  j  a va 2s  .  c o m*/

    if (texId != 0) {

        GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, texId,
                0);

        // check for FBO errors
        String err = getFramebufferError();
        if (err != null) {
            System.err.println("Error creating framebuffer object with texture " + texId + ": " + err);
            return 0;
        }

        // remove garbage from newly-allocated buffers
        createFBOState.backup();
        clearBuffers(Color.TRANSPARENT, true, false, true);
        createFBOState.restore();
    }

    return id;
}

From source file:cuchaz.jfxgl.prism.JFXGLContext.java

License:Open Source License

private static String getFramebufferError() {
    int status = GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER);
    switch (status) {
    case GL30.GL_FRAMEBUFFER_COMPLETE:
        return null;
    case GL30.GL_FRAMEBUFFER_UNSUPPORTED:
        return "GL_FRAMEBUFFER_UNSUPPORTED";
    case GL30.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
        return "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
    case GL30.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
        return "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
    /* doesn't look like we have these constants
    case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
    return "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT";
    case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
    return "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT";
    *//*from   www.j a  v a2  s  . c  o m*/
    case GL30.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
        return "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER";
    case GL30.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
        return "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER";
    case GL30.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
        return "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE";
    default:
        return "(unknown error: " + status + ")";
    }
}

From source file:cuchaz.jfxgl.prism.OffscreenBuffer.java

License:Open Source License

public boolean resize(int width, int height) {

    if (this.width == width && this.height == height) {
        return false;
    }/*from   w  ww.j a v  a 2s . c om*/

    this.width = width;
    this.height = height;

    // resize the texture
    if (texId != 0) {
        context.deleteTexture(texId);
    }
    texId = context.createTexture(width, height);

    // update the framebuf
    if (fboId == 0) {
        fboId = GL30.glGenFramebuffers();
    }
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fboId);
    GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, texId, 0);

    // remove the old quad
    quadDirty = true;

    return true;
}

From source file:de.ikosa.mars.viewer.glviewer.engine.GLRenderer2Stage.java

License:Open Source License

public GLRenderer2Stage(GLScene scene, GLResources resourceManager, GLCamera camera, int width, int height) {
    this.scene = scene;
    this.camera = camera;
    this.width = width;
    this.height = height;

    // setup opengl
    GL11.glViewport(0, 0, width, height);

    // setup framebuffer
    fbAId = GL30.glGenFramebuffers();//from   ww  w.  ja  v a  2 s. c o  m
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fbAId);

    // color buffer
    fbATexId = GLTextureBuilder.createEmptyTexture("FB", width, height, (byte) 0, (byte) 0, (byte) 0, (byte) 0)
            .getTextureId();
    GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, fbATexId,
            0);

    // create depth buffer
    dbATexId = GLTextureBuilder.createEmptyTexture("DB", width, height, 0.0f).getTextureId();
    GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL11.GL_TEXTURE_2D, dbATexId, 0);

    int status = GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER);

    if (status != GL30.GL_FRAMEBUFFER_COMPLETE) {
        ML.f(String.format("Cannot set up framebuffer: %x", status));
    }

    // setup framebuffer B
    fbBId = GL30.glGenFramebuffers();
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fbBId);

    // color buffer
    fbBTexId = GLTextureBuilder.createEmptyTexture("FB", width, height, (byte) 0, (byte) 0, (byte) 0, (byte) 0)
            .getTextureId();
    GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, fbBTexId,
            0);

    status = GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER);

    if (status != GL30.GL_FRAMEBUFFER_COMPLETE) {
        ML.f(String.format("Cannot set up framebuffer: %x", status));
    }

    ssqScene = new GLSSQScene(resourceManager, resourceManager.getShader("post"), new GLTexture("FB", fbATexId),
            new GLTexture("DB", dbATexId), resourceManager.getShader("post2"), new GLTexture("FB2", fbBTexId));
}