I’m not sure what I’m doing wrong but for some reason box2dLight isn’t working on my program. I get the following exceptions when I try and run it:
Exception in thread “LWJGL Application” com.badlogic.gdx.utils.GdxRuntimeException: GL2 is required.
at com.badlogic.gdx.graphics.glutils.FrameBuffer.build(FrameBuffer.java:112)
at com.badlogic.gdx.graphics.glutils.FrameBuffer.(FrameBuffer.java:97)
at box2dLight.LightMap.(LightMap.java:115)
at box2dLight.RayHandler.(RayHandler.java:100)
at box2dLight.RayHandler.(RayHandler.java:78)
at com.me.m.MyGame.create(MyGame.java:30)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
and here is the code I’m using:
import box2dLight.PointLight;
import box2dLight.RayHandler;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.World;
public class MyGame implements ApplicationListener {
World world;
OrthographicCamera camera;
RayHandler handler;
@Override
public void create() {
camera = new OrthographicCamera(800, 480);
camera.translate(400, 240);
camera.update();
world = new World(new Vector2(0, -9.8f), true);
handler = new RayHandler(world);
handler.setCombinedMatrix(camera.combined);
camera.update();
new PointLight(handler, 5000, new Color(1,1,1,1), 100, 100, 100);
}
@Override
public void dispose() {
}
@Override
public void render() {
Gdx.gl.glClearColor(0.5f,0,0,1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
handler.updateAndRender();
world.step(1/60f, 6, 2);
}
@Override
public void resize(int width, int height) {
}
@Override
public void pause() {
}
@Override
public void resume() {
}
}