(LWJGL) Pixel Unpack Buffer Object is Disabled? (glTextImage2D)

Posted by OstlerDev on Game Development See other posts from Game Development or by OstlerDev
Published on 2014-03-15T20:55:13Z Indexed on 2014/05/29 4:06 UTC
Read the original article Hit count: 291

Filed under:
|
|

I am trying to create a render target for my game so that I can re-render at a different screen size. But I am receiving the following error:

Exception in thread "main" org.lwjgl.opengl.OpenGLException: Cannot use offsets when Pixel Unpack Buffer Object is disabled

Here is the source code for my Render method:

    // clear screen
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    // Start FBO Rendering Code
    // The framebuffer, which regroups 0, 1, or more textures, and 0 or 1 depth buffer.
    int FramebufferName = GL30.glGenFramebuffers();
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, FramebufferName);

    // The texture we're going to render to
    int renderedTexture = glGenTextures();

    // "Bind" the newly created texture : all future texture functions will modify this texture
    glBindTexture(GL_TEXTURE_2D, renderedTexture);

    // Give an empty image to OpenGL ( the last "0" )
    glTexImage2D(GL_TEXTURE_2D, 0,GL_RGB, 1024, 768, 0,GL_RGB, GL_UNSIGNED_BYTE, 0);

    // Poor filtering. Needed !
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

    // Set "renderedTexture" as our colour attachement #0
    GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, renderedTexture, 0);

    // Set the list of draw buffers.
    IntBuffer drawBuffer = BufferUtils.createIntBuffer(20 * 20);
    GL20.glDrawBuffers(drawBuffer);

    // Always check that our framebuffer is ok
    if(GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER) != GL30.GL_FRAMEBUFFER_COMPLETE){
        System.out.println("Framebuffer was not created successfully! Exiting!");
        return;
    }



    // Resets the current viewport
    GL11.glViewport(0, 0, scaleWidth*scale, scaleHeight*scale);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    // let subsystem paint
    if (callback != null) {
        callback.frameRendering();
    }



    // update window contents
    Display.update();

It is crashing on this line:

glTexImage2D(GL_TEXTURE_2D, 0,GL_RGB, 1024, 768, 0,GL_RGB, GL_UNSIGNED_BYTE, 0);

I am not really sure why it is crashing and looking around I have not been able to find out why. Any help or insight would be greatly welcome.

© Game Development or respective owner

Related posts about opengl

Related posts about lwjgl