28package com.jogamp.newt.util.applet3;
30import java.util.Locale;
32import com.jogamp.plugin.applet.Applet3;
33import com.jogamp.plugin.applet.Applet3Context;
34import com.jogamp.plugin.ui.NativeWindowDownstream;
35import com.jogamp.plugin.ui.NativeWindowUpstream;
37import com.jogamp.nativewindow.AbstractGraphicsDevice;
38import com.jogamp.nativewindow.AbstractGraphicsScreen;
39import com.jogamp.nativewindow.NativeWindow;
40import com.jogamp.nativewindow.NativeWindowFactory;
41import com.jogamp.nativewindow.WindowClosingProtocol.WindowClosingMode;
42import com.jogamp.nativewindow.util.PointImmutable;
43import com.jogamp.opengl.FPSCounter;
44import com.jogamp.opengl.GLCapabilities;
45import com.jogamp.opengl.GLProfile;
47import com.jogamp.nativewindow.UpstreamWindowHookMutableSizePos;
48import com.jogamp.newt.NewtFactory;
49import com.jogamp.newt.Window;
50import com.jogamp.newt.opengl.GLWindow;
51import com.jogamp.newt.util.applet.JOGLNewtAppletBase;
104 int glXd=Integer.MAX_VALUE, glYd=Integer.MAX_VALUE, glWidth=Integer.MAX_VALUE, glHeight=Integer.MAX_VALUE;
106 boolean glStandalone =
false;
111 final String getParameter(
final String name) {
112 return ctx.getParameter(name);
116 public NativeWindowDownstream
createNativeWindow(
final Applet3Context ctx,
final NativeWindowUpstream upstreamWin) {
119 String glProfileName=
null;
120 boolean glOpaque=
true;
122 int glNumMultisampleBuffer=0;
123 boolean glUndecorated=
false;
124 boolean glAlwaysOnTop=
false;
126 glProfileName = getParameter(
"gl_profile");
136 }
catch (
final Exception e) {
139 glStandalone = Integer.MAX_VALUE>glXd && Integer.MAX_VALUE>glYd && Integer.MAX_VALUE>glWidth && Integer.MAX_VALUE>glHeight;
142 if(0<glNumMultisampleBuffer) {
152 upstreamWin.getWidth(), upstreamWin.getHeight(),
153 upstreamWin.getWidth(), upstreamWin.getHeight());
155 upstreamSizePosHook);
158 System.err.println(
"JOGLNewtApplet3Run Configuration:");
159 System.err.println(
"glStandalone: "+glStandalone);
160 System.err.println(
"glProfileName: "+glProfileName);
161 System.err.println(
"glOpaque: "+glOpaque);
162 System.err.println(
"glAlphaBits: "+glAlphaBits);
163 System.err.println(
"glNumMultisampleBuffer: "+glNumMultisampleBuffer);
164 System.err.println(
"glUndecorated: "+glUndecorated);
165 System.err.println(
"glAlwaysOnTop: "+glAlwaysOnTop);
166 System.err.println(
"UpstreamWin: "+upstreamWin+
", LOS "+upstreamLocOnScreen);
168 System.err.println(
"pos-size: "+glXd+
"/"+glYd+
" "+glWidth+
"x"+glHeight);
176 glWindow.
setSize(browserWin.getWidth(), browserWin.getHeight());
178 return new NativeWindowDownstream() {
180 public void setVisible(
final boolean v) {
181 if(
null != glWindow ) {
187 public void setSize(
final int width,
final int height) {
188 upstreamSizePosHook.
setWinSize(width, height);
189 if(
null != glWindow ) {
190 glWindow.
setSize(width, height);
195 public void requestFocus() {
196 if(
null != glWindow ) {
203 if(
null != glWindow ) {
209 public NativeWindowUpstream getParent() {
214 public long getWindowHandle() {
215 if(
null != glWindow ) {
223 public void display() {
224 if(
null != glWindow ) {
230 public void notifyPositionChanged(
final NativeWindowUpstream nw) {
231 upstreamSizePosHook.
setWinPos(nw.getX(), nw.getY());
232 if(
null != glWindow ) {
240 public void init(
final Applet3Context ctx) {
242 System.err.println(
"JOGLNewtApplet1Run.init() START - "+currentThreadName());
245 String glEventListenerClazzName=
null;
246 int glSwapInterval=1;
247 boolean glDebug=
false;
248 boolean glTrace=
false;
249 boolean glNoDefaultKeyListener =
false;
250 boolean glCloseable=
false;
253 glEventListenerClazzName = getParameter(
"gl_event_listener_class");
259 }
catch (
final Exception e) {
262 if(
null==glEventListenerClazzName) {
263 throw new RuntimeException(
"No applet parameter 'gl_event_listener_class'");
266 System.err.println(
"JOGLNewtApplet1Run Configuration:");
267 System.err.println(
"glEventListenerClazzName: "+glEventListenerClazzName);
268 System.err.println(
"glSwapInterval: "+glSwapInterval);
269 System.err.println(
"glDebug: "+glDebug);
270 System.err.println(
"glTrace: "+glTrace);
271 System.err.println(
"glNoDefaultKeyListener: "+glNoDefaultKeyListener);
272 System.err.println(
"glCloseable: "+glCloseable);
277 glNoDefaultKeyListener,
286 }
catch (
final Throwable t) {
287 throw new RuntimeException(t);
290 System.err.println(
"JOGLNewtApplet1Run.init() END - "+currentThreadName());
294 private static String currentThreadName() {
return "["+Thread.currentThread().getName()+
"]"; }
299 System.err.println(
"JOGLNewtApplet1Run.start() START (isVisible "+glWindow.
isVisible()+
") - "+currentThreadName());
302 glWindow.
setSize(glWidth, glHeight);
308 System.err.println(
"JOGLNewtApplet1Run start:");
310 System.err.println(
"GLWindow: "+glWindow);
314 System.err.println(
"JOGLNewtApplet1Run.start() END - "+currentThreadName());
321 System.err.println(
"JOGLNewtApplet1Run.stop() START - "+currentThreadName());
325 System.err.println(
"JOGLNewtApplet1Run.stop() END - "+currentThreadName());
332 System.err.println(
"JOGLNewtApplet1Run.destroy() START - "+currentThreadName());
341 System.err.println(
"JOGLNewtApplet1Run.destroy() END - "+currentThreadName());
void setBackgroundOpaque(final boolean opaque)
Sets whether the surface shall be opaque or translucent.
void setAlphaBits(final int alphaBits)
Sets the number of bits requested for the color buffer's alpha component.
Provides a pluggable mechanism for arbitrary window toolkits to adapt their components to the NativeW...
static Point getLocationOnScreen(final NativeWindow nw)
static AbstractGraphicsDevice createDevice(final String displayConnection, final boolean own)
Creates a native device type, following getNativeWindowType(true).
static NativeWindow createWrappedWindow(final AbstractGraphicsScreen aScreen, final long surfaceHandle, final long windowHandle, final UpstreamWindowHookMutableSizePos hook)
Creates a wrapped NativeWindow with given native handles and AbstractGraphicsScreen.
static AbstractGraphicsScreen createScreen(final AbstractGraphicsDevice device, int screen)
final void setWinSize(final int winWidth, final int winHeight)
final void setWinPos(final int winX, final int winY)
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,...
Point getLocationOnScreen(final Point storage)
Returns the window's top-left client-area position in the screen.
WindowClosingMode setDefaultCloseOperation(final WindowClosingMode op)
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.
final void setAlwaysOnTop(final boolean value)
final int getX()
Returns the current x position of this window, relative to it's parent.
final int getY()
Returns the current y position of the top-left corner of the client area relative to it's parent in w...
final void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
final boolean isVisible()
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
final void setUndecorated(final boolean value)
final long getWindowHandle()
Returns the window handle for this NativeWindow.
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
final void requestFocus()
Request focus for this native window.
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Simple GLEventListener deployment as an applet using JOGL.
void init(final Applet3Context ctx)
NativeWindowDownstream createNativeWindow(final Applet3Context ctx, final NativeWindowUpstream upstreamWin)
String[][] getParameterInfo()
static final boolean DEBUG
Shows how to deploy an applet using JOGL.
static int str2Int(final String str, final int def)
void init(final GLWindow glWindow)
static final boolean DEBUG
static boolean str2Bool(final String str, final boolean def)
Specifies a set of OpenGL capabilities.
void setNumSamples(final int numSamples)
If sample buffers are enabled, indicates the number of buffers to be allocated.
void setSampleBuffers(final boolean enable)
Defaults to false.
Specifies the the OpenGL profile.
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
Window closing mode if triggered by toolkit close operation.
DO_NOTHING_ON_CLOSE
Do nothing on native window close operation.
DISPOSE_ON_CLOSE
Dispose resources on native window close operation.
A interface describing a graphics device in a toolkit-independent manner.
A interface describing a graphics screen in a toolkit-independent manner.
Extend the NativeSurface interface with windowing information such as window-handle,...
void destroy()
Destroys this window incl.
Immutable Point interface.
Specifying NEWT's Window functionality:
void setUpdateFPSFrames(int frames, PrintStream out)
static final int DEFAULT_FRAMES_PER_INTERVAL