forked from processing/processing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGLW.java
More file actions
52 lines (40 loc) · 1.35 KB
/
GLW.java
File metadata and controls
52 lines (40 loc) · 1.35 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
package processing.glw;
import processing.core.PGraphics;
import com.jogamp.newt.opengl.GLWindow;
import java.util.HashMap;
public class GLW {
static public final String RENDERER = "processing.glw.PGraphicsGLW";
static public final String OPENGL = "processing.glw.PGraphicsGLW";
static public final String P2D = "processing.glw.PGraphics2D";
static public final String P3D = "processing.glw.PGraphics3D";
static protected HashMap<PGraphics, GLWindow> windows =
new HashMap<PGraphics, GLWindow>();
public GLW() {
}
static public void createWindow(PGraphics pg) {
if (pg instanceof PGraphics2D || pg instanceof PGraphics3D) {
windows.put(pg, null);
} else {
throw new RuntimeException("Only GLW.P2D or GLW.P3D surfaces can be attached to a window");
}
}
static public GLWindow getWindow(PGraphics pg) {
return windows.get(pg);
}
static public boolean isFocused(PGraphics pg) {
GLWindow win = windows.get(pg);
return win != null && win.hasFocus();
}
static public PGraphics getFocusedGraphics() {
for (PGraphics pg: windows.keySet()) {
if (isFocused(pg)) return pg;
}
return null;
}
static public GLWindow getFocusedWindow() {
for (PGraphics pg: windows.keySet()) {
if (isFocused(pg)) return windows.get(pg);
}
return null;
}
}