LibGDX与Box2DLights:如何修复"数组缓冲区对象" -Exception?

时间:2017-07-05 20:42:52

标签: java libgdx box2d box2dlights

我将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)

在我的渲染系统中(我使用与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();
}

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

0 个答案:

没有答案