box2dlight + libgdx -> cant get it to work (SOLVED)

Hello peeps, I started to create a 2D topdown Tilebased Game and i wanted to add some lightning.

I found this tut:http://voodoobits.blogspot.de/2012/04/and-there-was-light.html
but i could not get it to work.

at this place:


light_world = new com.badlogic.gdx.physics.box2d.World(new Vector2(), true);
RayHandler.useDiffuseLight(true);
rayHandler = new RayHandler(light_world); // <----- this one

i get an Exception and that was it then :confused:

here is what my eclipse says :

Exception in thread “LWJGL Application” com.badlogic.gdx.utils.GdxRuntimeException: java.lang.IllegalArgumentException: color attribute must have 4 components
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:113)
Caused by: java.lang.IllegalArgumentException: color attribute must have 4 components
at com.badlogic.gdx.graphics.VertexAttributes.checkValidity(VertexAttributes.java:104)
at com.badlogic.gdx.graphics.VertexAttributes.(VertexAttributes.java:52)
at com.badlogic.gdx.graphics.glutils.VertexArray.(VertexArray.java:53)
at com.badlogic.gdx.graphics.Mesh.(Mesh.java:99)
at box2dLight.RayHandler.(RayHandler.java:120)
at box2dLight.RayHandler.(RayHandler.java:87)
at de.vdb.tiledmapgametest.LightRenderer.(LightRenderer.java:30)
at de.vdb.tiledmapgametest.WorldRenderer.drawLight(WorldRenderer.java:93)
at de.vdb.tiledmapgametest.WorldRenderer.render(WorldRenderer.java:86)
at de.vdb.tiledmapgametest.Gamescreen.render(Gamescreen.java:97)
at com.badlogic.gdx.Game.render(Game.java:46)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:187)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:110)

i am using the stable libgdx 0.9.8

maybe somebody around here may have an idea :smiley:

btw. the light_world is filled somewhere else after that piece of code but as far as i can see that is nothing i have to care about at this place right? ::slight_smile:

edit: got the line of code where it all goes to valhalla x.x its in libgdx :
com.badlogic.gdx.graphics.VertexAttributes Line 104


if (attribute.usage == Usage.Color || attribute.usage == Usage.ColorPacked) {
				if (attribute.numComponents != 4) throw new IllegalArgumentException("color attribute must have 4 components"); // <--- this one :D

				if (cols) throw new IllegalArgumentException("two color attributes were specified");
				cols = true;
			}

while debugging i found out that i have got 2 attributes vertex positions and color color got 4 args thats ok but here the color attribute got the usage code 4 and the positions 1 libgdx is asking for code 1 as color code and then it runs into 2 components not 4 after that -> crash x.x

edit 2 :

Okay now i can see that box2dlights uses the Usage class of libgdx and takes Usage.Position for the position attributes and Usage.ColorPacked for the Color so far its okay but now at Runtime i got the code 1 for the pos attribute and it is recognized as a color, but for the position the code 0 is used in my libgdx o.O seems like in my libgdx there are other codes used then in box2dlight ill try to change from stable to nightly if that fixes my bug ill report back soon :stuck_out_tongue:

edit 3:

after a break and updating my libs to the nightly build its working now :smiley:

sorry for spamming your forum xD but i did not know that i can fix it on my own :stuck_out_tongue: just started my apprenticeship this month as a programmer ^^