← Back to team overview

yade-dev team mailing list archive

[svn] r1644 - in trunk: core gui/qt3 pkg/common/RenderingEngine/GLDrawGeometricalModel pkg/common/RenderingEngine/GLDrawInteractingGeometry pkg/common/RenderingEngine/OpenGLRenderingEngine

 

Author: cosurgi
Date: 2009-01-27 01:58:28 +0100 (Tue, 27 Jan 2009)
New Revision: 1644

Modified:
   trunk/core/RenderingEngine.hpp
   trunk/gui/qt3/YadeQtMainWindow.cpp
   trunk/pkg/common/RenderingEngine/GLDrawGeometricalModel/GLDrawSphere.cpp
   trunk/pkg/common/RenderingEngine/GLDrawGeometricalModel/GLDrawSphere.hpp
   trunk/pkg/common/RenderingEngine/GLDrawInteractingGeometry/GLDrawInteractingSphere.hpp
   trunk/pkg/common/RenderingEngine/OpenGLRenderingEngine/GLDrawFunctors.hpp
   trunk/pkg/common/RenderingEngine/OpenGLRenderingEngine/OpenGLRenderingEngine.cpp
   trunk/pkg/common/RenderingEngine/OpenGLRenderingEngine/OpenGLRenderingEngine.hpp
Log:
maybe spheres won't disappear anymore?



Modified: trunk/core/RenderingEngine.hpp
===================================================================
--- trunk/core/RenderingEngine.hpp	2009-01-26 03:34:03 UTC (rev 1643)
+++ trunk/core/RenderingEngine.hpp	2009-01-27 00:58:28 UTC (rev 1644)
@@ -21,6 +21,7 @@
 		virtual void render(const shared_ptr<MetaBody>& , const int selection = -1) {throw;};
 		virtual void renderWithNames(const shared_ptr<MetaBody>& ) {throw;};
 		virtual void init() {throw;};
+		virtual void initgl() {};
 
 	REGISTER_CLASS_AND_BASE(RenderingEngine,Serializable);
 };

Modified: trunk/gui/qt3/YadeQtMainWindow.cpp
===================================================================
--- trunk/gui/qt3/YadeQtMainWindow.cpp	2009-01-26 03:34:03 UTC (rev 1643)
+++ trunk/gui/qt3/YadeQtMainWindow.cpp	2009-01-27 00:58:28 UTC (rev 1644)
@@ -155,6 +155,8 @@
 	glv->camera()->setViewDirection(qglviewer::Vec(-1,-1,-1));
 	lookDown(glv);
 	glViews.push_back(glv);
+	if(isFirst)
+		renderer->initgl();
 	//connect( glv, SIGNAL(closeSignal(int)), this, SLOT( closeGLViewEvent(int) ) );
 }
 

Modified: trunk/pkg/common/RenderingEngine/GLDrawGeometricalModel/GLDrawSphere.cpp
===================================================================
--- trunk/pkg/common/RenderingEngine/GLDrawGeometricalModel/GLDrawSphere.cpp	2009-01-26 03:34:03 UTC (rev 1643)
+++ trunk/pkg/common/RenderingEngine/GLDrawGeometricalModel/GLDrawSphere.cpp	2009-01-27 00:58:28 UTC (rev 1644)
@@ -34,7 +34,7 @@
 int  GLDrawSphere::glutStacks=6;
 
 GLDrawSphere::GLDrawSphere(){first=true;};
-
+		
 void GLDrawSphere::go(const shared_ptr<GeometricalModel>& gm, const shared_ptr<PhysicalParameters>& ph,bool wire)
 {
 	if(glutUse){

Modified: trunk/pkg/common/RenderingEngine/GLDrawGeometricalModel/GLDrawSphere.hpp
===================================================================
--- trunk/pkg/common/RenderingEngine/GLDrawGeometricalModel/GLDrawSphere.hpp	2009-01-26 03:34:03 UTC (rev 1643)
+++ trunk/pkg/common/RenderingEngine/GLDrawGeometricalModel/GLDrawSphere.hpp	2009-01-27 00:58:28 UTC (rev 1644)
@@ -29,6 +29,7 @@
 	public :
 		GLDrawSphere();
 		virtual void go(const shared_ptr<GeometricalModel>&, const shared_ptr<PhysicalParameters>&,bool);
+		virtual void initgl(){first=true;};
 /// Serialization
 	protected :
 		virtual void postProcessAttributes(bool deserializing){if(deserializing){first=true;};};

Modified: trunk/pkg/common/RenderingEngine/GLDrawInteractingGeometry/GLDrawInteractingSphere.hpp
===================================================================
--- trunk/pkg/common/RenderingEngine/GLDrawInteractingGeometry/GLDrawInteractingSphere.hpp	2009-01-26 03:34:03 UTC (rev 1643)
+++ trunk/pkg/common/RenderingEngine/GLDrawInteractingGeometry/GLDrawInteractingSphere.hpp	2009-01-27 00:58:28 UTC (rev 1644)
@@ -25,6 +25,7 @@
 	public :
 		GLDrawInteractingSphere();
 		virtual void go(const shared_ptr<InteractingGeometry>&, const shared_ptr<PhysicalParameters>&,bool);
+		virtual void initgl(){first=true;};
 /// Serialization
 	protected :
 		virtual void postProcessAttributes(bool deserializing){if(deserializing){first=true;};};

Modified: trunk/pkg/common/RenderingEngine/OpenGLRenderingEngine/GLDrawFunctors.hpp
===================================================================
--- trunk/pkg/common/RenderingEngine/OpenGLRenderingEngine/GLDrawFunctors.hpp	2009-01-26 03:34:03 UTC (rev 1643)
+++ trunk/pkg/common/RenderingEngine/OpenGLRenderingEngine/GLDrawFunctors.hpp	2009-01-27 00:58:28 UTC (rev 1644)
@@ -20,6 +20,7 @@
 	public:
 		virtual ~GLDrawBoundingVolumeFunctor() {};
 		virtual string renders() const { std::cerr<<"Unregistered gldraw class.\n"; throw; };
+		virtual void initgl(){/*WARNING: it must deal with static members, because it is called from another instance!*/};
 	REGISTER_CLASS_NAME(GLDrawBoundingVolumeFunctor);
 	REGISTER_BASE_CLASS_NAME(EngineUnit1D);
 };
@@ -29,6 +30,7 @@
 	public: 
 		virtual ~GLDrawGeometricalModelFunctor() {};
 		virtual string renders() const { std::cerr<<"Unregistered gldraw class.\n"; throw; };
+		virtual void initgl(){/*WARNING: it must deal with static members, because it is called from another instance!*/};
 	REGISTER_CLASS_NAME(GLDrawGeometricalModelFunctor);
 	REGISTER_BASE_CLASS_NAME(EngineUnit1D);
 };
@@ -39,6 +41,7 @@
 	public:
 		virtual ~GLDrawInteractingGeometryFunctor() {};
 		virtual string renders() const { std::cerr<<"Unregistered gldraw class.\n"; throw; };
+		virtual void initgl(){/*WARNING: it must deal with static members, because it is called from another instance!*/};
 	REGISTER_CLASS_NAME(GLDrawInteractingGeometryFunctor);
 	REGISTER_BASE_CLASS_NAME(EngineUnit1D);
 };
@@ -48,6 +51,7 @@
 	public: 
 		virtual ~GLDrawInteractionGeometryFunctor() {};
 		virtual string renders() const { std::cerr<<"Unregistered gldraw class.\n"; throw; };
+		virtual void initgl(){/*WARNING: it must deal with static members, because it is called from another instance!*/};
 	REGISTER_CLASS_NAME(GLDrawInteractionGeometryFunctor);
 	REGISTER_BASE_CLASS_NAME(EngineUnit1D);
 };
@@ -57,6 +61,7 @@
 	public: 
 		virtual ~GLDrawInteractionPhysicsFunctor() {};
 		virtual string renders() const { std::cerr<<"Unregistered gldraw class.\n"; throw; };
+		virtual void initgl(){/*WARNING: it must deal with static members, because it is called from another instance!*/};
 	REGISTER_CLASS_NAME(GLDrawInteractionPhysicsFunctor);
 	REGISTER_BASE_CLASS_NAME(EngineUnit1D);
 };
@@ -74,6 +79,7 @@
 	public : 
 		virtual ~GLDrawStateFunctor() {};
 		virtual string renders() const { std::cerr<<"Unregistered gldraw class.\n"; throw; };
+		virtual void initgl(){/*WARNING: it must deal with static members, because it is called from another instance!*/};
 	REGISTER_CLASS_NAME(GLDrawStateFunctor);
 	REGISTER_BASE_CLASS_NAME(EngineUnit1D);
 };

Modified: trunk/pkg/common/RenderingEngine/OpenGLRenderingEngine/OpenGLRenderingEngine.cpp
===================================================================
--- trunk/pkg/common/RenderingEngine/OpenGLRenderingEngine/OpenGLRenderingEngine.cpp	2009-01-26 03:34:03 UTC (rev 1643)
+++ trunk/pkg/common/RenderingEngine/OpenGLRenderingEngine/OpenGLRenderingEngine.cpp	2009-01-27 00:58:28 UTC (rev 1644)
@@ -58,6 +58,22 @@
 	glutInitDone=true;
 }
 
+void OpenGLRenderingEngine::initgl(){
+	LOG_INFO("(re)initializing GL for gldraw methods.\n");
+	BOOST_FOREACH(vector<string>& s,stateFunctorNames)
+		(static_pointer_cast<GLDrawStateFunctor>(ClassFactory::instance().createShared(s[1])))->initgl();
+	BOOST_FOREACH(vector<string>& s,boundingVolumeFunctorNames)
+		(static_pointer_cast<GLDrawBoundingVolumeFunctor>(ClassFactory::instance().createShared(s[1])))->initgl();
+	BOOST_FOREACH(vector<string>& s,interactingGeometryFunctorNames)
+		(static_pointer_cast<GLDrawInteractingGeometryFunctor>(ClassFactory::instance().createShared(s[1])))->initgl();
+	BOOST_FOREACH(vector<string>& s,geometricalModelFunctorNames)
+		(static_pointer_cast<GLDrawGeometricalModelFunctor>(ClassFactory::instance().createShared(s[1])))->initgl();
+	BOOST_FOREACH(vector<string>& s,interactionGeometryFunctorNames)
+		(static_pointer_cast<GLDrawInteractionGeometryFunctor>(ClassFactory::instance().createShared(s[1])))->initgl();
+	BOOST_FOREACH(vector<string>& s,interactionPhysicsFunctorNames)
+		(static_pointer_cast<GLDrawInteractionPhysicsFunctor>(ClassFactory::instance().createShared(s[1])))->initgl();
+}
+
 void OpenGLRenderingEngine::renderWithNames(const shared_ptr<MetaBody>& rootBody){
 	FOREACH(const shared_ptr<Body>& b, *rootBody->bodies){
 		if(!b->geometricalModel) continue;

Modified: trunk/pkg/common/RenderingEngine/OpenGLRenderingEngine/OpenGLRenderingEngine.hpp
===================================================================
--- trunk/pkg/common/RenderingEngine/OpenGLRenderingEngine/OpenGLRenderingEngine.hpp	2009-01-26 03:34:03 UTC (rev 1643)
+++ trunk/pkg/common/RenderingEngine/OpenGLRenderingEngine/OpenGLRenderingEngine.hpp	2009-01-27 00:58:28 UTC (rev 1644)
@@ -66,6 +66,7 @@
 		virtual ~OpenGLRenderingEngine();
 	
 		void init();
+		void initgl();
 		void render(const shared_ptr<MetaBody>& body, body_id_t selection = body_id_t(-1));
 		virtual void renderWithNames(const shared_ptr<MetaBody>& );