fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Base / OSGTextureBaseChunk.cpp
blob3ff3ef92c47acc76c6f8a65eaf49ad80b2303249
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 "OSGTextureBaseChunk.h"
59 //#define OSG_DUMP_TEX
61 OSG_USING_NAMESPACE
63 // Documentation for this class is emited in the
64 // OSGTextureBaseChunkBase.cpp file.
65 // To modify it, please change the .fcd file (OSGTextureBaseChunk.fcd) and
66 // regenerate the base file.
68 /***************************************************************************\
69 * Class variables *
70 \***************************************************************************/
72 StateChunkClass TextureBaseChunk::_class("Texture", osgMaxTexImages, 20);
74 volatile UInt16 TextureBaseChunk::_uiChunkCounter = 1;
76 UInt32 TextureBaseChunk::_arbMultiTex = Window::invalidExtensionID;
77 UInt32 TextureBaseChunk::_funcActiveTexture = Window::invalidFunctionID;
79 /***************************************************************************\
80 * Class methods *
81 \***************************************************************************/
83 /*-------------------------------------------------------------------------*\
84 - private -
85 \*-------------------------------------------------------------------------*/
87 void TextureBaseChunk::initMethod(InitPhase ePhase)
89 Inherited::initMethod(ePhase);
91 if(ePhase == TypeObject::SystemPost)
93 _arbMultiTex =
94 Window::registerExtension("GL_ARB_multitexture");
96 _funcActiveTexture =
97 Window::registerFunction (OSG_DLSYM_UNDERSCORE"glActiveTextureARB",
98 _arbMultiTex);
103 /***************************************************************************\
104 * Instance methods *
105 \***************************************************************************/
107 /*-------------------------------------------------------------------------*\
108 - private -
109 \*-------------------------------------------------------------------------*/
112 /*------------- constructors & destructors --------------------------------*/
114 TextureBaseChunk::TextureBaseChunk(void) :
115 Inherited( ),
116 _uiChunkId(0)
120 TextureBaseChunk::TextureBaseChunk(const TextureBaseChunk &source) :
121 Inherited(source),
122 _uiChunkId( 0)
126 TextureBaseChunk::~TextureBaseChunk(void)
130 /*------------------------- Chunk Class Access ---------------------------*/
132 const StateChunkClass *TextureBaseChunk::getClass(void) const
134 return &_class;
137 /*------------------------------- Sync -----------------------------------*/
139 /*! React to field changes.
140 Note: this function also handles CubeTexture changes, make sure to keep
141 it consistent with the cubeTexture specifics
144 void TextureBaseChunk::changed(ConstFieldMaskArg whichField,
145 UInt32 origin,
146 BitVector details)
148 Inherited::changed(whichField, origin, details);
152 /*----------------------------- onCreate --------------------------------*/
154 void TextureBaseChunk::onCreate(const TextureBaseChunk *source)
156 Inherited::onCreate(source);
158 if(GlobalSystemState == Startup)
159 return;
161 _uiChunkId = _uiChunkCounter++;
164 void TextureBaseChunk::onCreateAspect(const TextureBaseChunk *createAspect,
165 const TextureBaseChunk *source )
167 Inherited::onCreateAspect(createAspect, source);
169 _uiChunkId = createAspect->_uiChunkId;
172 /*------------------------------ Output ----------------------------------*/
174 void TextureBaseChunk::dump( UInt32 uiIndent,
175 const BitVector bvFlags ) const
177 Inherited::dump(uiIndent, bvFlags);
179 if((bvFlags & TargetFieldMask) != 0)
181 indentLog(uiIndent, PLOG);
182 PLOG << "target "
183 << GLDefineMapper::the()->toString(_sfTarget.getValue())
184 << "\n";
188 bool TextureBaseChunk::isCubeTexture(void)
190 return false;
193 /*------------------------------ State ------------------------------------*/
196 /*-------------------------- Comparison -----------------------------------*/