fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Auxiliary / OSGTextureSelectChunk.cpp
bloba437e2652fd88ddc8ad10590b8b22e886c3f1ab2
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 <boost/bind.hpp>
48 #include "OSGConfig.h"
50 #include "OSGGL.h"
51 #include "OSGGLU.h"
52 #include "OSGGLEXT.h"
53 #include "OSGImage.h"
55 #include "OSGDrawEnv.h"
57 #include "OSGTextureSelectChunk.h"
58 #include "OSGTextureBaseChunk.h"
60 //#define OSG_DUMP_TEX
62 OSG_USING_NAMESPACE
64 // Documentation for this class is emited in the
65 // OSGTextureSelectChunkBase.cpp file.
66 // To modify it, please change the .fcd file (OSGTextureSelectChunk.fcd) and
67 // regenerate the base file.
69 /***************************************************************************\
70 * Class variables *
71 \***************************************************************************/
73 /***************************************************************************\
74 * Class methods *
75 \***************************************************************************/
77 /*-------------------------------------------------------------------------*\
78 - private -
79 \*-------------------------------------------------------------------------*/
81 void TextureSelectChunk::initMethod(InitPhase ePhase)
83 Inherited::initMethod(ePhase);
86 /***************************************************************************\
87 * Instance methods *
88 \***************************************************************************/
90 /*-------------------------------------------------------------------------*\
91 - private -
92 \*-------------------------------------------------------------------------*/
95 /*------------- constructors & destructors --------------------------------*/
97 TextureSelectChunk::TextureSelectChunk(void) :
98 Inherited()
102 TextureSelectChunk::TextureSelectChunk(const TextureSelectChunk &source) :
103 Inherited(source)
107 TextureSelectChunk::~TextureSelectChunk(void)
111 /*------------------------- Chunk Class Access ---------------------------*/
113 /*------------------------------- Sync -----------------------------------*/
115 /*! React to field changes.
116 Note: this function also handles CubeTexture changes, make sure to keep
117 it consistent with the cubeTexture specifics
120 void TextureSelectChunk::changed(ConstFieldMaskArg whichField,
121 UInt32 origin,
122 BitVector details)
124 Inherited::changed(whichField, origin, details);
127 bool TextureSelectChunk::isTransparent(void) const
129 // Even if the texture has alpha, the Blending is makes the sorting
130 // important, thus textures per se are not transparent
131 return false;
135 /*----------------------------- onCreate --------------------------------*/
137 void TextureSelectChunk::onCreate(const TextureSelectChunk *source)
139 Inherited::onCreate(source);
142 void TextureSelectChunk::onCreateAspect(const TextureSelectChunk *createAspect,
143 const TextureSelectChunk *source )
145 Inherited::onCreateAspect(createAspect, source);
148 /*------------------------------ Output ----------------------------------*/
150 void TextureSelectChunk::dump( UInt32 OSG_CHECK_ARG(uiIndent),
151 const BitVector OSG_CHECK_ARG(bvFlags )) const
153 SLOG << "Dump TextureSelectChunk NI" << std::endl;
157 /*------------------------------ State ------------------------------------*/
160 void TextureSelectChunk::activate(DrawEnv *pEnv, UInt32 idx)
162 if(_sfChoice.getValue() >= _mfTextures.size())
164 FWARNING(
165 ("TextureSelect::activate choice beyond size %d %" PRISize "!\n",
166 _sfChoice.getValue(),
167 _mfTextures.size ()));
169 return;
172 this->_mfTextures[_sfChoice.getValue()]->activate(pEnv, idx);
176 void TextureSelectChunk::changeFrom(DrawEnv *pEnv,
177 StateChunk *old ,
178 UInt32 idx )
180 // change from me to me?
181 // this assumes I haven't changed in the meantime.
182 // is that a valid assumption?
183 if(old == this)
184 return;
186 if(_sfChoice.getValue() >= _mfTextures.size())
188 FWARNING(
189 ("TextureSelect::changeFrom choice beyond size %d %" PRISize "!\n",
190 _sfChoice.getValue(),
191 _mfTextures.size ()));
193 return;
196 this->_mfTextures[_sfChoice.getValue()]->changeFrom(pEnv, old, idx);
199 void TextureSelectChunk::deactivate(DrawEnv *pEnv, UInt32 idx)
201 if(_sfChoice.getValue() >= _mfTextures.size())
203 FWARNING(
204 ("TextureSelect::deactivate choice beyond size %d %" PRISize "!\n",
205 _sfChoice.getValue(),
206 _mfTextures.size ()));
208 return;
211 this->_mfTextures[_sfChoice.getValue()]->deactivate(pEnv, idx);
214 /*-------------------------- Comparison -----------------------------------*/
216 Real32 TextureSelectChunk::switchCost(StateChunk *OSG_CHECK_ARG(chunk))
218 return 0;
221 bool TextureSelectChunk::operator < (const StateChunk &other) const
223 return this < &other;
226 bool TextureSelectChunk::operator == (const StateChunk &other) const
228 bool returnValue = false;
230 return returnValue;
233 bool TextureSelectChunk::operator != (const StateChunk &other) const
235 return ! (*this == other);
238 void TextureSelectChunk::validate(DrawEnv *pEnv)
240 if(_sfChoice.getValue() >= _mfTextures.size())
242 FWARNING(
243 ("TextureSelect::validate choice beyond size %d %" PRISize "!\n",
244 _sfChoice.getValue(),
245 _mfTextures.size ()));
247 return;
250 this->_mfTextures[_sfChoice.getValue()]->validate(pEnv);
253 Int32 TextureSelectChunk::getOpenGLId(DrawEnv *pEnv)
255 if(_sfChoice.getValue() >= _mfTextures.size())
257 FWARNING(
258 ("TextureSelect::validate choice beyond size %d %" PRISize "!\n",
259 _sfChoice.getValue(),
260 _mfTextures.size ()));
262 return -1;
265 return this->_mfTextures[_sfChoice.getValue()]->getOpenGLId(pEnv);
268 GLenum TextureSelectChunk::determineInternalFormat(void)
270 if(_sfChoice.getValue() >= _mfTextures.size())
272 FWARNING(
273 ("TextureSelect::validate choice beyond size %d %" PRISize "!\n",
274 _sfChoice.getValue(),
275 _mfTextures.size ()));
277 return -1;
280 return this->_mfTextures[_sfChoice.getValue()]->determineInternalFormat();