From: Harry Overs (hovers++at++taz.qinetiq.com)
Date: 01/04/2002 07:02:21
>
> 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 );
*/
}
This archive was generated by hypermail 2b29 : Fri Jan 04 2002 - 06:54:45 PST