Jogamp
NewtVersionActivity: Remove 'gears' test; Version Info: Drop NativeWindow/Newt Versio...
[jogl.git] / src / newt / classes / jogamp / newt / driver / awt / opengl / VersionApplet.java
CommitLineData
4dbb8731 1package jogamp.newt.driver.awt.opengl;
a7398aac 2
a7398aac
SG
3import java.applet.Applet;
4import java.awt.BorderLayout;
8adc0478 5import java.awt.Container;
ea0d252a 6import java.awt.Frame;
8adc0478 7import java.awt.GridLayout;
a7398aac 8import java.awt.TextArea;
ea0d252a
SG
9import java.awt.event.WindowAdapter;
10import java.awt.event.WindowEvent;
8adc0478
SG
11
12import java.util.List;
13
a7398aac
SG
14import javax.media.opengl.GLProfile;
15import javax.media.opengl.awt.GLCanvas;
16import javax.media.opengl.GL;
17import javax.media.opengl.GLAutoDrawable;
8adc0478
SG
18import javax.media.opengl.GLCapabilities;
19import javax.media.opengl.GLCapabilitiesImmutable;
20import javax.media.opengl.GLDrawableFactory;
a7398aac
SG
21import javax.media.opengl.GLEventListener;
22
8adc0478
SG
23import com.jogamp.common.GlueGenVersion;
24import com.jogamp.common.os.Platform;
25import com.jogamp.common.util.VersionUtil;
26import com.jogamp.nativewindow.NativeWindowVersion;
27import com.jogamp.newt.NewtVersion;
28import com.jogamp.opengl.JoglVersion;
29
a7398aac 30public class VersionApplet extends Applet {
ea0d252a 31 static {
a7398aac 32 GLProfile.initSingleton(false);
ea0d252a 33 }
8adc0478
SG
34 TextArea tareaVersion;
35 TextArea tareaCaps;
ea0d252a
SG
36 GLCanvas canvas;
37
38 public static void main(String[] args) {
39 Frame frame = new Frame("JOGL Version Applet");
40 frame.setSize(800, 600);
41 frame.setLayout(new BorderLayout());
42
43 VersionApplet va = new VersionApplet();
44 frame.addWindowListener(new ClosingWindowAdapter(frame, va));
45
46 va.init();
47 frame.add(va, BorderLayout.CENTER);
48 frame.validate();
49
50 frame.setVisible(true);
51 va.start();
52 }
53
54 static class ClosingWindowAdapter extends WindowAdapter {
55 Frame f;
56 VersionApplet va;
57 public ClosingWindowAdapter(Frame f, VersionApplet va) {
58 this.f = f;
59 this.va = va;
60 }
61 public void windowClosing(WindowEvent ev) {
62 f.setVisible(false);
63 va.stop();
64 va.destroy();
65 f.remove(va);
66 f.dispose();
67 System.exit(0);
68 }
69 }
70
71 private synchronized void my_init() {
72 if(null != canvas) { return; }
73
8adc0478
SG
74 GLProfile glp = GLProfile.getDefault();
75 GLCapabilities glcaps = new GLCapabilities(glp);
76
a7398aac
SG
77 setLayout(new BorderLayout());
78 String s;
79
8adc0478 80 tareaVersion = new TextArea(120, 60);
a7398aac
SG
81 s = VersionUtil.getPlatformInfo().toString();
82 System.err.println(s);
8adc0478 83 tareaVersion.append(s);
a7398aac
SG
84
85 s = GlueGenVersion.getInstance().toString();
86 System.err.println(s);
8adc0478 87 tareaVersion.append(s);
a7398aac 88
62df9dd1 89 /*
a7398aac
SG
90 s = NativeWindowVersion.getInstance().toString();
91 System.err.println(s);
62df9dd1
SG
92 tareaVersion.append(NativeWindowVersion.getInstance().toString());
93 */
a7398aac
SG
94
95 s = JoglVersion.getInstance().toString();
96 System.err.println(s);
8adc0478 97 tareaVersion.append(s);
a7398aac 98
62df9dd1 99 /*
a7398aac
SG
100 s = NewtVersion.getInstance().toString();
101 System.err.println(s);
8adc0478 102 tareaVersion.append(s);
62df9dd1 103 */
8adc0478
SG
104
105 tareaCaps = new TextArea(120, 20);
106 GLDrawableFactory factory = GLDrawableFactory.getFactory(glp);
107 List/*<GLCapabilitiesImmutable>*/ availCaps = factory.getAvailableCapabilities(null);
108 for(int i=0; i<availCaps.size(); i++) {
109 s = ((GLCapabilitiesImmutable) availCaps.get(i)).toString();
110 System.err.println(s);
111 tareaCaps.append(s);
112 tareaCaps.append(Platform.getNewline());
113 }
a7398aac 114
8adc0478
SG
115 Container grid = new Container();
116 grid.setLayout(new GridLayout(2, 1));
117 grid.add(tareaVersion);
118 grid.add(tareaCaps);
119 add(grid, BorderLayout.CENTER);
a7398aac 120
8adc0478 121 canvas = new GLCanvas(glcaps);
a7398aac 122 canvas.addGLEventListener(new GLInfo());
dcd98e8c 123 canvas.setSize(10, 10);
a7398aac 124 add(canvas, BorderLayout.SOUTH);
ea0d252a
SG
125 validate();
126 }
127
128 private synchronized void my_release() {
129 if(null!=canvas) {
130 remove(canvas);
131 canvas.destroy();
132 canvas = null;
8adc0478
SG
133 remove(tareaVersion);
134 tareaVersion=null;
ea0d252a
SG
135 }
136 }
137
138 public void init() {
139 System.err.println("VersionApplet: init() - begin");
140 my_init();
a7398aac
SG
141 System.err.println("VersionApplet: init() - end");
142 }
143
144 public void start() {
145 System.err.println("VersionApplet: start() - begin");
146 System.err.println("VersionApplet: start() - end");
147 }
148
149 public void stop() {
a7398aac
SG
150 System.err.println("VersionApplet: stop() - begin");
151 System.err.println("VersionApplet: stop() - end");
152 }
153
154 public void destroy() {
ea0d252a
SG
155 System.err.println("VersionApplet: destroy() - start");
156 my_release();
157 System.err.println("VersionApplet: destroy() - end");
a7398aac
SG
158 }
159
160 class GLInfo implements GLEventListener {
161 public void init(GLAutoDrawable drawable) {
162 GL gl = drawable.getGL();
10c696f7 163 String s = JoglVersion.getGLInfo(gl, null).toString();
a7398aac 164 System.err.println(s);
8adc0478 165 tareaVersion.append(s);
a7398aac
SG
166 }
167
168 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
169 }
170
171 public void display(GLAutoDrawable drawable) {
172 }
173
174 public void dispose(GLAutoDrawable drawable) {
175 }
176 }
177
178}
http://JogAmp.org git info: FAQ, tutorial and man pages.