Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r423 - in trunk: Engine/Control Interface SwigInterface
- Date: Tue, 5 Jul 2005 23:36:04 -0600 (MDT)
Author: bigler
Date: Tue Jul 5 23:36:03 2005
New Revision: 423
Added:
trunk/SwigInterface/manta.h
Modified:
trunk/Engine/Control/RTRT.cc
trunk/Interface/Callback.h
trunk/Interface/CallbackHelpers.h
trunk/SwigInterface/CMakeLists.txt
trunk/SwigInterface/manta.i
Log:
Added ability to change the PixelSampler after the renderer has started.
Engine/Control/RTRT.cc
You can now call selectPixelSampler after rendering has
started. You should make sure that you are doing so from a
one shot call back, or you will be sorry. There aren't any
guards protecting the user from doing so. Make sure
currentPixelSampler is initialized with 0.
Interface/Callback.h
Interface/CallbackHelpers.h
Added 2Data Callback with 2 arguments (for use with
addOneShotCallback and a 2 argument function).
SwigInterface/CMakeLists.txt
Added manta.h to the build list.
SwigInterface/manta.h
SwigInterface/manta.i
Added the PipelineChanger class.
Modified: trunk/Engine/Control/RTRT.cc
==============================================================================
--- trunk/Engine/Control/RTRT.cc (original)
+++ trunk/Engine/Control/RTRT.cc Tue Jul 5 23:36:03 2005
@@ -87,6 +87,7 @@
registerKnownComponents(this);
scene = 0;
verbose_transactions = false;
+ currentPixelSampler = 0;
}
RTRT::~RTRT()
@@ -770,7 +771,20 @@
PixelSamplerMapType::iterator iter = pixelSamplers.find(name);
if(iter == pixelSamplers.end())
return false;
+ // Try to clean up our memory. This function should be called with
+ // the transactions or before rendering.
+ if (running) {
+ // Currently there isn't anything special to make sure this is
+ // called safely, so you are on your own.
+ }
+ if (currentPixelSampler) {
+ // It would be nice to see if the current pixel sampler can be
+ // simply updated rather than recreated, but for now we will do it
+ // the hard way.
+ delete currentPixelSampler;
+ }
currentPixelSampler = (*iter->second)(args);
+ pipelineNeedsSetup = true;
return true;
}
Modified: trunk/Interface/Callback.h
==============================================================================
--- trunk/Interface/Callback.h (original)
+++ trunk/Interface/Callback.h Tue Jul 5 23:36:03 2005
@@ -51,6 +51,14 @@
}
template<class T, typename Data1, typename Data2,
+ typename Arg1, typename Arg2> static
+ CallbackBase_2Data<Data1, Data2>*
+ create(T* ptr, void (T::*pmf)(Data1, Data2, Arg1, Arg2),
+ Arg1 arg1, Arg2 arg2) {
+ return new Callback_2Data_2Arg<T, Data1, Data2, Arg1, Arg2>(ptr, pmf,
arg1, arg2);
+ }
+
+ template<class T, typename Data1, typename Data2,
typename Arg1, typename Arg2, typename Arg3> static
CallbackBase_2Data<Data1, Data2>*
create(T* ptr, void (T::*pmf)(Data1, Data2, Arg1, Arg2, Arg3),
Modified: trunk/Interface/CallbackHelpers.h
==============================================================================
--- trunk/Interface/CallbackHelpers.h (original)
+++ trunk/Interface/CallbackHelpers.h Tue Jul 5 23:36:03 2005
@@ -262,6 +262,29 @@
};
template<class T, typename Data1, typename Data2,
+ typename Arg1, typename Arg2>
+ class Callback_2Data_2Arg : public CallbackBase_2Data<Data1, Data2> {
+ public:
+ Callback_2Data_2Arg(T* ptr, void (T::*pmf)(Data1, Data2, Arg1, Arg2),
+ Arg1 arg1, Arg2 arg2)
+ : ptr(ptr), pmf(pmf), arg1(arg1), arg2(arg2)
+ {
+ }
+ virtual ~Callback_2Data_2Arg()
+ {
+ }
+ virtual void call(Data1 data1, Data2 data2)
+ {
+ (ptr->*pmf)(data1, data2, arg1, arg2);
+ }
+ private:
+ T* ptr;
+ void (T::*pmf)(Data1, Data2, Arg1, Arg2);
+ Arg1 arg1;
+ Arg2 arg2;
+ };
+
+ template<class T, typename Data1, typename Data2,
typename Arg1, typename Arg2, typename Arg3>
class Callback_2Data_3Arg : public CallbackBase_2Data<Data1, Data2> {
public:
Modified: trunk/SwigInterface/CMakeLists.txt
==============================================================================
--- trunk/SwigInterface/CMakeLists.txt (original)
+++ trunk/SwigInterface/CMakeLists.txt Tue Jul 5 23:36:03 2005
@@ -20,7 +20,7 @@
SET_SOURCE_FILES_PROPERTIES(manta.i PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(manta.i PROPERTIES SWIG_FLAGS "`echo \"\"`")
-SWIG_ADD_MODULE(manta python manta.i manta.cc)
+SWIG_ADD_MODULE(manta python manta.i manta.cc manta.h)
SWIG_LINK_LIBRARIES(manta
${PYTHON_LIBRARIES}
Added: trunk/SwigInterface/manta.h
==============================================================================
--- (empty file)
+++ trunk/SwigInterface/manta.h Tue Jul 5 23:36:03 2005
@@ -0,0 +1,43 @@
+#include <Interface/RTRTInterface.h>
+#include <Interface/Callback.h>
+
+#include <sgi_stl_warnings_off.h>
+#include <string>
+#include <sgi_stl_warnings_on.h>
+
+namespace Manta {
+ using namespace std;
+
+ class PipelineChanger {
+ RTRTInterface* rtrt_interface;
+ public:
+ PipelineChanger(RTRTInterface* rtrt_interface):
+ rtrt_interface(rtrt_interface)
+ {}
+
+ void changePixelSamplerCallback(int, int,
+ string spec)
+ {
+ rtrt_interface->selectPixelSampler(spec);
+ }
+
+ void changeResolutionCallBack(int, int,
+ int channel, int new_xres, int new_yres)
+ {
+ rtrt_interface->changeResolution(channel, new_xres, new_yres, true);
+ }
+
+ void changePixelSampler(string spec) {
+ rtrt_interface->addOneShotCallback(RTRTInterface::Relative, 0,
+ Callback::create(this,
&PipelineChanger::changePixelSamplerCallback,
+ spec));
+ }
+
+ void changeResolution(int channel, int new_xres, int new_yres) {
+ rtrt_interface->addOneShotCallback(RTRTInterface::Relative, 0,
+ Callback::create(this,
&PipelineChanger::changeResolutionCallBack,
+ channel, new_xres, new_yres));
+ }
+ };
+
+} // end namespace Manta
Modified: trunk/SwigInterface/manta.i
==============================================================================
--- trunk/SwigInterface/manta.i (original)
+++ trunk/SwigInterface/manta.i Tue Jul 5 23:36:03 2005
@@ -56,6 +56,9 @@
#include <Interface/UserInterface.h>
#include <Interface/RenderParameters.h>
#include <Interface/Scene.h>
+#include <Interface/Callback.h>
+#include <Interface/CallbackHelpers.h>
+#include <SwigInterface/manta.h>
%}
namespace std {
@@ -72,6 +75,9 @@
%include <Interface/Transaction.h>
%include <Interface/TValue.h>
+%include <Interface/RTRTInterface.h>
+%include <SwigInterface/manta.h>
+
namespace Manta {
using namespace std;
@@ -81,8 +87,6 @@
}
extern Manta::Scene* createDefaultScene();
-
-%include <Interface/RTRTInterface.h>
%exception;
- [MANTA] r423 - in trunk: Engine/Control Interface SwigInterface, bigler, 07/05/2005
Archive powered by MHonArc 2.6.16.