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

Revision 13041, 2.7 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/PolygonStipple>
15#include <osg/Notify>
16
17#include <algorithm>
18
19using namespace osg;
20
21static GLubyte defaultPolygonStippleMask[] =
22{
23    0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
24    0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
25    0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
26    0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
27    0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
28    0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
29    0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
30    0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
31    0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
32    0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
33    0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
34    0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
35    0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
36    0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
37    0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99,
38    0x44, 0x44, 0x44, 0x44, 0x99, 0x99, 0x99, 0x99
39};
40
41PolygonStipple::PolygonStipple()
42{
43    setMask(defaultPolygonStippleMask);
44}
45
46PolygonStipple::PolygonStipple(const GLubyte* mask)
47{
48    setMask(mask);
49}
50
51PolygonStipple::PolygonStipple(const PolygonStipple& ps,const CopyOp& copyop):
52    StateAttribute(ps,copyop)
53{
54    setMask(ps.getMask());
55}
56
57PolygonStipple::~PolygonStipple()
58{
59}
60
61int PolygonStipple::compare(const StateAttribute& sa) const
62{
63    // check the types are equal and then create the rhs variable
64    // used by the COMPARE_StateAttribute_Parameter macros below.
65    COMPARE_StateAttribute_Types(PolygonStipple,sa)
66
67    // compare each parameter in turn against the rhs.
68    for(unsigned int i=0;i<128;++i)
69    {
70        if (_mask[i]<rhs._mask[i]) return -1;
71        else if (_mask[i]>rhs._mask[i]) return 1;
72    }
73
74    return 0; // passed all the above comparison macros, must be equal.
75}
76
77void PolygonStipple::setMask(const GLubyte* givenMask)
78{
79    std::copy(givenMask,givenMask+128,_mask);
80}
81
82void PolygonStipple::apply(State&) const
83{
84#ifdef OSG_GL1_AVAILABLE
85    glPolygonStipple(_mask);
86#else
87    OSG_NOTICE<<"Warning: PolygonStipple::apply(State&) - not supported."<<std::endl;
88#endif
89}
Note: See TracBrowser for help on using the browser.