blob: 4510f47a99716fd3c808aad00d5b82b11dbd9e41 (
plain)
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
|
/*
* Portions Copyright (C) 2003 Sun Microsystems, Inc.
* All rights reserved.
*/
package demos.printext;
import java.awt.Frame;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.awt.GLCanvas;
public class PrintExt {
public static void main(String[] args) {
// set argument 'NotFirstUIActionOnProcess' in the JNLP's application-desc tag for example
// <application-desc main-class="demos.j2d.TextCube"/>
// <argument>NotFirstUIActionOnProcess</argument>
// </application-desc>
boolean firstUIActionOnProcess = 0==args.length || !args[0].equals("NotFirstUIActionOnProcess") ;
GLProfile.initSingleton(firstUIActionOnProcess);
Frame frame = new Frame();
GLCanvas canvas = new GLCanvas();
canvas.addGLEventListener(new Listener());
frame.setUndecorated(true);
frame.add(canvas);
frame.setSize(1, 1);
frame.setVisible(true);
}
static class Listener implements GLEventListener {
public void init(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
System.out.println("GL vendor: " + gl.glGetString(GL.GL_VENDOR));
System.out.println("GL version: " + gl.glGetString(GL.GL_VERSION));
System.out.println("GL renderer: " + gl.glGetString(GL.GL_RENDERER));
System.out.println("GL extensions:");
String[] extensions = gl.glGetString(GL.GL_EXTENSIONS).split(" ");
int i = 0;
while (i < extensions.length) {
System.out.print(" ");
String ext = extensions[i++];
System.out.print(ext);
if (i < extensions.length) {
for (int j = 0; j < (40 - ext.length()); j++) {
System.out.print(" ");
}
System.out.println(extensions[i++]);
} else {
System.out.println();
}
}
runExit();
}
public void dispose(GLAutoDrawable drawable) {
}
public void display(GLAutoDrawable drawable) {
}
public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
}
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
}
}
private static void runExit() {
// Note: calling System.exit() synchronously inside the draw,
// reshape or init callbacks can lead to deadlocks on certain
// platforms (in particular, X11) because the JAWT's locking
// routines cause a global AWT lock to be grabbed. Run the
// exit routine in another thread.
new Thread(new Runnable() {
public void run() {
System.exit(0);
}
}).start();
}
}
|