ShadeModel 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
  2. *
  3. * This library is open source and may be redistributed and/or modified under
  4. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * OpenSceneGraph Public License for more details.
  12. */
  13. #ifndef OSG_SHADEMODEL
  14. #define OSG_SHADEMODEL 1
  15. #include <osg/GL>
  16. #include <osg/StateAttribute>
  17. namespace osg {
  18. #ifndef OSG_GL_FIXED_FUNCTION_AVAILABLE
  19. #define GL_FLAT 0x1D00
  20. #define GL_SMOOTH 0x1D01
  21. #endif
  22. /** Class which encapsulates glShadeModel(..).
  23. */
  24. class OSG_EXPORT ShadeModel : public StateAttribute
  25. {
  26. public :
  27. enum Mode {
  28. FLAT = GL_FLAT,
  29. SMOOTH = GL_SMOOTH
  30. };
  31. ShadeModel(Mode mode=SMOOTH);
  32. /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
  33. ShadeModel(const ShadeModel& sm,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
  34. StateAttribute(sm,copyop),
  35. _mode(sm._mode) {}
  36. META_StateAttribute(osg, ShadeModel, SHADEMODEL);
  37. /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
  38. virtual int compare(const StateAttribute& sa) const
  39. {
  40. // check the types are equal and then create the rhs variable
  41. // used by the COMPARE_StateAttribute_Parameter macros below.
  42. COMPARE_StateAttribute_Types(ShadeModel,sa)
  43. // compare each parameter in turn against the rhs.
  44. COMPARE_StateAttribute_Parameter(_mode)
  45. return 0; // passed all the above comparison macros, must be equal.
  46. }
  47. inline void setMode(Mode mode) { _mode = mode; }
  48. inline Mode getMode() const { return _mode; }
  49. virtual void apply(State& state) const;
  50. protected:
  51. virtual ~ShadeModel();
  52. Mode _mode;
  53. };
  54. }
  55. #endif