File: TestJavaBindings.java

package info (click to toggle)
f3d 3.2.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,668 kB
  • sloc: cpp: 99,109; python: 811; sh: 342; xml: 238; java: 101; javascript: 95; makefile: 25
file content (35 lines) | stat: -rw-r--r-- 1,032 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import app.f3d.F3D.*;

public class TestJavaBindings {

  static {
    if (System.getProperty("os.name").startsWith("Windows"))
    {
      // On Windows, preload the OpenGL library
      // This ensures the OpenGL used is the one in the working directory if any.
      // In practice, it is used in F3D CI to run the test using Mesa, it's not required for production.
      System.loadLibrary("opengl32");
    }
  }

  public static void main(String[] args) {

    Engine.autoloadPlugins();

    // Always use try-with-resources idiom to ensure the native engine is released
    try (Engine engine = new Engine()) {

      Camera camera = engine.getWindow().getCamera();

      camera.setPosition(new double[] { 0, 1, 2 });
      double[] pos = camera.getPosition();

      assert pos[0] == 0.0 : "Position X is not valid";
      assert pos[1] == 1.0 : "Position Y is not valid";
      assert pos[2] == 2.0 : "Position Z is not valid";

      Scene scene = engine.getScene();
      scene.add(args[0] + "data/cow.vtp");
    }
  }
}