Login  Register

Jogl and JavaFX

Posted by Sweck on Mar 31, 2020; 6:50pm
URL: https://forum.jogamp.org/Jogl-and-JavaFX-tp4040468.html

I heared its possible to integrate Jogl into JavaFX with the NewtCanvasJFX but I can't get it to work.
I tried something like that.

  @Override
   public void start(Stage primaryStage) throws Exception{
       Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
       primaryStage.setTitle("JavaFX Jogl");
       primaryStage.setScene(new Scene(root, 300, 275));
       primaryStage.show();
     
       //init Canvas
       final GLProfile glProfile = GLProfile.getDefault();
       final GLCapabilities capabilities = new GLCapabilities(glProfile);

       GLWindow glWindow = GLWindow.create(capabilities);

       NewtCanvasJFX glPanel = new NewtCanvasJFX(glWindow);
       glPanel.setWidth(300);
       glPanel.setHeight(300);
     
       StackPane openGLPane = new StackPane();
       openGLPane.getChildren().add(glPanel);

       glWindow.addGLEventListener(this);
  }

I just need to get jogl and Javafx working together for a university project so if anyone has other solutions I would really appreciate them.