fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / RenderingBackend / OSGRenderPropertiesPool.cpp
blob7c9bc8430c6cd4623e039b9f96697460bd8a11e5
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 "OSGBaseInitFunctions.h"
49 #include "OSGRenderPropertiesPool.h"
50 #include "OSGTaggedSingletonHolder.ins"
52 OSG_USING_NAMESPACE
54 OSG_BEGIN_NAMESPACE
56 OSG_TAGGEDSINGLETON_INST(RenderPropertiesPoolBase,
57 RenderPropertiesPoolTag )
59 template class TaggedSingletonHolder<RenderPropertiesPoolBase,
60 RenderPropertiesPoolTag>;
62 template<>
63 void NamedSplitFinitePool<RenderPropBitVector,
64 RenderPropertiesSplitInfo,
65 RenderPropertiesPoolTag,
66 SingleLockPolicy >::initialize(void)
68 for(UInt32 i = 0; i < RenderPropertiesSplitInfo::SplitPoint; ++i)
70 RenderPropBitVector tmpVal = RenderPropBitVector(0x0001) << i;
72 _vElementStore1.push_back(tmpVal);
75 std::reverse(_vElementStore1.begin(),
76 _vElementStore1.end ());
78 for(UInt32 i = RenderPropertiesSplitInfo::SplitPoint;
79 i < RenderPropertiesSplitInfo::NumBits;
80 ++i)
82 RenderPropBitVector tmpVal = RenderPropBitVector(0x0001) << i;
84 _vElementStore2.push_back(tmpVal);
87 std::reverse(_vElementStore2.begin(),
88 _vElementStore2.end ());
90 _oDefaultElement = RenderPropBitVector(0x0000);
92 std::string szFallback("fallback");
94 _mNameValueMap[ szFallback ] = _oDefaultElement;
95 _mValueNameMap[_oDefaultElement] = szFallback;
98 template<>
99 void NamedSplitFinitePool<RenderPropBitVector,
100 RenderPropertiesSplitInfo,
101 RenderPropertiesPoolTag,
102 SingleLockPolicy >::keyToStringList(
103 const StoredType &val,
104 std::vector<std::string> &result)
106 const RenderPropBitVector zeroVec = 0x0000;
108 const RenderPropBitVector splitVal =
109 RenderPropBitVector(0x0001) << RenderPropertiesSplitInfo::SplitPoint;
111 for(UInt32 i = 0; i < RenderPropertiesSplitInfo::NumBits; ++i)
113 RenderPropBitVector tmpVal = RenderPropBitVector(0x0001) << i;
115 if(zeroVec != (val & tmpVal))
117 std::string tmpRes = this->findName(tmpVal);
119 if(tmpVal < splitVal)
121 tmpRes.append("@");
123 else
125 tmpRes.append("$");
128 result.push_back(tmpRes);
134 template<>
135 void NamedSplitFinitePool<RenderPropBitVector,
136 RenderPropertiesSplitInfo,
137 RenderPropertiesPoolTag,
138 SingleLockPolicy >::dumpValue(
139 const StoredType &val)
141 fprintf(stderr, "0x%016" PRIx64 , val);
145 RenderPropertiesStruct SystemRenderProperties;
147 RenderPropertiesStruct::RenderPropertiesStruct(void) :
148 ColorBuffer (0),
149 DepthBuffer (0),
150 GBuffer (0),
151 ShadowFactor(0)
155 namespace
157 bool initRenderProperties(void)
159 BitVector *bv = NULL;
162 bv = const_cast<BitVector *>(&SystemRenderProperties.ColorBuffer);
164 *bv = RenderPropertiesPool::the()->getFrom1("ColorBuffer");
167 bv = const_cast<BitVector *>(&SystemRenderProperties.DepthBuffer);
169 *bv = RenderPropertiesPool::the()->getFrom1("DepthBuffer");
172 bv = const_cast<BitVector *>(&SystemRenderProperties.GBuffer);
174 *bv = RenderPropertiesPool::the()->getFrom1("GBuffer");
177 bv = const_cast<BitVector *>(&SystemRenderProperties.ShadowFactor);
179 *bv = RenderPropertiesPool::the()->getFrom1("ShadowFactor");
181 fprintf(stderr,
182 "ColorBuffer : 0x%016" PRIx64 " \n"
183 "DepthBuffer : 0x%016" PRIx64 " \n"
184 "GBuffer : 0x%016" PRIx64 " \n"
185 "ShadowFactor: 0x%016" PRIx64 " \n",
186 SystemRenderProperties.ColorBuffer,
187 SystemRenderProperties.DepthBuffer,
188 SystemRenderProperties.GBuffer,
189 SystemRenderProperties.ShadowFactor);
191 return true;
194 bool registerInitRenderProps(void)
196 addPreFactoryInitFunction(initRenderProperties);
198 return true;
201 StaticInitFuncWrapper initRenderPropWrapper(registerInitRenderProps);
204 OSG_END_NAMESPACE