root/OpenSceneGraph/trunk/src/osg/PolygonMode.cpp @ 13041

Revision 13041, 2.0 kB (checked in by robert, 3 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#include <osg/GL>
14#include <osg/PolygonMode>
15#include <osg/Notify>
16
17using namespace osg;
18
19PolygonMode::PolygonMode():
20    _modeFront(FILL),
21    _modeBack(FILL)
22{
23}
24
25PolygonMode::PolygonMode(Face face,Mode mode):
26    _modeFront(FILL),
27    _modeBack(FILL)
28{
29    setMode(face,mode);
30}
31
32
33PolygonMode::~PolygonMode()
34{
35}
36
37void PolygonMode::setMode(Face face,Mode mode)
38{
39    switch(face)
40    {
41        case(FRONT):
42            _modeFront = mode;
43            break;
44        case(BACK):
45            _modeBack = mode;
46            break;
47        case(FRONT_AND_BACK):
48            _modeFront = mode;
49            _modeBack = mode;
50            break;
51    }
52}
53
54PolygonMode::Mode PolygonMode::getMode(Face face) const
55{
56    switch(face)
57    {
58        case(FRONT):
59            return _modeFront;
60        case(BACK):
61            return _modeBack;
62        case(FRONT_AND_BACK):
63            return _modeFront;
64    }
65    OSG_WARN<<"Warning : invalid Face passed to PolygonMode::getMode(Face face)"<<std::endl;
66    return _modeFront;
67}
68
69void PolygonMode::apply(State&) const
70{
71#ifdef OSG_GL1_AVAILABLE
72    if (_modeFront==_modeBack)
73    {
74        glPolygonMode(GL_FRONT_AND_BACK,(GLenum)_modeFront);
75    }
76    else
77    {
78        glPolygonMode(GL_FRONT,(GLenum)_modeFront);
79        glPolygonMode(GL_BACK,(GLenum)_modeBack);
80    }
81#else
82    OSG_NOTICE<<"Warning: PolygonMode::apply(State&) - not supported."<<std::endl;
83#endif
84}
Note: See TracBrowser for help on using the browser.