changed: gcc8 base update
[opensg.git] / Source / System / State / OpenGL / OSGLineChunk.cpp
blob30c5000dc78be91e9531ed5cbd9cd7094df58a16
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <cstdlib>
44 #include <cstdio>
46 #include "OSGConfig.h"
48 #include "OSGGL.h"
50 #include "OSGWindow.h"
52 #include "OSGLineChunk.h"
54 OSG_USING_NAMESPACE
56 // Documentation for this class is emited in the
57 // OSGLineChunkBase.cpp file.
58 // To modify it, please change the .fcd file (OSGLineChunk.fcd) and
59 // regenerate the base file.
61 /***************************************************************************\
62 * Class variables *
63 \***************************************************************************/
65 StateChunkClass LineChunk::_class("Line", 1, 50);
67 /***************************************************************************\
68 * Class methods *
69 \***************************************************************************/
71 void LineChunk::initMethod(InitPhase ePhase)
73 Inherited::initMethod(ePhase);
76 /***************************************************************************\
77 * Instance methods *
78 \***************************************************************************/
80 /*-------------------------------------------------------------------------*\
81 - private -
82 \*-------------------------------------------------------------------------*/
84 /*------------- constructors & destructors --------------------------------*/
87 LineChunk::LineChunk(void) :
88 Inherited()
92 LineChunk::LineChunk(const LineChunk &source) :
93 Inherited(source)
97 LineChunk::~LineChunk(void)
101 /*------------------------- Chunk Class Access ---------------------------*/
103 const StateChunkClass *LineChunk::getClass(void) const
105 return &_class;
108 /*------------------------------- Sync -----------------------------------*/
110 void LineChunk::changed(ConstFieldMaskArg whichField,
111 UInt32 origin,
112 BitVector details)
114 Inherited::changed(whichField, origin, details);
117 /*------------------------------ Output ----------------------------------*/
119 void LineChunk::dump( UInt32 ,
120 const BitVector ) const
122 SLOG << "Dump LineChunk NI" << std::endl;
126 /*------------------------------ State ------------------------------------*/
128 void LineChunk::activate(DrawEnv *pEnv, UInt32)
130 pEnv->incNumChunkChanges();
132 if(_sfWidth.getValue() != 1)
134 glLineWidth(_sfWidth.getValue());
137 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
138 if(_sfStipplePattern.getValue() != 0xffffu)
140 glLineStipple(_sfStippleRepeat.getValue(),
141 _sfStipplePattern.getValue());
142 glEnable(GL_LINE_STIPPLE);
144 #endif
146 #ifndef OSG_OGL_ES2
147 if(_sfSmooth.getValue())
149 glEnable(GL_LINE_SMOOTH);
151 #endif
154 void LineChunk::changeFrom(DrawEnv *pEnv,
155 StateChunk *old_chunk,
156 UInt32 index )
158 old_chunk->deactivate(pEnv, index);
160 activate(pEnv, index);
163 void LineChunk::deactivate(DrawEnv *, UInt32)
165 if(_sfWidth.getValue() != 1)
167 glLineWidth(1);
170 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
171 if(_sfStipplePattern.getValue() != 0xffffu)
173 glDisable(GL_LINE_STIPPLE);
175 #endif
177 #ifndef OSG_OGL_ES2
178 if(_sfSmooth.getValue())
180 glDisable(GL_LINE_SMOOTH);
182 #endif
185 /*-------------------------- Comparison -----------------------------------*/
187 Real32 LineChunk::switchCost(StateChunk *)
189 return 0;
192 /** \brief assignment
195 bool LineChunk::operator <(const StateChunk &other) const
197 return this < &other;
200 /** \brief equal
203 bool LineChunk::operator ==(const StateChunk &other) const
205 LineChunk const *tother = dynamic_cast<LineChunk const*>(&other);
207 if(!tother)
208 return false;
210 if(tother == this)
211 return true;
213 if(getWidth() != tother->getWidth() ||
214 getStipplePattern() != tother->getStipplePattern() ||
215 getSmooth() != tother->getSmooth() )
217 return false;
220 return true;
223 /** \brief unequal
226 bool LineChunk::operator != (const StateChunk &other) const
228 return ! (*this == other);