[JOGL] Starting with frame buffers

Hello everyone,

I’m currently working on a new part of my JOGL project, following tutorials about Framebuffers (this one looks rather good to me). I’m stuck at the very beginning of this tutorial, with a strange status for my framebuffer (1280 does not seem to correspond to any status).

To understand a bit more my problem, here’s how my code looks like :


public static void renderAll(GLAutoDrawable drawable) throws NullPointerException {
    GL3 gl = drawable.getGL().getGL3();
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);
    gl.glClearColor(0.3f, 0.3f, 0.3f, 0);

    // Enabling alpha transparency
    gl.glEnable(GL3.GL_BLEND | GL3.GL_PROGRAM_POINT_SIZE);
    gl.glBlendFunc(GL3.GL_SRC_ALPHA, GL3.GL_ONE_MINUS_SRC_ALPHA);
    gl.glPolygonMode(GL3.GL_FRONT_AND_BACK, isInPlayMode() ? GL3.GL_FILL : GL3.GL_LINE);

    // Updating camera position, direction and zoom
    CameraManager.updateCamera();

    SceneManager.renderIntoFramebuffer(gl, mainWindow.getWidth(), mainWindow.getHeight());

    gl.glFlush();
}

...

SceneManager.renderIntoFramebuffer(GL3 gl, int viewportWidth, int viewportHeight) {
    // Creation of the framebuffer
    IntBuffer idFramebuffer = GLBuffers.newDirectIntBuffer(1);
    gl.glGenFramebuffers(1, idFramebuffer);
    gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, idFramebuffer.get(0));

    // Checking the framebuffer status
    int framebufferStatus = gl.glCheckFramebufferStatus(idFramebuffer.get(0));
    switch (framebufferStatus) {
        case GL3.GL_FRAMEBUFFER_COMPLETE:
            logger.info("Framebuffer is complete :)");
            break;
        case GL3.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
            logger.error("Incomplete attachment");
            break;
        case GL3.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
            logger.error("Incomplete dimensions");
            break;
        case GL3.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
            logger.error("Incomplete draw buffer");
            break;
        case GL3.GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS:
            logger.error("Incomplete layer targets");
            break;
        case GL3.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
            logger.error("Incomplete read buffer");
            break;
        case GL3.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
            logger.error("Missing attachment");
            break;
        case GL3.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
            logger.error("Incomplete multisample");
            break;
        case GL3.GL_FRAMEBUFFER_UNDEFINED:
            logger.error("Undefined");
            break;
        case GL3.GL_FRAMEBUFFER_UNSUPPORTED:
            logger.error("Not supported");
            break;
        default:
            logger.warn("Unknown framebuffer status (" + framebufferStatus + ")");
    }
    gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0);
    gl.glDeleteFramebuffers(1, idFramebuffer);
}

In my logs, the only result I obtain is “Unknown framebuffer status (1280)”.
Do you see anything I could have forgotten / made wrong ?

Thanks in advance for your help :slight_smile:

1280 is GL_INVALID_ENUM

from the doc:

You are passing instead the fbo id/name and that’s why the error

Wow, feeling impressed by the speed at which you spotted the point :o
I’m gonna think about putting your name in the thanks part of my project (if it’s released one day ;D)

Now, I have a Missing attachment error, but it seems far better than this 1280 error code


EDIT :

I just un-commented the part where I was creating a texture and attaching it to the framebuffer and now I get the GL_FRAMEBUFFER_COMPLETE.
Thanks a lot :wink:

Got the same error of your somewhere in the past, it took me a while… and I learnt that