From: Alexandre Naaman (naaman++at++laplace.engr.sgi.com)
Date: 01/07/2002 10:10:10
Hi Harry,
Can you tell Java what visual to use for the DrawingSurface? With respect
to your comments about how to setup this stuff, if you are using version
2.5 you can check out the source to the libpfx library in the following
directory:
/usr/share/Performer/src/lib/libpfx/
pfMotifViewer.C, pfGTKViewer.C and pfViewkitViewer.C may be of some help
to you...
You may want to run Performer in a highly verbose mode (PFNFYLEVEL 6)
to see where exactly the problem lies.
Are you certain the window(s) are realized before you call
pfWinWSDrawable()? (at first glance it looks like it otherwise the X
drawing routines would fail as well ... ) Can you call something like
XSync() and XMapWindow()/XRaiseWindow()?
How about running in SP mode. (just out of curiosity, which platform are
you running on?)
A+,
Alex.
> >
> > Hi Harry,
> >
> > You need to call pfPipeWindow::setWSDrawable() and
> > pfPipeWindow::setWSWindow().
> >
> > Good luck,
> >
> > Alex.
> >
>
> I've been stumbling around in the dark with this for a while, as the
> documentation's a little sparse, and there's a shortage of examples. The
> problems are in my performer code, rather than at the Java end. Here's a
> code fragment, based on a Sun example that draws onto a java canvas - if
> anyone can steer me in the right direction to getting the performer bit
> working I'd be most greatful. The call to pfPWinWSDrawable causes an
> exception - how should I be using it ?
>
> Thanks.
>
> #include "MyCanvas.h"
>
> #include "jawt_md.h"
>
> // #include "visualisation.h"
>
> // #include "scene.h"
>
> #include <Performer/pf.h>
>
> #include <Performer/pfutil.h>
>
> #include <Performer/pfdu.h>
>
> #include <Performer/pfui.h>
>
>
>
>
>
>
> /*
>
> * Class: MyCanvas
>
> * Method: paint
>
> * Signature: (Ljava/awt/Graphics;)V
>
> */
>
> JNIEXPORT void JNICALL Java_MyCanvas_paint
>
> (JNIEnv* env, jobject canvas, jobject graphics)
>
> {
>
> JAWT awt;
>
> JAWT_DrawingSurface* ds;
>
> JAWT_DrawingSurfaceInfo* dsi;
>
> JAWT_X11DrawingSurfaceInfo* dsi_x11;
>
> jboolean result;
>
> jint lock;
>
> GC gc;
>
>
> short i;
>
> char *testString = "^^^ rendered from native code ^^^";
>
> int returnVal;
>
> /* handle for pipe window */
>
> pfPipeWindow *pipeWindow = NULL;
>
> /* pointer to a pipe */
>
> pfPipe* pipe = NULL;
>
>
> /* pointer to a channel */
>
> pfChannel* chan0 = NULL;
>
>
> /* Get the AWT */
>
> awt.version = JAWT_VERSION_1_3;
>
> if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
>
> printf("AWT Not found\n");
>
> return;
>
> }
>
> /* Get the drawing surface */
>
> ds = awt.GetDrawingSurface(env, canvas);
>
> if (ds == NULL) {
>
> printf("NULL drawing surface\n");
>
> return;
>
> }
>
> /* Lock the drawing surface */
>
> lock = ds->Lock(ds);
>
> if((lock & JAWT_LOCK_ERROR) != 0) {
>
> printf("Error locking surface\n");
>
> awt.FreeDrawingSurface(ds);
>
> return;
>
> }
>
> /* Get the drawing surface info */
>
> dsi = ds->GetDrawingSurfaceInfo(ds);
>
> if (dsi == NULL) {
>
> printf("Error getting surface info\n");
>
> ds->Unlock(ds);
>
> awt.FreeDrawingSurface(ds);
>
> return;
>
> }
>
> /* Get the platform-specific drawing info */
>
> dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
>
>
>
> /* Now paint */
>
> //gc = XCreateGC(dsi_x11->display, dsi_x11->drawable, 0, 0);
>
>
>
> // ***** Performer stuff *****
>
> /* initialise performer */
>
> pfInit( );
>
> pfuInit( );
>
> pfiInit( );
>
> /* Initialise file loaders */
>
> pfdInitConverter( "XXX.flt" );
>
> pfdInitConverter( "XXX.pfb" );
>
> pfConfig( );
>
> // create and configure pipe
>
> pipe = pfGetPipe( 0 );
>
> //pfConfig( );
>
> // Associate pipewindow with the pipe
>
> pipeWindow = pfNewPWin( pipe );
>
> // Create performer window
>
> pfPWinType( pipeWindow, PFPWIN_TYPE_X );
>
> // Associate the channel with the pipe
>
> chan0 = pfNewChan( pipe ) ;
>
> // Associate the channel and pipe window so the channel is
>
> // drawn in it
>
> pfAddChan( pipeWindow, chan0 );
>
> //Do I need to do pfOpenPWin ?
>
> //pfOpenPWin( pipeWindow );
>
> //this causes exception
>
> //pfPWinWSDrawable( pipeWindow, NULL, dsi_x11->drawable );
>
> //pfPWinWSWindow( pipeWindow, NULL, dsi_x11->drawable );
>
> //pfFrame( );
>
> /*
>
> //this bit does some X drawing, but I want performer to draw instead
>
> XSetBackground( dsi_x11->display, gc, 0 );
>
> for( i=0; i<36;i++ )
>
> {
>
> XSetForeground( dsi_x11->display, gc, 10*i );
>
> XFillRectangle( dsi_x11->display, dsi_x11->drawable, gc,
>
> 10*i, 5, 90, 90 );
>
> }
>
> XSetForeground( dsi_x11->display, gc, 155 );
>
> XDrawImageString( dsi_x11->display, dsi_x11->drawable, gc,
>
> 100, 110, testString, strlen( testString ) );
>
> XFreeGC( dsi_x11->display, gc );
>
>
>
> // Free the drawing surface info
>
> ds->FreeDrawingSurfaceInfo( dsi );
>
> // Unlock the drawing surface
>
> ds->Unlock( ds );
>
> // Free the drawing surface
>
> awt.FreeDrawingSurface( ds );
>
> */
>
> }
>
>
> -----------------------------------------------------------------------
> List Archives, Info, FAQ: http://www.sgi.com/software/performer/
> Open Development Project: http://oss.sgi.com/projects/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com
> -----------------------------------------------------------------------
>
This archive was generated by hypermail 2b29 : Mon Jan 07 2002 - 15:03:19 PST