Java does not work with VTK on Mac OS X
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
I have OS X version 10.2.8 and Java v1.4.1_01-69.1
I had to perform the following hack (found in the mailing list archive) to get the java bindings to build: > in VTK/Common/vtkJavaAwt.h change lines 86 through 88 from:- > > JAWT_MacDrawingSurfaceInfo* dsi_mac; > dsi_mac = (JAWT_MacDrawingSurfaceInfo*)dsi->platformInfo; > temp0->SetWindowId((void )dsi_mac->fQDWindow); > > to:- > > JAWT_MacOSXDrawingSurfaceInfo dsi_mac; > dsi_mac = (JAWT_MacOSXDrawingSurfaceInfo*)dsi->platformInfo; > temp0->SetWindowId((void *)dsi_mac->cgWindowID);
I then have something which does not work. The program I want to run is too large so I've created the following program which works on the PC - you get a Cone which can be rotated with the mouse. Under CARBON I just get a blank window. Under COCOA I get a bus error: #0 0x90986b18 in glMatrixMode () #1 0x0668159c in vtkCocoaRenderWindow::OpenGLInit() () #2 0x06681bd0 in vtkCocoaRenderWindow::WindowInitialize() () #3 0x06680b38 in vtkCocoaRenderWindow::Start() () #4 0x066449ec in vtkRenderWindow::DoStereoRender() () #5 0x066449b0 in vtkRenderWindow::DoFDRender() () #6 0x066445c4 in vtkRenderWindow::DoAARender() () #7 0x06643dcc in vtkRenderWindow::Render() () ...
The program is: import java.awt.; import javax.swing.;
public class ConeFrame extends JFrame { public ConeFrame() { }
public static void main(String [] args) {
ConePanel panel= new ConePanel();
panel.drawMe();
JFrame frame= new ConeFrame();
frame.getContentPane().add(panel);
frame.setSize(600,600);
frame.show();
}
} and: import vtk.; import java.awt.;
public class ConePanel extends vtk.vtkPanel { public ConePanel(){ }
public void drawMe () {
vtkConeSource cone = new vtkConeSource();
cone.SetHeight( 3.0 );
cone.SetRadius( 1.0 );
cone.SetResolution( 10 );
vtkPolyDataMapper coneMapper = new vtkPolyDataMapper();
coneMapper.SetInput( cone.GetOutput() );
vtkActor coneActor = new vtkActor();
coneActor.SetMapper( coneMapper );
vtkRenderer ren1 = GetRenderer(); //new vtkRenderer();
ren1.AddActor( coneActor );
ren1.SetBackground( 0.1, 0.2, 0.4 );
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
}
}