1 # PyOpenSG is (C) Copyright 2005-2009 by Allen Bierbaum
3 # This file is part of PyOpenSG.
5 # PyOpenSG is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation; either version 2 of the License, or (at your option)
10 # PyOpenSG is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This script is derived from gen_bindings.py, it contains all class specific
20 # tasks for the OSGGroupLib for the integration with the OpenSG CMake system
29 def preScanSetup(gen_classes
, fc_infos
, core_mods
, free_funcs
, free_func_mods
, exc_types
):
35 def excludeFCDSetup(opensg_src_dir
, fc_ignore_list
, skip_fcds
):
37 fc_ignore_list
.extend(["ShadowMapEngine", "SimpleShadowMapEngine"])
44 def genTemplatesSetup(template_builder
, tbuilder
, non_fc_template_instances
):
50 scp_temp
= tbuilder
.Template("OSG::ContainerMixinHead<OSG::StageDesc>",
51 "StageContainerParent")
53 spb_temp
= tbuilder
.Template("OSG::TraversalValidationHandlerMixin< OSG::ContainerMixinHead<OSG::StageDesc> >",
55 sp_temp
= tbuilder
.Template("OSG::StageParent", "StageParent")
61 def postScanSetup(osg
, template_alias_db
):
63 splitGenHelper
.exposeTemplateType(scp_temp
)
65 splitGenHelper
.exposeTemplateType(spb_temp
)
67 spb_temp_decl
= spb_temp
.decl
68 spb_temp_decl
["editSFUpdateMode"].exclude()
69 spb_temp_decl
["getSFUpdateMode"].call_policies
= return_internal_reference()
71 spb_temp_decl
.add_declaration_code("""
75 void destroyedCallback(bp::object callable, OSG::FieldContainer* fc,
81 void wrapAddDestroyedFunctor(alias_StageParentBase* spb, bp::object func,
82 const std::string& createSymbol)
84 spb->addDestroyedFunctor(boost::bind(destroyedCallback, func, _1, _2),
90 spb_temp_decl
["addDestroyedFunctor"].exclude()
91 spb_temp_decl
.add_registration_code("""
92 def("addDestroyedFunctor", wrapAddDestroyedFunctor,
93 (bp::arg("func"), bp::arg("createSymbol")))
96 splitGenHelper
.exposeTemplateType(sp_temp
)
101 def postGenClassesSetup(osg
, mb
):
107 def postFCDInfoSetup(osg
, mb
, adddition_exp
):
109 splitGenHelper
.handlAutoSlotReplace(osg
, "DynamicStateGeneratorStageData")
111 c
= osg
.class_("RenderCallbackStage")
112 c
["addPreRenderFunctor"].exclude()
113 c
["addPostRenderFunctor"].exclude()
114 c
["fillPreRenderStore"].exclude()
115 c
["fillPostRenderStore"].exclude()
117 c
.add_declaration_code("""
121 void renderCallback(bp::object callable, OSG::DrawEnv* drawEnv)
126 void wrapAddPreRenderFunctor(OSG::RenderCallbackStage* self,
128 const std::string& createSymbol)
130 self->addPreRenderFunctor(boost::bind(renderCallback, callable, _1),
134 void wrapAddPostRenderFunctor(OSG::RenderCallbackStage* self,
136 const std::string& createSymbol)
138 self->addPostRenderFunctor(boost::bind(renderCallback, callable, _1),
143 fillFunctorStore(const bp::list& callables,
144 OSG::RenderCallbackStage::RenderFunctorStore& store)
146 const int length = bp::extract<int>(callables.attr("__len__")());
147 store.resize(length);
149 for ( int i = 0; i < length; ++i )
151 store[i] = boost::bind(renderCallback, callables[i], _1);
155 void wrapFillPreRenderStore(OSG::RenderCallbackStage* self, bp::list callables)
157 OSG::RenderCallbackStage::RenderFunctorStore store;
158 fillFunctorStore(callables, store);
159 self->fillPreRenderStore(store);
162 void wrapFillPostRenderStore(OSG::RenderCallbackStage* self, bp::list callables)
164 OSG::RenderCallbackStage::RenderFunctorStore store;
165 fillFunctorStore(callables, store);
166 self->fillPostRenderStore(store);
171 add_member_function(c
, "addPreRenderFunctor", "wrapAddPreRenderFunctor")
172 add_member_function(c
, "addPostRenderFunctor", "wrapAddPostRenderFunctor")
173 add_member_function(c
, "fillPreRenderStore", "wrapFillPreRenderStore")
174 add_member_function(c
, "fillPostRenderStore", "wrapFillPostRenderStore")
177 c
= osg
.class_("CubeMapGenerator")
178 c
["initData"].call_policies
= return_internal_reference()
181 c
= osg
.class_("DynamicStateGenerator")
182 c
.add_declaration_code("""
186 OSG::FrameBufferObjectRecPtr
187 wrapGetRenderTarget(OSG::DynamicStateGenerator* dsg)
189 return OSG::FrameBufferObjectRecPtr(
190 OSG::FrameBufferObject::ObjTransitPtr(dsg->getRenderTarget())
198 c
["getRenderTarget"].exclude()
199 c
.add_registration_code('def("getRenderTarget", wrapGetRenderTarget)')