-
-
Notifications
You must be signed in to change notification settings - Fork 440
Expand file tree
/
Copy pathEngine.java
More file actions
421 lines (363 loc) · 12.5 KB
/
Copy pathEngine.java
File metadata and controls
421 lines (363 loc) · 12.5 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
package app.f3d.F3D;
import java.util.List;
import java.util.Map;
public class Engine implements AutoCloseable {
@FunctionalInterface
public interface ContextFunction {
/**
* Get the address of an OpenGL function by name
* @param name the function name (e.g., "glClear")
* @return the function pointer address as a long
*/
long getProcAddress(String name);
}
public static class LibInfo {
public String version;
public String versionFull;
public String buildDate;
public String buildSystem;
public String compiler;
public Map<String, Boolean> modules;
public String vtkVersion;
public List<String> copyrights;
public String license;
public LibInfo(String version, String versionFull, String buildDate, String buildSystem,
String compiler, Map<String, Boolean> modules, String vtkVersion,
List<String> copyrights, String license) {
this.version = version;
this.versionFull = versionFull;
this.buildDate = buildDate;
this.buildSystem = buildSystem;
this.compiler = compiler;
this.modules = modules;
this.vtkVersion = vtkVersion;
this.copyrights = copyrights;
this.license = license;
}
}
public static class ReaderInfo {
public String name;
public String description;
public List<String> extensions;
public List<String> mimeTypes;
public String pluginName;
public boolean hasSceneReader;
public boolean hasGeometryReader;
public ReaderInfo(String name, String description, List<String> extensions,
List<String> mimeTypes, String pluginName,
boolean hasSceneReader, boolean hasGeometryReader) {
this.name = name;
this.description = description;
this.extensions = extensions;
this.mimeTypes = mimeTypes;
this.pluginName = pluginName;
this.hasSceneReader = hasSceneReader;
this.hasGeometryReader = hasGeometryReader;
}
}
/** Thrown when a window-based operation is called on an engine with no window. */
public static class NoWindowException extends F3DException {
public NoWindowException(String message) { super(message); }
}
/** Thrown when {@link #getInteractor()} is called on an engine with no interactor. */
public static class NoInteractorException extends F3DException {
public NoInteractorException(String message) { super(message); }
}
/** Thrown when a plugin cannot be loaded. */
public static class PluginException extends F3DException {
public PluginException(String message) { super(message); }
}
/** Thrown when the cache path cannot be set or used. */
public static class CacheException extends F3DException {
public CacheException(String message) { super(message); }
}
// Used to load the 'f3d' library on application startup.
static {
System.loadLibrary("f3d-java");
}
private Engine(long nativeAddress) {
mNativeAddress = nativeAddress;
mScene = new Scene(mNativeAddress);
mOptions = new Options(mNativeAddress);
mWindow = new Window(mNativeAddress);
}
/**
* Create an engine with automatic window selection
* @param offscreen if true, window will be hidden
* @return new Engine instance
*/
public static Engine create(boolean offscreen) {
return new Engine(nativeCreate(offscreen));
}
/**
* Create an engine with automatic window selection (non-offscreen)
* @return new Engine instance
*/
public static Engine create() {
return create(false);
}
/**
* Create an engine with no window
* @return new Engine instance
*/
public static Engine createNone() {
return new Engine(nativeCreateNone());
}
/**
* Create an engine with a GLX window (Linux only)
* @param offscreen if true, window will be hidden
* @return new Engine instance
*/
public static Engine createGLX(boolean offscreen) {
return new Engine(nativeCreateGLX(offscreen));
}
/**
* Create an engine with a GLX window (Linux only, non-offscreen)
* @return new Engine instance
*/
public static Engine createGLX() {
return createGLX(false);
}
/**
* Create an engine with a WGL window (Windows only)
* @param offscreen if true, window will be hidden
* @return new Engine instance
*/
public static Engine createWGL(boolean offscreen) {
return new Engine(nativeCreateWGL(offscreen));
}
/**
* Create an engine with a WGL window (Windows only, non-offscreen)
* @return new Engine instance
*/
public static Engine createWGL() {
return createWGL(false);
}
/**
* Create an engine with an offscreen EGL window
* @return new Engine instance
*/
public static Engine createEGL() {
return new Engine(nativeCreateEGL());
}
/**
* Create an engine with an offscreen OSMesa window
* @return new Engine instance
*/
public static Engine createOSMesa() {
return new Engine(nativeCreateOSMesa());
}
/**
* Create an engine with an external context using a custom getProcAddress function
* @param getProcAddress callback function to resolve OpenGL function addresses
* @return new Engine instance
*/
public static Engine createExternal(ContextFunction getProcAddress) {
return new Engine(nativeCreateExternal(getProcAddress));
}
/**
* Create an engine with an external GLX context (Linux only)
* @return new Engine instance
*/
public static Engine createExternalGLX() {
return new Engine(nativeCreateExternalGLX());
}
/**
* Create an engine with an external WGL context (Windows only)
* @return new Engine instance
*/
public static Engine createExternalWGL() {
return new Engine(nativeCreateExternalWGL());
}
/**
* Create an engine with an external COCOA context (macOS only)
* @return new Engine instance
*/
public static Engine createExternalCOCOA() {
return new Engine(nativeCreateExternalCOCOA());
}
/**
* Create an engine with an external EGL context
* @return new Engine instance
*/
public static Engine createExternalEGL() {
return new Engine(nativeCreateExternalEGL());
}
/**
* Create an engine with an external OSMesa context
* @return new Engine instance
*/
public static Engine createExternalOSMesa() {
return new Engine(nativeCreateExternalOSMesa());
}
@Override
public void close() {
nativeDestroy(mNativeAddress);
}
/**
* Set the cache path directory
* @param cachePath path to cache directory
*/
public native void setCachePath(String cachePath);
/**
* Get the cache path directory
* @return path to cache directory
*/
public native String getCachePath();
/**
* Set options for this engine
* @param options the options to set
*/
public native void setOptions(Options options);
/**
* A serializable snapshot of an engine, captured with dump() and applied back with load().
*/
public static class State implements AutoCloseable {
private long mNativeAddress;
private State(long nativeAddress) {
mNativeAddress = nativeAddress;
}
/**
* Build a state from a JSON statefile string
* @param content JSON statefile content to read from
* @return new State instance
*/
public static State fromString(String content) {
return new State(nativeFromString(content));
}
/**
* Build a state from a JSON statefile
* @param filePath path to read the statefile from
* @return new State instance
*/
public static State fromFile(String filePath) {
return new State(nativeFromFile(filePath));
}
/**
* Build a state from the JSON content of the system clipboard
* @return new State instance
*/
public static State fromClipboard() {
return new State(nativeFromClipboard());
}
/**
* Return the state as a JSON statefile string
* @return the state content as a JSON string
*/
@Override
public native String toString();
/**
* Write the state as a JSON statefile
* @param filePath path to write the statefile to
*/
public native void toFile(String filePath);
/**
* Copy the state into the system clipboard as a JSON string
*/
public native void toClipboard();
@Override
public void close() {
nativeDestroy(mNativeAddress);
}
private static native long nativeFromString(String content);
private static native long nativeFromFile(String filePath);
private static native long nativeFromClipboard();
private static native void nativeDestroy(long nativeAddress);
}
/**
* Capture the current engine state
* @return a State capturing the engine
*/
public State dump() {
return new State(nativeDump());
}
/**
* Restore the engine from a previously captured state
* @param state the state to restore from
*/
public void load(State state) {
nativeLoad(state.mNativeAddress);
}
private native long nativeDump();
private native void nativeLoad(long stateAddress);
/**
* Get the options
* @return Options instance
*/
public Options getOptions() { return mOptions; }
/**
* Get the scene
* @return Scene instance
*/
public Scene getScene() { return mScene; }
/**
* Get the window
* @return Window instance
*/
public Window getWindow() { return mWindow; }
/**
* Get the interactor
* @return Interactor instance
*/
public native Interactor getInteractor();
/**
* Load a plugin by path or name
* @param plugin path or name of the plugin
*/
public static native void loadPlugin(String plugin);
/**
* Automatically load all static plugins
*/
public static native void autoloadPlugins();
/**
* List plugins available in the given directory
* @param pluginPath path to search for plugins
* @return list of available plugin names
*/
public static native List<String> getPluginsList(String pluginPath);
/**
* Get information about libf3d
* @return LibInfo object containing library information
*/
public static native LibInfo getLibInfo();
/**
* Get information about supported readers
* @return list of ReaderInfo objects
*/
public static native List<ReaderInfo> getReadersInfo();
/**
* Get list of rendering backends supported by libf3d
* @return map of backend names to availability boolean
*/
public static native Map<String, Boolean> getRenderingBackendList();
/**
* Set a reader option value
* @param name option name
* @param value option value
*/
public static native void setReaderOption(String name, String value);
/**
* Get all reader option names
* @return list of option names
*/
public static native List<String> getAllReaderOptionNames();
// Native methods
private static native long nativeCreate(boolean offscreen);
private static native long nativeCreateNone();
private static native long nativeCreateGLX(boolean offscreen);
private static native long nativeCreateWGL(boolean offscreen);
private static native long nativeCreateEGL();
private static native long nativeCreateOSMesa();
private static native long nativeCreateExternal(ContextFunction getProcAddress);
private static native long nativeCreateExternalGLX();
private static native long nativeCreateExternalWGL();
private static native long nativeCreateExternalCOCOA();
private static native long nativeCreateExternalEGL();
private static native long nativeCreateExternalOSMesa();
private static native void nativeDestroy(long nativeAddress);
// Member variables
private long mNativeAddress;
private Scene mScene;
private Options mOptions;
private Window mWindow;
}