Hi, I am having trouble with lighting.
Before I go on I have one quick question.
IntBuffer lights = BufferUtils.createIntBuffer(16);
GL11.glGetInteger(GL11.GL_MAX_LIGHTS, lights);
writeLine("Maximum number of light sources: " + lights.get(0));
That code outputs the number 8. I am sure my understanding of OpenGL lights is incorrect but how is possible that I can only create 8 lights? As in, to my understanding, games can create a lot more than 8 lights.
Okay and here is my attempt at setting up lights.
(Perhaps I should have uploaded a larger image) parts of quads are lit up but not others, some corners have two quads lit but not the third.
The room is drawn with 6 quads and texture bound over them (I need to move on to floatBuffers).
Here is the light setup.
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_LIGHT0);
GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, floatBuffer(1.0f, 1.0f, 1.0f, 1.0f));
GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, floatBuffer(0.1f, 0.1f, 0.1f, 1.0f));
GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, floatBuffer(1.0f, 1.0f, 1.0f, 1.0f));
GL11.glLightModeli(GL11.GL_LIGHT_MODEL_TWO_SIDE, GL11.GL_TRUE);
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
GL11.glColorMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_AMBIENT_AND_DIFFUSE);
// For the last line, what is the last float used for? Shouldn't it just be x,y,z?
GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, floatBuffer(-5f, -5f, -5f, 1f));
/* Rendering here. */
public FloatBuffer floatBuffer(float a, float b, float c, float d) {
float[] data = new float[] { a, b, c, d };
FloatBuffer fb = BufferUtils.createFloatBuffer(data.length);
fb.put(data);
fb.flip();
return fb;
}
Perhaps I need to setup normals (I’m not too informed on normals) on my quads?
Thank you for your time and help.