[comp.sys.sgi] Lighting on the PI

loan@Neon.Stanford.EDU (James P. Loan) (09/20/90)

I am having some problems using lighting on our PI 4D/25 (running 3.3).

My gl application has 8 windows, and I want to use the gl lighting
commands on polygonal objects in only one of the windows. Furthermore,
the objects in that window have two modes (wireframe and solid), so I
don't want to waste time with lighting when they are wireframes. In other
words, I want to do lighting in only one of my windows, and only some
of the time.
What I can't figure out is when to call mmode(MVIEWING) and loadmatrix(id_mat),
when to use lmdef to define lights and materials, and when to use lmbind to
activate lighting so that lighting calculations are performed only on my
solid objects in that one window.
I thought this would work:

1. Call lmdef at startup to define lights and materials.
2. When I first open the window in which I want lighting, do:

   mmode(MVIEWING);
   loadmatrix(id_mat);
   lmbind(LIGHT0,1);
   lmbind(LMODEL,1);

3. When it's time to draw a solid, lighted, object, do:

   lmbind(MATERIAL,1);

4. When I'm done drawing the lighted objects, do:

   lmbind(MATERIAL,0);


This doesn't work, but I don't know why. The objects are drawn correctly
the FIRST time, but on the next redraw, the window goes black. Could
someone please help?

Thanks in advance,
pete loan
loan@neon.stanford.edu