| 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 | |
|---|
| 14 | #ifndef OSG_SHADEMODEL |
|---|
| 15 | #define OSG_SHADEMODEL 1 |
|---|
| 16 | |
|---|
| 17 | #include <osg/GL> |
|---|
| 18 | #include <osg/StateAttribute> |
|---|
| 19 | |
|---|
| 20 | namespace osg { |
|---|
| 21 | |
|---|
| 22 | #ifndef OSG_GL_FIXED_FUNCTION_AVAILABLE |
|---|
| 23 | #define GL_FLAT 0x1D00 |
|---|
| 24 | #define GL_SMOOTH 0x1D01 |
|---|
| 25 | #endif |
|---|
| 26 | |
|---|
| 27 | /** Class which encapsulates glShadeModel(..). |
|---|
| 28 | */ |
|---|
| 29 | class OSG_EXPORT ShadeModel : public StateAttribute |
|---|
| 30 | { |
|---|
| 31 | public : |
|---|
| 32 | |
|---|
| 33 | enum Mode { |
|---|
| 34 | FLAT = GL_FLAT, |
|---|
| 35 | SMOOTH = GL_SMOOTH |
|---|
| 36 | }; |
|---|
| 37 | |
|---|
| 38 | ShadeModel(Mode mode=SMOOTH); |
|---|
| 39 | |
|---|
| 40 | /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ |
|---|
| 41 | ShadeModel(const ShadeModel& sm,const CopyOp& copyop=CopyOp::SHALLOW_COPY): |
|---|
| 42 | StateAttribute(sm,copyop), |
|---|
| 43 | _mode(sm._mode) {} |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | META_StateAttribute(osg, ShadeModel, SHADEMODEL); |
|---|
| 47 | |
|---|
| 48 | /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/ |
|---|
| 49 | virtual int compare(const StateAttribute& sa) const |
|---|
| 50 | { |
|---|
| 51 | // check the types are equal and then create the rhs variable |
|---|
| 52 | // used by the COMPARE_StateAttribute_Parameter macros below. |
|---|
| 53 | COMPARE_StateAttribute_Types(ShadeModel,sa) |
|---|
| 54 | |
|---|
| 55 | // compare each parameter in turn against the rhs. |
|---|
| 56 | COMPARE_StateAttribute_Parameter(_mode) |
|---|
| 57 | |
|---|
| 58 | return 0; // passed all the above comparison macros, must be equal. |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | inline void setMode(Mode mode) { _mode = mode; } |
|---|
| 62 | |
|---|
| 63 | inline Mode getMode() const { return _mode; } |
|---|
| 64 | |
|---|
| 65 | virtual void apply(State& state) const; |
|---|
| 66 | |
|---|
| 67 | protected: |
|---|
| 68 | |
|---|
| 69 | virtual ~ShadeModel(); |
|---|
| 70 | |
|---|
| 71 | Mode _mode; |
|---|
| 72 | |
|---|
| 73 | }; |
|---|
| 74 | |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | #endif |
|---|