File: Engine.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 (41 lines) | stat: -rw-r--r-- 1,191 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
36
37
38
39
40
41
package app.f3d.F3D;

public class Engine implements AutoCloseable {
    // Used to load the 'f3d' library on application startup.
    static {
        System.loadLibrary("f3d-java");
    }

    public Engine() {
        mNativeAddress = construct(); // instantiate the native engine
        mScene = new Scene(mNativeAddress);
        mOptions = new Options(mNativeAddress);
        mWindow = new Window(mNativeAddress);
    }

    // The engine class is automatically released using the Java
    // try-with-resources idiom
    // see https://www.baeldung.com/java-try-with-resources
    @Override
    public void close() {
        destroy(mNativeAddress);
    }

    public native void setCachePath(String cachePath);

    static public native void loadPlugin(String plugin);
    static public native void autoloadPlugins();

    public Scene getScene() { return mScene; }
    public Options getOptions() { return mOptions; }
    public Window getWindow() { return mWindow; }

    private native long construct();
    private native void destroy(long nativeAddress);

    private Scene mScene;
    private Options mOptions;
    private Window mWindow;

    private long mNativeAddress;
}