Lighting with VBO

Posted by nkint on Game Development See other posts from Game Development or by nkint
Published on 2012-05-31T16:05:33Z Indexed on 2012/05/31 16:51 UTC
Read the original article Hit count: 260

Filed under:
|
|

I'm using a Java JOGL wrapper called processing.org. I have coded some enviroment on it and I'm quite proud of it even if it has some ready stuffs that I didn't know anything about it (==LIGHTS).

Then, for some geometry, I've decided to use a VBO. I had to pass in the hard way and recode all lights. But I can't achieve the same result.

This is the original light system: enter image description here

And this with VBO:

enter image description here

With this code:

Vec3D l;

gl.glEnable(GL.GL_LIGHTING);
gl.glEnable(GL.GL_LIGHT0);
gl.glEnable(GL.GL_COLOR_MATERIAL);
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, new float[]{0.8f,0f,0f}, 0);

l = new Vec3D(0,0,-10);
gl.glColor3f(0.8f,0f,0f);
gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, new float[] { l.x, l.y, l.z, 0 }, 0);
gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPOT_DIRECTION, new float[] { 1, 1, 1, 1 }, 0);

I can't achive the same light, the same color material, and the same wireframe stuffs.

If needed I can also post the code I use for VBO, but it is quite standard vertex array grabbed on the net that uses glDrawArrays

© Game Development or respective owner

Related posts about jogl

Related posts about vertex-arrays