fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / OpenGL / OSGShadeModelChunk.cpp
blobe7a76f65873c709f1c3ef874830d5445961c1f5f
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 <stdlib.h>
44 #include <stdio.h>
46 #include "OSGConfig.h"
48 #include "OSGShadeModelChunk.h"
49 #include "OSGDrawEnv.h"
51 OSG_BEGIN_NAMESPACE
53 /***************************************************************************\
54 * Description *
55 \***************************************************************************/
57 /*! \class OSG::ShadeModelChunk
58 ShadeModelChunk controls the shading model used for rendering lines and filled polygons.
61 /***************************************************************************\
62 * Class variables *
63 \***************************************************************************/
65 StateChunkClass ShadeModelChunk::_class("ShadeModel", 1, 100);
67 /***************************************************************************\
68 * Class methods *
69 \***************************************************************************/
71 void ShadeModelChunk::initMethod (InitPhase ePhase)
73 Inherited::initMethod(ePhase);
77 /***************************************************************************\
78 * Instance methods *
79 \***************************************************************************/
81 /*-------------------------------------------------------------------------*\
82 - private -
83 \*-------------------------------------------------------------------------*/
85 /*----------------------- constructors & destructors ----------------------*/
87 ShadeModelChunk::ShadeModelChunk(void) :
88 Inherited()
92 ShadeModelChunk::ShadeModelChunk(const ShadeModelChunk &source) :
93 Inherited(source)
97 ShadeModelChunk::~ShadeModelChunk(void)
101 /*------------------------- Chunk Class Access ---------------------------*/
103 const StateChunkClass *ShadeModelChunk::getClass(void) const
105 return &_class;
108 /*------------------------------- Sync -----------------------------------*/
110 void ShadeModelChunk::changed(ConstFieldMaskArg whichField,
111 UInt32 origin,
112 BitVector details)
114 Inherited::changed(whichField, origin, details);
117 /*------------------------------ Output ----------------------------------*/
119 void ShadeModelChunk::dump( UInt32,
120 const BitVector ) const
122 SLOG << "Dump ShadeModelChunk NI" << std::endl;
125 /*------------------------------ State ------------------------------------*/
127 void ShadeModelChunk::activate(DrawEnv *pEnv, UInt32)
129 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
130 pEnv->incNumChunkChanges();
132 if(getShadeModel() != GL_SMOOTH)
133 glShadeModel(getShadeModel());
134 #else
135 OSG_ASSERT(false);
136 #endif
139 void ShadeModelChunk::changeFrom(DrawEnv *pEnv,
140 StateChunk *old_chunk,
141 UInt32 index )
143 ShadeModelChunk *old = dynamic_cast<ShadeModelChunk *>(old_chunk);
145 if(old == NULL)
147 FWARNING(("ShadeModelChunk::changeFrom: caught "
148 "non-ShadeModelChunk!\n"));
149 return;
152 // ShadeModelChunk didn't change so do nothing.
153 if(old == this)
154 return;
156 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
157 pEnv->incNumChunkChanges();
159 if(old->getShadeModel() != getShadeModel())
160 glShadeModel(getShadeModel());
161 #else
162 OSG_ASSERT(false);
163 #endif
166 void ShadeModelChunk::deactivate(DrawEnv *, UInt32)
168 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
169 if(getShadeModel() != GL_SMOOTH)
170 glShadeModel(GL_SMOOTH);
171 #else
172 OSG_ASSERT(false);
173 #endif
177 /*-------------------------- Comparison -----------------------------------*/
179 Real32 ShadeModelChunk::switchCost(StateChunk *OSG_CHECK_ARG(chunk))
181 return 0;
184 bool ShadeModelChunk::operator <(const StateChunk &other) const
186 return this < &other;
189 bool ShadeModelChunk::operator ==(const StateChunk &other) const
191 ShadeModelChunk const *tother =
192 dynamic_cast<ShadeModelChunk const*>(&other);
194 if(!tother)
195 return false;
197 if(tother == this)
198 return true;
200 return true;
203 bool ShadeModelChunk::operator !=(const StateChunk &other) const
205 return !(*this == other);
208 OSG_END_NAMESPACE