home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!paladin.american.edu!darwin.sura.net!sgiblab!sgigate!sgi!fido!krypton!gavin
- From: gavin@krypton.asd.sgi.com (Gavin Bell)
- Newsgroups: comp.sys.sgi.graphics
- Subject: Re: Setting Material Color
- Date: 23 Dec 1992 22:15:56 GMT
- Organization: Silicon Graphics, Inc. Mountain View, CA
- Lines: 40
- Message-ID: <1haoesINN897@fido.asd.sgi.com>
- References: <7671@dove.nist.gov>
- NNTP-Posting-Host: krypton.asd.sgi.com
-
- In <7671@dove.nist.gov> fred@poly2.nist.gov (Frederick R. Phelan Jr.) writes:
- >Suppose you have a material color:
- >float object_color[] =
- >{
- > DIFFUSE, 0.1, 1.0, 0.2,
- > SPECULAR, 0.3, 0.9, 0.3,
- > EMISSION, 1.0, 0.1, 1.0,
- > SHININESS, 24.0,
- > LMNULL
- >};
- >which has been set with:
- > lmdef(DEFMATERIAL, 1, 15, object_color);
- >First, are you allowed to change the EMISSION values (or really any
- >of object_color's properties) on the fly?
-
- Yes. Use lmcolor(LMC_EMISSION) if you are only changing that one
- property, and use c3f() or cpack() commands to change it.
-
- >Second, If you can change on the fly, do you need to do a new call to
- >lmdef every time for the changes to take effect or is the first call
- >sufficient?
-
- Changing the value in the array is not sufficient-- you need to send
- the values to the GL. Use lmcolor() if you can, or just issue another
- lmdef() with just the values you are changing:
-
- float object_emission[] = { EMISSION, 0.2, 0.5, 0.1, LMNULL };
- lmdef(DEFMATERIAL, 1, 5, object_emission);
-
- In OpenGL, this is much simpler-- material properties are just like
- colors. You set them and forget them.
-
- So, in OpenGL, your code will look like:
-
- float emission[3] = { 1.0, 0.1, 1.0 };
- glMaterialfv(GL_FRONT, GL_EMISSION, emission);
-
- ... no bind necessary.
- --
- --gavin (gavin@sgi.com, (415)390-1024)
-