MantisBT - VTK
View Issue Details
0000619VTK(No Category)public2004-02-23 04:162011-01-13 17:00
robert.nelson 
Mathieu Malaterre 
highmajoralways
closedfixed 
 
 
0000619: Java does not work with VTK on Mac OS X
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);
   }
}
No tags attached.
patch java.patch (855) 1969-12-31 19:00
https://www.vtk.org/Bug/file/5052/java.patch
Issue History
2007-08-28 14:17Zack GalbreathProject@8@ => VTK
2007-08-28 14:17Zack GalbreathAssigned ToCharles Law => Mathieu Malaterre
2007-08-28 14:17Zack GalbreathStatus@80@ => closed
2007-08-28 14:17Zack GalbreathResolutionwon't fix => fixed
2007-08-28 14:17Zack GalbreathSummaryGoodsite => Java does not work with VTK on Mac OS X
2007-08-28 14:18Zack GalbreathNote Deleted: 0008258
2010-11-29 17:59Mathieu MalaterreSource_changeset_attached => VTK master 30b322a6
2011-01-13 17:00Source_changeset_attached => VTK master a2bd8391
2011-01-13 17:00Source_changeset_attached => VTK master 020ef709
2011-06-16 13:11Zack GalbreathCategory => (No Category)

Notes
(0000700)
Mathieu Malaterre   
2004-02-24 11:06   
I was not able to compile VTK on MAC unless applying this patch. I'll commit this to the CVS.
(0000702)
Mathieu Malaterre   
2004-02-24 18:40   
Patch commited to CVS. Now Carbon is fine.
What are you env var Robert ?
I am using
export CLASSPATH=~/Programs/VTK-gcc-carbon/bin/vtk.jar:.
export DYLD_LIBRARY_PATH=~/Programs/VTK-gcc-carbon/bin
export LD_LIBRARY_PATH=~/Programs/VTK-gcc-carbon/bin

Carbon is display is fine. Cocoa is not displaying anything but I suspect again a problem of proper bundling. I suggest we close this bug.
(0000703)
robert.nelson   
2004-02-25 08:18   
I only build one set of VTK libraries and classes at a time, so I must be picking up the correct ones.

I'm using VTK v4.2 so it could be that. If I switch to v4.4 (and patch it) will it work or do I need the latest code from CVS?

For me COCOA crashes but again that is probably the version of VTK. Is "proper bundling" something that is being fixed under another bug? If so which?
(0001081)
Mathieu Malaterre   
2004-05-19 06:20   
Cmake recently add the MACBUNDLE: see bug #595