home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / sgi / graphics / 61 < prev    next >
Encoding:
Internet Message Format  |  1992-12-23  |  1.7 KB

  1. Path: sparky!uunet!paladin.american.edu!darwin.sura.net!sgiblab!sgigate!sgi!fido!krypton!gavin
  2. From: gavin@krypton.asd.sgi.com (Gavin Bell)
  3. Newsgroups: comp.sys.sgi.graphics
  4. Subject: Re: Setting Material Color
  5. Date: 23 Dec 1992 22:15:56 GMT
  6. Organization: Silicon Graphics, Inc.  Mountain View, CA
  7. Lines: 40
  8. Message-ID: <1haoesINN897@fido.asd.sgi.com>
  9. References: <7671@dove.nist.gov>
  10. NNTP-Posting-Host: krypton.asd.sgi.com
  11.  
  12. In <7671@dove.nist.gov> fred@poly2.nist.gov (Frederick R. Phelan Jr.) writes:
  13. >Suppose you have a material color:
  14. >float object_color[] = 
  15. >{
  16. >        DIFFUSE,    0.1, 1.0, 0.2,
  17. >        SPECULAR,   0.3, 0.9, 0.3,
  18. >        EMISSION,   1.0, 0.1, 1.0,
  19. >        SHININESS,  24.0,
  20. >        LMNULL 
  21. >};
  22. >which has been set with:
  23. >    lmdef(DEFMATERIAL, 1, 15, object_color);
  24. >First, are you allowed to change the EMISSION values (or really any
  25. >of object_color's properties) on the fly?  
  26.  
  27. Yes.  Use lmcolor(LMC_EMISSION) if you are only changing that one
  28. property, and use c3f() or cpack() commands to change it.
  29.  
  30. >Second, If you can change on the fly, do you need to do a new call to
  31. >lmdef every time for the changes to take effect or is the first call
  32. >sufficient?
  33.  
  34. Changing the value in the array is not sufficient-- you need to send
  35. the values to the GL.  Use lmcolor() if you can, or just issue another
  36. lmdef() with just the values you are changing:
  37.  
  38. float object_emission[] = { EMISSION, 0.2, 0.5, 0.1, LMNULL };
  39. lmdef(DEFMATERIAL, 1, 5, object_emission);
  40.  
  41. In OpenGL, this is much simpler-- material properties are just like
  42. colors.  You set them and forget them.
  43.  
  44. So, in OpenGL, your code will look like:
  45.  
  46. float emission[3] = { 1.0, 0.1, 1.0 };
  47. glMaterialfv(GL_FRONT, GL_EMISSION, emission);
  48.  
  49. ... no bind necessary.
  50. --
  51. --gavin     (gavin@sgi.com,  (415)390-1024)
  52.