1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
46 #include "OSGConfig.h"
48 #include "OSGBaseInitFunctions.h"
49 #include "OSGRenderPropertiesPool.h"
50 #include "OSGTaggedSingletonHolder.ins"
56 OSG_TAGGEDSINGLETON_INST(RenderPropertiesPoolBase
,
57 RenderPropertiesPoolTag
)
59 template class TaggedSingletonHolder
<RenderPropertiesPoolBase
,
60 RenderPropertiesPoolTag
>;
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
;
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
;
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
)
128 result
.push_back(tmpRes
);
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) :
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");
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
);
194 bool registerInitRenderProps(void)
196 addPreFactoryInitFunction(initRenderProperties
);
201 StaticInitFuncWrapper
initRenderPropWrapper(registerInitRenderProps
);