Hi, I started with the Nehe07 tutorial but the lights didn't work as I expected I've tried to modify the code but still darkness. What am i doing wrong?
private final static void init() throws Exception {
//texture = loadTexture("data/crate.png");
Keyboard.create(); // Create The Keyboard
GL.glEnable(GL.GL_TEXTURE_2D); // Enable Texture Mapping
GL.glShadeModel(GL.GL_SMOOTH); // Enable Smooth Shading
GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
GL.glClearDepth(1.0); // Depth Buffer Setup
GL.glEnable(GL.GL_DEPTH_TEST); // Enables Depth Testing
GL.glDepthFunc(GL.GL_LEQUAL); // The Type Of Depth Testing To Do
GL.glMatrixMode(GL.GL_PROJECTION); // Select The Projection Matrix
GL.glLoadIdentity(); // Reset The Projection Matrix
// Calculate The Aspect Ratio Of The Window
GLU.gluPerspective(45.0f, (float) Display.getWidth() / (float) Display.getHeight(), 0.1f, 100.0f);
GL.glMatrixMode(GL.GL_MODELVIEW); // Select The Modelview Matrix
// Really Nice Perspective Calculations
GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
ByteBuffer temp = ByteBuffer.allocateDirect(16);
temp.order(ByteOrder.nativeOrder());
GL.glEnable(GL.GL_LIGHTING);
GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, temp.asFloatBuffer(). put(LightAmbient));
GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, temp.asFloatBuffer().put(LightDiffuse));
GL.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, temp.asFloatBuffer().put(Specular));
GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, temp.asFloatBuffer().put(LightPosition));
GL.glEnable(GL.GL_LIGHT0);
GL.glMaterial(GL.GL_FRONT, GL.GL_SPECULAR, temp.asFloatBuffer().put(specref));
GL.glMateriali(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, 100);
GL.glEnable(GL.GL_COLOR_MATERIAL);
GL.glColorMaterial(GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE;
}
cheers