PDA

View Full Version : Lighting



WT
12-05-2001, 11:37 AM
I am trying to use the light models within visual basic. For a start I can only seem to use light0. All the other lights do not seem to be active. Furthermore, when I rotate the my model, the lighting seems to turn on and off.


The four parameters are I believe to be x,y,z position of the light and the 4th one is to indicate whether it is a direction light. Please enlighten me

many thanks

Rob The Bloke
12-05-2001, 11:49 AM
1. Only Light0 has any values initially, the other lights may seem to be off, but infact they haven't had their parameters set, therefore all colour given out is Black, ie, none

2. In order to place a light in world space, you have to transform it with your glRotate* glTranslate* etc.

ie,


glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();

// some matrix transforms

glPushMatrix();

glLightfv( GL_LIGHT0, GL_POSITION, pos);

// draw your world here

glPopMatrix();

// swap your buffers