0

I'm using Box2DLights with LibGDX. But everytime I'm running the app, only one frame will pop up and immediately the exception will get thrown like that:

Exception in thread "LWJGL Application" org.lwjgl.opengl.OpenGLException: Cannot use offsets when Array Buffer Object is disabled
    at org.lwjgl.opengl.GLChecks.ensureArrayVBOenabled(GLChecks.java:77)
    at org.lwjgl.opengl.GL20.glVertexAttribPointer(GL20.java:892)
    at com.badlogic.gdx.backends.lwjgl.LwjglGL20.glVertexAttribPointer(LwjglGL20.java:847)
    at com.badlogic.gdx.graphics.glutils.ShaderProgram.setVertexAttribute(ShaderProgram.java:683)
    at com.badlogic.gdx.graphics.glutils.VertexBufferObject.bind(VertexBufferObject.java:190)
    at com.badlogic.gdx.graphics.Mesh.bind(Mesh.java:380)
    at com.badlogic.gdx.graphics.Mesh.bind(Mesh.java:371)
    at com.badlogic.gdx.graphics.Mesh.render(Mesh.java:479)
    at com.badlogic.gdx.graphics.Mesh.render(Mesh.java:422)
    at box2dLight.LightMap.render(LightMap.java:59)
    at box2dLight.RayHandler.render(RayHandler.java:338)
    at box2dLight.RayHandler.updateAndRender(RayHandler.java:269)
    at de.marc_manhart.ecs.entities.systems.RenderingSystem.update(RenderingSystem.java:155)

In my RenderingSystem (I'm using an ECS approach with ashley), this is my constructor:

public RenderingSystem(...) {
        //...       

        // ------ Box2DLights
        RayHandler.setGammaCorrection(true);
        RayHandler.useDiffuseLight(false);       
        this.rayHandler=new RayHandler(this.world);
        this.rayHandler.setBlur(true);
        this.rayHandler.setBlurNum(1);
        this.rayHandler.setShadows(true);
        this.rayHandler.setCulling(true);
        this.rayHandler.setAmbientLight(0.9f);


        // Two PointLights just for test here
        new PointLight(rayHandler, 500, Color.RED, 50, -5, 10);
        new PointLight(rayHandler, 500, new Color(1f, 0.5f, 1f, 1f), 150, 0, 30);

    }

And in update Method where I'm doing the rendering-stuff:

@Override
public void update(float deltaTime) {
        //...
        rayHandler.setCombinedMatrix(gameWorldCam);
        rayHandler.updateAndRender();
        rayHandler.dispose();
}

I have no Idea how to fix or even how to interpret this error.

EchtFettigerKeks
  • 1,692
  • 1
  • 18
  • 33
  • 1
    why are you disposing `rayHandler` in `update()` method ? – Abhishek Aryan Jul 05 '17 at 21:30
  • Yes! That was the error! thanks for that. But unfortunately, now it seems, that doing Box2DLights.renderandupdate at the bottom of my update loop, will break my aspect ratio of my cam... – EchtFettigerKeks Jul 05 '17 at 21:32
  • Se the [box2dlights Wiki](https://github.com/libgdx/box2dlights/wiki/Custom-viewport-and-box2dlights), it should not break the cam if you pre-setup viewport correctly. – Mikhail Churbanov Jul 07 '17 at 14:40

0 Answers0