Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r387 - in branches/itanium2: Engine/Display Interface fox


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r387 - in branches/itanium2: Engine/Display Interface fox
  • Date: Thu, 16 Jun 2005 03:54:25 -0600 (MDT)

Author: abe
Date: Thu Jun 16 03:54:12 2005
New Revision: 387

Modified:
   branches/itanium2/Engine/Display/GLXImageDisplay.cc
   branches/itanium2/Engine/Display/GLXImageDisplay.h
   branches/itanium2/Interface/CMakeLists.txt
   branches/itanium2/Interface/Callback.h
   branches/itanium2/Interface/CallbackHelpers.h
   branches/itanium2/Interface/Fragment.cc
   branches/itanium2/Interface/HitInfo.cc
   branches/itanium2/Interface/HitInfo.h
   branches/itanium2/fox/FMantaImageFrame.cc
   branches/itanium2/fox/FMantaImageFrame.h
   branches/itanium2/fox/FMantaWindow.cc
   branches/itanium2/fox/FMantaWindow.h
   branches/itanium2/fox/fox_manta.cc
Log:
M    fox/fox_manta.cc
M    fox/FMantaWindow.cc
M    fox/FMantaWindow.h
M    fox/FMantaImageFrame.cc
M    fox/FMantaImageFrame.h
M    Engine/Display/GLXImageDisplay.cc
M    Engine/Display/GLXImageDisplay.h
M    Interface/CallbackHelpers.h
M    Interface/Callback.h

Fox/Manta code is pretty raw, but appears to be stable with different numbers 
of workers. I think I solved the X11 ASync event error and the BadMatch 
problem.

The code is pretty messy and needs to be refined. 

I think we should now be able to extend FMantaImageFrame with an image frame 
that contains the mouse logic we 
need etc. GLXImageDisplay is passed a x_visual_info from the driving app's 
visual, and a window id from the 
driving app. It connects to the X server and then creates a GLXContext for 
its own thread. The API to obtain
the XVisualInfo from fox was only in Fox-1.5

Haven't tried with vizserver.. 

Known problems: 
  harsh exits, 
  only resize working, 
  no mouse keyboard.
  reconnects to xserver every resize !!

Code now requires Fox-1.5. This can be found in the same basic path as before 
/store/......,
replacing 1.4 with 1.5. 

M    Interface/HitInfo.h
M    Interface/Fragment.cc
M    Interface/CMakeLists.txt
M    Interface/HitInfo.cc
Changes related to adding headers to CMake files........


Modified: branches/itanium2/Engine/Display/GLXImageDisplay.cc
==============================================================================
--- branches/itanium2/Engine/Display/GLXImageDisplay.cc (original)
+++ branches/itanium2/Engine/Display/GLXImageDisplay.cc Thu Jun 16 03:54:12 
2005
@@ -14,9 +14,18 @@
 
 // Note that the GLXImage display must be passed a GLX context by the
 // application it is embedded inside of.
-GLXImageDisplay::GLXImageDisplay( GLXContext glx_context_, GLXDrawable 
glx_drawable_, Display *x_display_ ) 
-       : glx_context( glx_context_ ), glx_drawable( glx_drawable_ ), 
x_display( x_display_ ) 
+GLXImageDisplay::GLXImageDisplay( XVisualInfo *x_visual_info_, 
+                                  GLXContext  glx_context_, 
+                                                                             
                                                          GLXDrawable 
glx_drawable_, 
+                                                                             
                                                          Display *x_display_,
+                                                                             
                                                          int x_screen_ ) 
+       : x_visual_info( x_visual_info_ ), 
+         glx_context( glx_context_ ), 
+               glx_drawable( glx_drawable_ ), 
+               x_display( x_display_ ),
+               x_screen( x_screen_ ) 
 {
+               
 }
 
 GLXImageDisplay::~GLXImageDisplay() {
@@ -25,16 +34,37 @@
 // Manta ImageDisplay interface.
 void GLXImageDisplay::setupDisplayChannel( SetupContext &context ) {
        // The setup for the window should be done in the driving application.
+
+       std::cout << "setupDisplayChannel" << context.proc << std::endl;
+
+        
+       // Only the display processor.
+       if (context.proc != 0)
+               return;
+                       
+       x_display = XOpenDisplay( 0 ); // Open a new connection to the same 
display...
        
+       // Get the default screen for the display.
+       x_screen = DefaultScreen( x_display );
+       
+       // (Like we have a prayer this will work...)
+       glx_context = glXCreateContext( x_display, x_visual_info, 0, true );
+
        // Call make current to associate with this thread
        // NOTE THIS MUST BE CALLED EACH TIME THE DISPLAY THREAD CHANGES!!
+       
+       // glXWaitX();
        glXMakeCurrent( x_display, glx_drawable, glx_context );
+       // glXWaitGL();
+       
+       // Copy out the manta channel.
+       manta_channel = context.channelIndex;
 }
 
 void GLXImageDisplay::displayImage( const DisplayContext &context, const 
Image* image ) {
 
        // Check to see if this processor should display the image.
-       if (context.proc == context.numProcs-1) {
+       if (context.proc == 0) {
        
                // Determine the image resolution.
                int xres, yres;
@@ -44,7 +74,9 @@
 
                // NOTE THIS MUST BE CALLED EACH TIME THE DISPLAY THREAD 
CHANGES!!
                // (which is why it's here, until I figure out how to insure 
that).
-               glXMakeCurrent( x_display, glx_drawable, glx_context );
+               // XSync( x_display, false );
+               // glXWaitX();
+               // glXMakeCurrent( x_display, glx_drawable, glx_context );
 
                // This code is from OpenGLImageDisplay.
                glViewport(0, 0, xres, yres);
@@ -112,7 +144,7 @@
                                glDrawPixels(xres, yres, GL_RGB, GL_FLOAT, 
si->getRaw(0));
                        }
                } 
-                               
+
                // Swap buffers.
                glXSwapBuffers( x_display, glx_drawable );
                
@@ -121,5 +153,8 @@
                if(errcode != GL_NO_ERROR) {
                        std::cerr << "OpenGLDisplay: Error code from OpenGL: 
" << gluErrorString(errcode) << std::endl;
                }
+               
+               // glXWaitGL();
+               // XSync( x_display, false );
        }
 }

Modified: branches/itanium2/Engine/Display/GLXImageDisplay.h
==============================================================================
--- branches/itanium2/Engine/Display/GLXImageDisplay.h  (original)
+++ branches/itanium2/Engine/Display/GLXImageDisplay.h  Thu Jun 16 03:54:12 
2005
@@ -19,16 +19,26 @@
                GLXContext  glx_context;
                GLXDrawable glx_drawable; // Or window id.
                Display     *x_display;
+               XVisualInfo *x_visual_info;
+               int          x_screen;
+               
+               int manta_channel; // The last channel number to call 
setupDisplayChannel.
                
        public:
                // Note that the GLXImage display must be passed a GLX 
context by the
                // application it is embedded inside of.
-               GLXImageDisplay( GLXContext glx_context_, GLXDrawable 
glx_drawable_, Display *x_display_ );
+               GLXImageDisplay( XVisualInfo *x_visual_info_, 
+                                                                             
   GLXContext glx_context_, 
+                                GLXDrawable glx_drawable_, 
+                                                                             
   Display *x_display_, int x_screen_ );
                ~GLXImageDisplay();
                
                // Manta ImageDisplay interface.
     void setupDisplayChannel( SetupContext &context );
     void displayImage( const DisplayContext &context, const Image* image );
+               
+               // Accessors.
+               int getMantaChannel() const { return manta_channel; } // NOT 
THREAD SAFE.
        };
 };
 

Modified: branches/itanium2/Interface/CMakeLists.txt
==============================================================================
--- branches/itanium2/Interface/CMakeLists.txt  (original)
+++ branches/itanium2/Interface/CMakeLists.txt  Thu Jun 16 03:54:12 2005
@@ -47,6 +47,8 @@
         UserInterface.h
         UserInterface.cc
         XWindow.h
+        Callback.h
+        CallbackHelpers.h
         )
 
 TARGET_LINK_LIBRARIES(Manta_Interface SCIRun_Core)

Modified: branches/itanium2/Interface/Callback.h
==============================================================================
--- branches/itanium2/Interface/Callback.h      (original)
+++ branches/itanium2/Interface/Callback.h      Thu Jun 16 03:54:12 2005
@@ -25,6 +25,12 @@
       return new Callback_0Data_2Arg<T, Arg1, Arg2>(ptr, pmf, arg1, arg2);
     }
 
+               template<class T, typename Arg1, typename Arg2, typename 
Arg3, typename Arg4> static
+    CallbackBase_0Data*
+    create(T* ptr, void (T::*pmf)(Arg1, Arg2, Arg3, Arg4), Arg1 arg1, Arg2 
arg2, Arg3 arg3, Arg4 arg4) {
+      return new Callback_0Data_4Arg<T, Arg1, Arg2, Arg3, Arg4>(ptr, pmf, 
arg1, arg2, arg3, arg4);
+    }
+
     template<class T, typename Data1> static
     CallbackBase_1Data<Data1>*
     create(T* ptr, void (T::*pmf)(Data1)) {

Modified: branches/itanium2/Interface/CallbackHelpers.h
==============================================================================
--- branches/itanium2/Interface/CallbackHelpers.h       (original)
+++ branches/itanium2/Interface/CallbackHelpers.h       Thu Jun 16 03:54:12 
2005
@@ -181,6 +181,29 @@
     Arg2 arg2;
   };
 
+       template<class T, typename Arg1, typename Arg2, typename Arg3, 
typename Arg4 >
+               class Callback_0Data_4Arg : public CallbackBase_0Data {
+       public:
+                       Callback_0Data_4Arg(T* ptr, void (T::*pmf)(Arg1, 
Arg2, Arg2, Arg4), Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
+      : ptr(ptr), pmf(pmf), arg1(arg1), arg2(arg2), arg3(arg3), arg4(arg4)
+    {
+    }
+                       virtual ~Callback_0Data_4Arg()
+    {
+    }
+                       virtual void call()
+    {
+                               (ptr->*pmf)(arg1, arg2, arg3, arg4);
+    }
+               private:
+                       T* ptr;
+                       void (T::*pmf)(Arg1, Arg2, Arg3, Arg4);
+                       Arg1 arg1;
+                       Arg2 arg2;
+                       Arg3 arg3;
+                       Arg4 arg4;
+               };
+
   // 1 Data
   template<class T, typename Data1>
   class Callback_1Data_0Arg : public CallbackBase_1Data<Data1> {

Modified: branches/itanium2/Interface/Fragment.cc
==============================================================================
--- branches/itanium2/Interface/Fragment.cc     (original)
+++ branches/itanium2/Interface/Fragment.cc     Thu Jun 16 03:54:12 2005
@@ -1,5 +1,5 @@
 
-#include <Packages/manta/Interface/Fragment.h>
+#include <Interface/Fragment.h>
 #include <Core/Util/FancyAssert.h>
 
 using namespace Manta;

Modified: branches/itanium2/Interface/HitInfo.cc
==============================================================================
--- branches/itanium2/Interface/HitInfo.cc      (original)
+++ branches/itanium2/Interface/HitInfo.cc      Thu Jun 16 03:54:12 2005
@@ -1,4 +1,4 @@
 
-#include <Packages/manta/Interface/HitInfo.h>
+#include <Interface/HitInfo.h>
 
 using namespace Manta;

Modified: branches/itanium2/Interface/HitInfo.h
==============================================================================
--- branches/itanium2/Interface/HitInfo.h       (original)
+++ branches/itanium2/Interface/HitInfo.h       Thu Jun 16 03:54:12 2005
@@ -2,6 +2,7 @@
 #ifndef Manta_Interface_HitInfo_h
 #define Manta_Interface_HitInfo_h
 
+#include <MantaTypes.h>
 #include <Interface/Parameters.h>
 #include <Core/Util/Assert.h>
 #include <stdlib.h>

Modified: branches/itanium2/fox/FMantaImageFrame.cc
==============================================================================
--- branches/itanium2/fox/FMantaImageFrame.cc   (original)
+++ branches/itanium2/fox/FMantaImageFrame.cc   Thu Jun 16 03:54:12 2005
@@ -13,6 +13,7 @@
 FXDEFMAP(FMantaImageFrame) FMantaImageFrameMap[] = {
        
//////////////////////////////////////////////////////////////////////////////
        //        Message_Type ID                                 
Message_Handler
+       FXMAPFUNC(SEL_CONFIGURE,           FMantaImageFrame::ID_IMAGE, 
FMantaImageFrame::onConfigure ),
        FXMAPFUNC(SEL_LEFTBUTTONRELEASE,   FMantaImageFrame::ID_IMAGE, 
FMantaImageFrame::onMouseChange ),
        FXMAPFUNC(SEL_MIDDLEBUTTONRELEASE, FMantaImageFrame::ID_IMAGE, 
FMantaImageFrame::onMouseChange ),
        FXMAPFUNC(SEL_RIGHTBUTTONRELEASE,  FMantaImageFrame::ID_IMAGE, 
FMantaImageFrame::onMouseChange ),
@@ -23,9 +24,24 @@
 
 // Constructor, creates a GLX Visual with a double buffer.
 FMantaImageFrame::FMantaImageFrame( FXComposite *p, FXApp *app, int width, 
int height, RTRTInterface *manta_interface_ ) 
-       : FXGLCanvas( p, new FXGLVisual( app, VISUAL_DOUBLEBUFFER ), this, 
ID_IMAGE, LAYOUT_FILL, 0, 0, width, height ),
+       : FXGLCanvas( p, new FXGLVisual( app, VISUAL_DOUBLEBUFFER ), this, 
ID_IMAGE, 
+                     LAYOUT_FILL, 0, 0, width, height ),
          manta_interface( manta_interface_ ) 
 {
+}
+
+// Fox event on window resize.
+long FMantaImageFrame::onConfigure  ( FXObject *sender, FXSelector sel, void 
*data ) {
+
+       // Send a transaction to manta, notifying change resolution.
+       manta_interface->addTransaction("resize",
+                                                                             
                                                          Callback::create( 
manta_interface, 
+                                                                             
                                                                              
                                                    
&RTRTInterface::changeResolution,
+                                                                             
                                                                              
                                                    manta_channel,
+                                                                             
                                                                              
                                                    getWidth(),
+                                                                             
                                                                              
                                                    getHeight(),
+                                                                             
                                                                              
                                                    true ) );
+       return 1;
 }
 
 // Default implementations of the on mouse change and key press.

Modified: branches/itanium2/fox/FMantaImageFrame.h
==============================================================================
--- branches/itanium2/fox/FMantaImageFrame.h    (original)
+++ branches/itanium2/fox/FMantaImageFrame.h    Thu Jun 16 03:54:12 2005
@@ -19,6 +19,9 @@
                // Pointer to the Manta interface to send commands.
                RTRTInterface *manta_interface;
                
+               // Manta channel number.
+               int manta_channel;
+               
        public: 
                // Message types.
                enum {
@@ -31,13 +34,16 @@
                FMantaImageFrame( FXComposite *p, FXApp *app, int width, int 
height, RTRTInterface *manta_interface_ );
                
                // Fox message handlers for mouse and keyboard.
+               long onConfigure  ( FXObject *sender, FXSelector sel, void 
*data );
                long onMouseChange( FXObject *sender, FXSelector sel, void 
*data );
          long onKeyPress   ( FXObject *sender, FXSelector sel, void *data );
                
                // Accessors.
-               void setMantaInterface( RTRTInterface *manta_interface_ ) { 
manta_interface = manta_interface_; };
+               void setMantaInterface( RTRTInterface *manta_interface_, int 
manta_channel_ ) { 
+                       manta_interface = manta_interface_; manta_channel = 
manta_channel_; };
                
                RTRTInterface *getMantaInterface() { return manta_interface; 
};
+               int            getMantaChannel  () { return manta_channel;   
};
        };
 
 };

Modified: branches/itanium2/fox/FMantaWindow.cc
==============================================================================
--- branches/itanium2/fox/FMantaWindow.cc       (original)
+++ branches/itanium2/fox/FMantaWindow.cc       Thu Jun 16 03:54:12 2005
@@ -18,7 +18,8 @@
                                                                              
                                  FXIcon *ic,FXIcon *mi,FXuint opts,FXint 
x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb,FXint hs,FXint 
vs )
        : FXMainWindow( app, name, ic, mi, opts, x, y, w, h, pl, pr, pt, pb, 
hs, vs ),
        
-         manta_interface( 0 )
+         manta_interface( 0 ),
+               fast_quit( false ) 
 {
        // Menu Bar.
        menu_bar = new FXMenuBar( this, LAYOUT_FILL_X );

Modified: branches/itanium2/fox/FMantaWindow.h
==============================================================================
--- branches/itanium2/fox/FMantaWindow.h        (original)
+++ branches/itanium2/fox/FMantaWindow.h        Thu Jun 16 03:54:12 2005
@@ -27,9 +27,7 @@
                
                // Other manta pipeline components which the application 
"controls"
                // (Transactions must be sent through manta in order to 
manipulate
-               // these components.
-               GLXImageDisplay *manta_image_display;
-               
+               // these components
                
                // Fox GUI Components.
                FXMenuBar  *menu_bar;
@@ -39,6 +37,8 @@
                // Image panels for displaying output.
                FMantaImageFrame *manta_frame;
                
+               bool fast_quit;
+               
        public:
                // Commands for the main window.
                enum {
@@ -48,8 +48,9 @@
                
                // Constructors.
                FMantaWindow() : manta_interface( 0 ) {  };
-               FMantaWindow( FXApp *app, const FXString &name, int width = 
512, int height = 512,
-                             FXIcon *ic=NULL,FXIcon *mi=NULL,FXuint 
opts=(DECOR_TITLE|DECOR_MINIMIZE|DECOR_MAXIMIZE|DECOR_BORDER|DECOR_SHRINKABLE|DECOR_STRETCHABLE|DECOR_MENU),FXint
 x=20,FXint y=20,FXint w=512,FXint h=512,FXint pl=0,FXint pr=0,FXint 
pt=0,FXint pb=0,FXint hs=0,FXint vs=0);
+               FMantaWindow( FXApp *app, const FXString &name, int width = 
256, int height = 256,
+                             FXIcon *ic=NULL,FXIcon *mi=NULL,FXuint 
opts=(DECOR_TITLE|DECOR_MINIMIZE|DECOR_MAXIMIZE|DECOR_BORDER|DECOR_SHRINKABLE|DECOR_STRETCHABLE|DECOR_MENU),
+                                                                       FXint 
x=20,FXint y=20,FXint w=256,FXint h=256,FXint pl=0,FXint pr=0,FXint 
pt=0,FXint pb=0,FXint hs=0,FXint vs=0);
                
                // Create the window.
                void create() { FXMainWindow::create(); show( 
PLACEMENT_DEFAULT ); };
@@ -58,7 +59,8 @@
                long onQuit( FXObject *sender, FXSelector key, void *data );
                
                // Accessors.
-               void setMantaInterface( RTRTInterface *manta_interface_ ) { 
manta_interface = manta_interface_; manta_frame->setMantaInterface( 
manta_interface_ ); };
+               void setMantaInterface( RTRTInterface *manta_interface_, int 
manta_channel_ ) { 
+                       manta_interface = manta_interface_; 
manta_frame->setMantaInterface( manta_interface_, manta_channel_ ); };
                
                RTRTInterface    *getMantaInterface() { return 
manta_interface; };
                FMantaImageFrame *getMantaFrame()     { return manta_frame; };

Modified: branches/itanium2/fox/fox_manta.cc
==============================================================================
--- branches/itanium2/fox/fox_manta.cc  (original)
+++ branches/itanium2/fox/fox_manta.cc  Thu Jun 16 03:54:12 2005
@@ -11,6 +11,10 @@
 
 #include <fox/FMantaWindow.h>
 
+#include <string>
+#include <stdlib.h>
+
+
 using namespace FX;
 using namespace fox_manta;
 using namespace Manta;
@@ -19,12 +23,29 @@
 
 int main( int argc, char *argv[]) {
 
+       // Parse args.
+       int np = 1;
+       
+       // Look for specific args.
+       for (int i=0;i<argc;++i) {
+               string arg = argv[i];
+               if (arg == "-np") {
+                       np = atoi( argv[++i] );
+               }
+       }
+       
+       std::cerr << "Using " << np << " workers plus one gui thread." << 
std::endl;
+
+       
/////////////////////////////////////////////////////////////////////////////
        // Make a fox application object.
        FXApp app( "", "Abe Stephens -- SGI" );
        app.init( argc, argv );
 
+       int width = 256;
+       int height = 256;
+
        // Add an FMantaWindow.
-       FMantaWindow manta_window( &app, "Fox/Manta Demo App" );
+       FMantaWindow manta_window( &app, "Fox/Manta Demo App", width, height 
);
 
        // Create the application's windows.
        app.create();
@@ -33,7 +54,7 @@
        RTRTInterface *manta_interface = createRTRT();
        
        manta_interface->setScenePath         (".");
-       manta_interface->changeNumWorkers     ( 1 );
+       manta_interface->changeNumWorkers     ( np );
        manta_interface->selectImageType      ( "rgba8" );
        manta_interface->selectLoadBalancer   ( "workqueue" );
        manta_interface->selectImageTraverser ( "tiled" );
@@ -47,18 +68,21 @@
        FMantaImageFrame *manta_frame = manta_window.getMantaFrame();
        
        // Create a glx image display.
-       GLXImageDisplay glx_image_display( 
(GLXContext)manta_frame->getContext(), 
-                                          (Window)    manta_frame->id(),
-                                                                             
                                                                   (Display 
*) app.getDisplay() );
+       GLXImageDisplay glx_image_display( (XVisualInfo 
*)manta_frame->getVisual()->getInfo(),
+                                                                             
                                                                   
(GLXContext)   manta_frame->getContext(),
+                                     (Window)       manta_frame->id(),
+                                                                             
                                                                   (Display 
*)    app.getDisplay(), 
+                                                                             
                                                                   0 );
        
        // Create manta channel for the interface.
-       manta_interface->createChannel( &glx_image_display, camera, false, 
512, 512 );
+       int manta_channel = 0; // !!! See XWindowUI.cc line: 586
+       manta_interface->createChannel( &glx_image_display, camera, false, 
width, height );
        
        // Create a default scene.
        manta_interface->setScene( createDefaultScene() );
        
        // Set the manta interface for the application.
-       manta_window.setMantaInterface( manta_interface );
+       manta_window.setMantaInterface( manta_interface, manta_channel );
        
        // Start up manta.
        manta_interface->beginRendering(false);




  • [MANTA] r387 - in branches/itanium2: Engine/Display Interface fox, abe, 06/16/2005

Archive powered by MHonArc 2.6.16.

Top of page