JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
VersionApplet3.java
Go to the documentation of this file.
1package com.jogamp.newt.util.applet3;
2
3import com.jogamp.plugin.applet.Applet3;
4import com.jogamp.plugin.applet.Applet3Context;
5import com.jogamp.plugin.ui.NativeWindowDownstream;
6import com.jogamp.plugin.ui.NativeWindowUpstream;
7
8import java.util.List;
9import java.util.Locale;
10
11import com.jogamp.opengl.GLProfile;
12import com.jogamp.opengl.GL;
13import com.jogamp.opengl.GLAutoDrawable;
14import com.jogamp.opengl.GLCapabilities;
15import com.jogamp.opengl.GLCapabilitiesImmutable;
16import com.jogamp.opengl.GLDrawableFactory;
17import com.jogamp.opengl.GLEventListener;
18
19import com.jogamp.common.GlueGenVersion;
20import com.jogamp.common.util.VersionUtil;
21import com.jogamp.newt.NewtFactory;
22import com.jogamp.newt.Window;
23import com.jogamp.newt.opengl.GLWindow;
24import com.jogamp.opengl.JoglVersion;
25
26public class VersionApplet3 implements Applet3 {
27
28 public static void main(final String[] args) {
29 final VersionApplet3 va = new VersionApplet3();
30
31 final NativeWindowDownstream nwc = va.createNativeWindow(null, new NativeWindowUpstream() {
32 @Override
33 public long getWindowHandle() {
34 return 0;
35 }
36 @Override
37 public int getWidth() {
38 return 64;
39 }
40 @Override
41 public int getHeight() {
42 return 64;
43 }
44 @Override
45 public String getDisplayConnection() {
46 return null; // default
47 }
48 @Override
49 public int getScreenIndex() {
50 return 0; // default
51 }
52 @Override
53 public void notifySurfaceUpdated(final NativeWindowDownstream swappedWin) {
54 // NOP
55 }
56 @Override
57 public int getX() {
58 return 0;
59 }
60 @Override
61 public int getY() {
62 return 0;
63 }
64 });
65 va.init(null);
66 va.start();
67 va.stop();
68 va.destroy();
69 nwc.destroy();
70 }
71
72 GLWindow canvas;
73
74 @Override
75 public NativeWindowDownstream createNativeWindow(final Applet3Context ctx, final NativeWindowUpstream parentWin) {
77 final Window w = NewtFactory.createWindow(parentWin.getDisplayConnection(), parentWin.getScreenIndex(), parentWin.getWindowHandle(), caps);
78 canvas = GLWindow.create(w);
79 canvas.setSize(parentWin.getWidth(), parentWin.getHeight());
80
81 return new NativeWindowDownstream() {
82 @Override
83 public void setVisible(final boolean v) {
84 if( null != canvas ) {
85 canvas.setVisible(v);
86 }
87 }
88
89 @Override
90 public void setSize(final int width, final int height) {
91 if( null != canvas ) {
92 canvas.setSize(width, height);
93 }
94 }
95
96 @Override
97 public void requestFocus() {
98 if( null != canvas ) {
99 canvas.requestFocus();
100 }
101 }
102
103 @Override
104 public void destroy() {
105 if( null != canvas ) {
106 canvas.destroy();
107 }
108 }
109
110 @Override
111 public NativeWindowUpstream getParent() {
112 return parentWin;
113 }
114
115 @Override
116 public long getWindowHandle() {
117 if( null != canvas ) {
118 return canvas.getWindowHandle();
119 } else {
120 return 0;
121 }
122 }
123
124 @Override
125 public void display() {
126 if( null != canvas ) {
127 canvas.display();
128 }
129 }
130
131 @Override
132 public void notifyPositionChanged(final NativeWindowUpstream nw) {
133 if( null != canvas ) {
134 canvas.setPosition(nw.getX(), nw.getY());
135 }
136 }
137 };
138 }
139
140 @Override
141 public void init(final Applet3Context ctx) {
142 System.err.println("VersionApplet: init() - begin");
143 canvas.addGLEventListener(new GLInfo());
144 System.err.println("VersionApplet: init() - end");
145 }
146
147 @Override
148 public void start() {
149 System.err.println("VersionApplet: start() - begin");
150
151 String s;
152
153 s = VersionUtil.getPlatformInfo().toString();
154 System.err.println(s);
155
156 s = GlueGenVersion.getInstance().toString();
157 System.err.println(s);
158
159 /*
160 s = NativeWindowVersion.getInstance().toString();
161 System.err.println(s);
162 */
163
165 System.err.println(s);
166
168 final List<GLCapabilitiesImmutable> availCaps = factory.getAvailableCapabilities(null);
169 for(int i=0; i<availCaps.size(); i++) {
170 s = availCaps.get(i).toString();
171 System.err.println(s);
172 }
173 canvas.display();
174 System.err.println("VersionApplet: start() - end");
175 }
176
177 @Override
178 public void stop() {
179 System.err.println("VersionApplet: stop() - begin");
180 canvas.setVisible(false);
181 System.err.println("VersionApplet: stop() - end");
182 }
183
184 @Override
185 public void destroy() {
186 System.err.println("VersionApplet: destroy() - start");
187 if(null!=canvas) {
188 canvas.destroy();
189 canvas = null;
190 }
191 System.err.println("VersionApplet: destroy() - end");
192 }
193
194 @Override
195 public String getAppletInfo() {
196 return null;
197 }
198
199 @Override
200 public Locale getLocale() {
201 return null;
202 }
203
204 @Override
205 public String[][] getParameterInfo() {
206 return null;
207 }
208
209 static class GLInfo implements GLEventListener {
210 @Override
211 public void init(final GLAutoDrawable drawable) {
212 final GL gl = drawable.getGL();
213 final String s = JoglVersion.getGLInfo(gl, null).toString();
214 System.err.println(s);
215 }
216 @Override
217 public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
218 }
219 @Override
220 public void display(final GLAutoDrawable drawable) {
221 }
222 @Override
223 public void dispose(final GLAutoDrawable drawable) {
224 }
225 }
226}
static Window createWindow(final CapabilitiesImmutable caps)
Create a top level Window entity on the default Display and default Screen.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
Definition: GLWindow.java:121
final void setPosition(final int x, final int y)
Sets the location of the window's client area excluding insets (window decorations) in window units.
Definition: GLWindow.java:525
final void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
Definition: GLWindow.java:625
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
Definition: GLWindow.java:615
final long getWindowHandle()
Returns the window handle for this NativeWindow.
Definition: GLWindow.java:1040
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
Definition: GLWindow.java:605
final void requestFocus()
Request focus for this native window.
Definition: GLWindow.java:416
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Definition: GLWindow.java:169
static void main(final String[] args)
NativeWindowDownstream createNativeWindow(final Applet3Context ctx, final NativeWindowUpstream parentWin)
Specifies a set of OpenGL capabilities.
final List< GLCapabilitiesImmutable > getAvailableCapabilities(AbstractGraphicsDevice device)
Returns an array of available GLCapabilities for the device.
static GLDrawableFactory getFactory(final GLProfile glProfile)
Returns the sole GLDrawableFactory instance.
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
static GLProfile getDefault(final AbstractGraphicsDevice device)
Returns a default GLProfile object, reflecting the best for the running platform.
Definition: GLProfile.java:739
static JoglVersion getInstance()
static StringBuilder getGLInfo(final GL gl, final StringBuilder sb)
StringBuilder toString(final GL gl, StringBuilder sb)
Specifying NEWT's Window functionality:
Definition: Window.java:115
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
GLProfile getGLProfile()
Fetches the GLProfile for this drawable.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.