[vtkusers] VTK with JAVA on MAC OSX
Daniel Sáez Domingo
dsaez at iti.upv.es
Wed Sep 18 12:13:37 EDT 2002
Hello
Sorry about asking you another time but I haven't solved my problems with
VTK and MAC OSX yet.
I have problems with Wrap java.
I have done all the changes you recommend in a mail:
vtkJavaUtil.cxx:
|| defined(__MACH__)
vtkJavaAwt.h:
#elif defined(VTK_USE_CARBON)
jawt_MacDrawingSurfaceInfo* dsi_mac;
dsi_mac = (jawt_MacDrawingSurfaceInfo*)dsi->platformInfo;
temp0->SetWindowId((void *)dsi_mac->fQDWindow);
and I have set the following variable paths:
Variable Name: JAVA_AWT_INCLUDE_PATH
Description: What is the path where the file jawt.h can be found
Current Value:
/System/Library/Frameworks/JavaEmbedding.framework/Versions/A/Headers
New Value (Enter to keep current value):
Variable Name: JAVA_AWT_LIBRARY
Description: Where can the jawt library be found
Current Value: -framework JavaEmbedding
New Value (Enter to keep current value):
Variable Name: JAVA_INCLUDE_PATH
Description: What is the path where the file jni.h can be found
Current Value: /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers
New Value (Enter to keep current value):
Variable Name: JAVA_INCLUDE_PATH2
Description: What is the path where the file jni_md.h can be found
Current Value: /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/
New Value (Enter to keep current value):
I have set the environment variables:
setenv CLASSPATH .:/usr/local/src/VTK/java/
setenv DYLD_LIBRARY_PATH /usr/local/src/VTK/bin/
But when I try to execute Wrapping/Java/SimpleVTK,
the next error appears:
Bus error.
Trying to get where this error is produced, I have change Common/vtkJavaAwt.h
introducing couts:
extern "C" JNIEXPORT void JNICALL
Java_vtk_vtkPanel_RenderCreate(JNIEnv *env, jobject canvas, jobject id0)
{
JAWT awt;
JAWT_DrawingSurface* ds;
JAWT_DrawingSurfaceInfo* dsi;
jint lock;
cout << "Entrando en RenderCreate...\n";
// get the render window pointer
vtkRenderWindow *temp0;
temp0 = (vtkRenderWindow *)(vtkJavaGetPointerFromObject(env,id0,(char *)
"vtkRenderWindow"));
cout << "Ya tenemos temp0 asignado.\n";
/* Get the AWT */
awt.version = JAWT_VERSION_1_3;
if (JAWT_GetAWT(env, &awt) == JNI_FALSE)
{
printf("AWT Not found\n");
return;
}
cout << "Ya tenemos awt asignado.\n";
/* Get the drawing surface */
ds = awt.GetDrawingSurface(env, canvas);
if (ds == NULL)
{
printf("NULL drawing surface\n");
return;
}
cout << "Ya tenemos ds asignado.\n";
/* Lock the drawing surface */
lock = ds->Lock(ds);
if((lock & JAWT_LOCK_ERROR) != 0)
{
printf("Error locking surface\n");
awt.FreeDrawingSurface(ds);
return;
}
cout << "Ya tenemos lock asignado";
/* 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;
}
cout << "Ya tenemos dsi asignado.";
// Here is the win32 drawing code
#if defined(_WIN32) || defined(WIN32)
JAWT_Win32DrawingSurfaceInfo* dsi_win;
dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
temp0->SetWindowId((void *)dsi_win->hwnd);
// otherwise use X11 code
#elif defined(VTK_USE_CARBON)
jawt_MacDrawingSurfaceInfo* dsi_mac;
dsi_mac = (jawt_MacDrawingSurfaceInfo*)dsi->platformInfo;
temp0->SetWindowId((void *)dsi_mac->fQDWindow);
#else
JAWT_X11DrawingSurfaceInfo* dsi_x11;
dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
temp0->SetDisplayId((void *)dsi_x11->display);
temp0->SetWindowId((void *)dsi_x11->drawable);
#endif
cout << "Ya sabemos el Id de la ventana.";
cout << "Pre render";
temp0->Render();
cout << "Post render";
/* Free the drawing surface info */
ds->FreeDrawingSurfaceInfo(dsi);
/* Unlock the drawing surface */
ds->Unlock(ds);
/* Free the drawing surface */
awt.FreeDrawingSurface(ds);
cout << "Saliendo de RenderCreate...";
}
And then, when I run SimpleVTK the out is:
Entrando en RenderCreate...
Ya tenemos temp0 asignado.
Ya tenemos awt asignado.
Bus error
This tell us that the error is produced when the function GetDrawingSurface
is called. Do you know why?
Do you think that this is due to my java version?
If I update to OSX 10.2 shwll the problem go?
Thanks and sorry about my english
Daniel Sáez
More information about the vtkusers
mailing list