0

我将 Box2DLights 与 LibGDX 一起使用。但是每次我运行应用程序时,只会弹出一帧,并且会立即抛出异常:

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)

在我的 RenderingSystem(我使用 ashley 的 ECS 方法)中,这是我的构造函数:

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);

    }

在我正在做渲染的更新方法中:

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

我不知道如何修复甚至如何解释这个错误。

4

0 回答 0