OpenGL lighting fixes

Kai Habel kai.habel at gmx.de
Mon Feb 2 08:33:04 CST 2009


I am currently working on enabling light (at least for the OpenGL
renderer).  I noticed the following problems with the current code.

1.) To set the material properties (ambient and diffuse reflection) we
have some instances in gl_render.cc with:

for (int i = 0; i < 3; i++)
  cb[i] = (as * fcolor(i));
glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);

for (int i = 0; i < 3; i++)
  cb[i] *= (ds / as);
glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);

As you can see, the calculation of the diffuse reflection fails if as==0.


2.) The surface normals should be calculated when facelighting is set to
'flat' too. In addition we need to normalize here, since we don't do
this in graphics.cc --> surface::properties::update_normals (void) anymore.

So,

if (fl_mode == 2)
  glNormal3d (...);

should be changed into

if (fl_mode > 0)
  glNormal3d (...);

in all cases.

I am cc'ing Michael directly since I would like to have his comment
before someone is applying this changeset.

Kai

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: changeset_gllighting
Url: https://www-old.cae.wisc.edu/pipermail/octave-maintainers/attachments/20090202/2af02525/attachment.ksh 


More information about the Octave-maintainers mailing list