Search code examples
javaopengllibgdxglsl

LibGDX RayHandler: Cannot use offsets when Pixel Unpack Buffer Object is disabled


I recently updated my LibGDX library used in my game by using the LibGDX setup program to create a new project, then importing all of my classes, assets, etc into said new project. Everything went fine, the game runs and I can get in to the main menu. However, when I try advancing to the game where I have Box2DLights, I get an error thrown on the instantiation of my RayHandler. The RayHandler is instantiated like so:

rays = new RayHandler(world, Game.V_WIDTH/LIGHT_PIXEL_SIZE, Game.V_HEIGHT/LIGHT_PIXEL_SIZE);

This worked In the older version of the LibGDX libraries but now it throws Exception in thread "LWJGL Application" org.lwjgl.opengl.OpenGLException: Cannot use offsets when Pixel Unpack Buffer Object is disabled

The old version of LibGDX had GL20 and this one has GL30. I'm not sure if this is relevant because I have little to no knowledge of OpenGL.

Putting the line Gdx.gl.glBindBuffer(GL30.GL_PIXEL_UNPACK_BUFFER, 1); before the instantiation of my RayHandler changed the error to Exception in thread "LWJGL Application" java.lang.IllegalStateException: Frame buffer couldn't be constructed: incomplete attachment. Thrown on the line where my RayHandler is instantiated again.

The entire relevant stack trace for the first error is:

Exception in thread "LWJGL Application" org.lwjgl.opengl.OpenGLException: Cannot use offsets when Pixel Unpack Buffer Object is disabled
    at org.lwjgl.opengl.GLChecks.ensureUnpackPBOenabled(GLChecks.java:125)
    at org.lwjgl.opengl.GL11.glTexImage2D(GL11.java:2899)
    at com.badlogic.gdx.backends.lwjgl.LwjglGL20.glTexImage2D(LwjglGL20.java:598)
    at com.badlogic.gdx.graphics.glutils.GLOnlyTextureData.consumeCustomData(GLOnlyTextureData.java:78)
    at com.badlogic.gdx.graphics.GLTexture.uploadImageData(GLTexture.java:270)
    at com.badlogic.gdx.graphics.GLTexture.uploadImageData(GLTexture.java:257)
    at com.badlogic.gdx.graphics.Texture.load(Texture.java:159)
    at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:147)
    at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:142)
    at com.badlogic.gdx.graphics.glutils.FrameBuffer.createTexture(FrameBuffer.java:81)
    at com.badlogic.gdx.graphics.glutils.FrameBuffer.createTexture(FrameBuffer.java:42)
    at com.badlogic.gdx.graphics.glutils.GLFrameBuffer.build(GLFrameBuffer.java:174)
    at com.badlogic.gdx.graphics.glutils.FrameBuffer.<init>(FrameBuffer.java:75)
    at com.badlogic.gdx.graphics.glutils.FrameBuffer.<init>(FrameBuffer.java:57)
    at box2dLight.LightMap.<init>(LightMap.java:118)
    at box2dLight.RayHandler.resizeFBO(RayHandler.java:143)
    at box2dLight.RayHandler.<init>(RayHandler.java:132)

Solution

  • My question was answered by someone in the LibGDX Discord server. They shared this with me: https://github.com/libgdx/libgdx/issues/6407 Who knew that there could be a bug that isn't my fault? Changing the GDX version from 1.9.14 to 1.9.15-SNAPSHOT fixed the issue.