PDA

View Full Version : Lighting problem,



dreamspaced
10-18-2005, 05:32 AM
Hi,

Can you see a problem with this code that generates normals for a mesh? With lighting mode 1 (i.e GL_Light_position x,y,z,1) it works on one side of the plane , but not the other) with a mode of 0, it appreas to work on curve surfaces but no on flat surfaces)

Here's the code I use to set up gl lights,

</font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">namespace Vivid3D
{
public class Light : Pivot
{
public int glLight, lightObj;
public static int[] lstack = new int[8];
public static int[] GL_Light = new int[8];
public static void SetupLights()
{
GL_Light[0] = Gl.GL_LIGHT0;
GL_Light[1] = Gl.GL_LIGHT1;
GL_Light[2] = Gl.GL_LIGHT2;
GL_Light[3] = Gl.GL_LIGHT3;
GL_Light[4] = Gl.GL_LIGHT4;
GL_Light[5] = Gl.GL_LIGHT5;
GL_Light[6] = Gl.GL_LIGHT6;
GL_Light[7] = Gl.GL_LIGHT7;
}
public static int RequestLight()
{
for (int j = 0; j < 8; j++)
{
if (lstack[j] == 0)
{
lstack[j] = 1;
Gl.glEnable(GL_Light[j]);
return j;
}
}

return -1;
}
public static void FreeLight(int light)
{
if (light < 0

mikael_aronsson
10-18-2005, 10:46 PM
Well, the code you posted has nothing to do with normals, and lighting problems can many times be caused by incorrect normals, so the first thing to do is to check your normals to see if they are correct.

Mikael