root/OpenSceneGraph/trunk/include/osg/PolygonMode @ 13041

Revision 13041, 2.5 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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_POLYGONMODE
15#define OSG_POLYGONMODE 1
16
17#include <osg/StateAttribute>
18#include <osg/GL>
19
20#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
21    #define GL_POINT    0x1B00
22    #define GL_LINE     0x1B01
23    #define GL_FILL     0x1B02
24#endif
25
26namespace osg {
27
28/** State Class for setting OpenGL's polygon culling mode.
29*/
30class OSG_EXPORT PolygonMode : public StateAttribute
31{
32    public :
33
34        enum Mode {
35            POINT = GL_POINT,
36            LINE = GL_LINE,
37            FILL = GL_FILL
38        };
39
40        enum Face {
41            FRONT_AND_BACK,
42            FRONT,
43            BACK
44        };
45
46        PolygonMode();
47
48        PolygonMode(Face face,Mode mode);
49
50        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
51        PolygonMode(const PolygonMode& pm,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
52            StateAttribute(pm,copyop),
53            _modeFront(pm._modeFront),
54            _modeBack(pm._modeBack) {}
55
56        META_StateAttribute(osg, PolygonMode, POLYGONMODE);
57
58        /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
59        virtual int compare(const StateAttribute& sa) const
60        {
61            // check the types are equal and then create the rhs variable
62            // used by the COMPARE_StateAttribute_Parameter macros below.
63            COMPARE_StateAttribute_Types(PolygonMode,sa)
64
65            // compare each parameter in turn against the rhs.
66            COMPARE_StateAttribute_Parameter(_modeFront)
67            COMPARE_StateAttribute_Parameter(_modeBack)
68
69            return 0; // passed all the above comparison macros, must be equal.
70        }
71
72        void setMode(Face face,Mode mode);
73        Mode getMode(Face face) const;
74
75        inline bool getFrontAndBack() const { return _modeFront==_modeBack; }
76
77        virtual void apply(State& state) const;
78
79    protected:
80
81        virtual ~PolygonMode();
82
83        Mode _modeFront;
84        Mode _modeBack;
85
86};
87
88}
89
90#endif
Note: See TracBrowser for help on using the browser.