JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
GLWindow.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
3 * Copyright (c) 2010 JogAmp Community. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * - Redistribution of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistribution in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * Neither the name of Sun Microsystems, Inc. or the names of
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * This software is provided "AS IS," without a warranty of any kind. ALL
21 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
22 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
23 * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
24 * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
25 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
26 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
27 * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
28 * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
29 * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
30 * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
31 * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 *
33 */
34
35package com.jogamp.newt.opengl;
36
37import java.security.PrivilegedAction;
38import java.util.List;
39
40import com.jogamp.nativewindow.AbstractGraphicsConfiguration;
41import com.jogamp.nativewindow.CapabilitiesChooser;
42import com.jogamp.nativewindow.CapabilitiesImmutable;
43import com.jogamp.nativewindow.NativeSurface;
44import com.jogamp.nativewindow.NativeWindow;
45import com.jogamp.nativewindow.NativeWindowException;
46import com.jogamp.nativewindow.SurfaceUpdatedListener;
47import com.jogamp.nativewindow.util.InsetsImmutable;
48import com.jogamp.nativewindow.util.Point;
49import com.jogamp.nativewindow.util.Rectangle;
50import com.jogamp.opengl.FPSCounter;
51import com.jogamp.opengl.GL;
52import com.jogamp.opengl.GL3;
53import com.jogamp.opengl.GL4ES3;
54import com.jogamp.opengl.GLAnimatorControl;
55import com.jogamp.opengl.GLAutoDrawable;
56import com.jogamp.opengl.GLCapabilities;
57import com.jogamp.opengl.GLCapabilitiesImmutable;
58import com.jogamp.opengl.GLContext;
59import com.jogamp.opengl.GLDrawable;
60import com.jogamp.opengl.GLDrawableFactory;
61import com.jogamp.opengl.GLES2;
62import com.jogamp.opengl.GLES3;
63import com.jogamp.opengl.GLEventListener;
64import com.jogamp.opengl.GLException;
65import com.jogamp.opengl.GLProfile;
66import com.jogamp.opengl.GLRunnable;
67import com.jogamp.opengl.GLSharedContextSetter;
68
69import jogamp.common.os.PlatformPropsImpl;
70import jogamp.newt.WindowImpl;
71import jogamp.opengl.GLAutoDrawableBase;
72import jogamp.opengl.GLContextImpl;
73import jogamp.opengl.GLDrawableImpl;
74
75import com.jogamp.common.GlueGenVersion;
76import com.jogamp.common.os.Clock;
77import com.jogamp.common.util.SecurityUtil;
78import com.jogamp.common.util.VersionUtil;
79import com.jogamp.common.util.locks.RecursiveLock;
80import com.jogamp.newt.MonitorDevice;
81import com.jogamp.newt.NewtFactory;
82import com.jogamp.newt.Screen;
83import com.jogamp.newt.Window;
84import com.jogamp.newt.Display.PointerIcon;
85import com.jogamp.newt.event.GestureHandler;
86import com.jogamp.newt.event.KeyListener;
87import com.jogamp.newt.event.MouseListener;
88import com.jogamp.newt.event.NEWTEvent;
89import com.jogamp.newt.event.NEWTEventConsumer;
90import com.jogamp.newt.event.NEWTEventListener;
91import com.jogamp.newt.event.WindowAdapter;
92import com.jogamp.newt.event.WindowEvent;
93import com.jogamp.newt.event.WindowListener;
94import com.jogamp.newt.event.WindowUpdateEvent;
95import com.jogamp.opengl.JoglVersion;
96import com.jogamp.opengl.GLStateKeeper;
97
98/**
99 * An implementation of {@link GLAutoDrawable} and {@link Window} interface,
100 * using a delegated {@link Window} instance, which may be an aggregation (lifecycle: created and destroyed).
101 * <P>
102 * This implementation supports {@link GLStateKeeper GL state preservation},
103 * hence {@link #isGLStatePreservationSupported()} returns <code>true</code>.
104 * </P>
105 * <P>
106 * This implementation does not make the OpenGL context current<br>
107 * before calling the various input EventListener callbacks, ie {@link MouseListener} etc.<br>
108 * This design decision is made in favor of a more performant and simplified
109 * implementation. Also the event dispatcher shall be implemented OpenGL agnostic.<br>
110 * To be able to use OpenGL commands from within such input {@link NEWTEventListener},<br>
111 * you can inject {@link GLRunnable} objects
112 * via {@link #invoke(boolean, GLRunnable)} to the OpenGL command stream.<br>
113 * </p>
114 * <p>
115 * <a name="contextSharing"><h5>OpenGL Context Sharing</h5></a>
116 * To share a {@link GLContext} see the following note in the documentation overview:
117 * <a href="../../../../overview-summary.html#SHARING">context sharing</a>
118 * as well as {@link GLSharedContextSetter}.
119 * </p>
120 */
121public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Window, NEWTEventConsumer, FPSCounter {
122 private final WindowImpl window;
123
124 /**
125 * Constructor. Do not call this directly -- use {@link #create()} instead.
126 */
127 protected GLWindow(final Window window) {
128 super(null, null, false /* always handle device lifecycle ourselves */);
129 this.window = (WindowImpl) window;
130 this.window.setWindowDestroyNotifyAction( new Runnable() {
131 @Override
132 public void run() {
133 defaultWindowDestroyNotifyOp();
134 } } );
135 window.addWindowListener(new WindowAdapter() {
136 @Override
137 public void windowRepaint(final WindowUpdateEvent e) {
138 defaultWindowRepaintOp();
139 }
140
141 @Override
142 public void windowResized(final WindowEvent e) {
143 defaultWindowResizedOp(getSurfaceWidth(), getSurfaceHeight());
144 }
145
146 });
147 this.window.setLifecycleHook(new GLLifecycleHook());
148 }
149
150 @Override
151 public final Object getUpstreamWidget() {
152 return window;
153 }
154
155 @Override
156 public final RecursiveLock getUpstreamLock() {
157 return window.getLock();
158 }
159
160 /**
161 * Creates a new GLWindow attaching a new Window referencing a
162 * new default Screen and default Display with the given GLCapabilities.
163 * <p>
164 * The lifecycle of this Window's Screen and Display is handled via {@link Screen#addReference()}
165 * and {@link Screen#removeReference()}.
166 * </p>
167 * The default Display will be reused if already instantiated.
168 */
169 public static GLWindow create(final GLCapabilitiesImmutable caps) {
170 return new GLWindow(NewtFactory.createWindow(caps));
171 }
172
173 /**
174 * Creates a new GLWindow attaching a new Window referencing the given Screen
175 * with the given GLCapabilities.
176 * <p>
177 * The lifecycle of this Window's Screen and Display is handled via {@link Screen#addReference()}
178 * and {@link Screen#removeReference()}.
179 * </p>
180 */
181 public static GLWindow create(final Screen screen, final GLCapabilitiesImmutable caps) {
182 return new GLWindow(NewtFactory.createWindow(screen, caps));
183 }
184
185 /**
186 * Creates a new GLWindow attaching the given window.
187 * <p>
188 * The lifecycle of this Window's Screen and Display is handled via {@link Screen#addReference()}
189 * and {@link Screen#removeReference()}.
190 * </p>
191 */
192 public static GLWindow create(final Window window) {
193 return new GLWindow(window);
194 }
195
196 /**
197 * Creates a new GLWindow attaching a new child Window
198 * of the given <code>parentNativeWindow</code> with the given GLCapabilities.
199 * <p>
200 * The Display/Screen will be compatible with the <code>parentNativeWindow</code>,
201 * or even identical in case it's a Newt Window.
202 * An already instantiated compatible Display will be reused.
203 * </p>
204 * <p>
205 * The lifecycle of this Window's Screen and Display is handled via {@link Screen#addReference()}
206 * and {@link Screen#removeReference()}.
207 * </p>
208 */
209 public static GLWindow create(final NativeWindow parentNativeWindow, final GLCapabilitiesImmutable caps) {
210 return new GLWindow(NewtFactory.createWindow(parentNativeWindow, caps));
211 }
212
213 //----------------------------------------------------------------------
214 // WindowClosingProtocol implementation
215 //
216 @Override
218 return window.getDefaultCloseOperation();
219 }
220
221 @Override
223 return window.setDefaultCloseOperation(op);
224 }
225
226 //----------------------------------------------------------------------
227 // Window Access
228 //
229
230 @Override
231 public final int getStatePublicBitCount() {
232 return window.getStatePublicBitCount();
233 }
234
235 @Override
236 public final int getStatePublicBitmask() {
237 return window.getStatePublicBitmask();
238 }
239
240 @Override
241 public final int getStateMask() {
242 return window.getStateMask();
243 }
244
245 @Override
246 public final String getStateMaskString() {
247 return window.getStateMaskString();
248 }
249
250 @Override
251 public final int getSupportedStateMask() {
252 return window.getSupportedStateMask();
253 }
254
255 @Override
256 public final String getSupportedStateMaskString() {
257 return window.getSupportedStateMaskString();
258 }
259
260 @Override
262 return window.setCapabilitiesChooser(chooser);
263 }
264
265 @Override
267 final GLDrawable _drawable = drawable;
268 return null != _drawable ? _drawable.getChosenGLCapabilities() : window.getChosenCapabilities();
269 }
270
271 @Override
273 return window.getRequestedCapabilities();
274 }
275
276 @Override
277 public final Window getDelegatedWindow() {
278 return window.getDelegatedWindow();
279 }
280
281 @Override
282 public final NativeWindow getParent() {
283 return window.getParent();
284 }
285
286 @Override
287 public final Screen getScreen() {
288 return window.getScreen();
289 }
290
291 @Override
293 return window.getMainMonitor();
294 }
295
296 @Override
297 public final void setTitle(final String title) {
298 window.setTitle(title);
299 }
300
301 @Override
302 public final String getTitle() {
303 return window.getTitle();
304 }
305
306 @Override
307 public final boolean isPointerVisible() {
308 return window.isPointerVisible();
309 }
310
311 @Override
312 public final void setPointerVisible(final boolean mouseVisible) {
313 window.setPointerVisible(mouseVisible);
314 }
315
316 @Override
318 return window.getPointerIcon();
319 }
320
321 @Override
322 public final void setPointerIcon(final PointerIcon pi) {
323 window.setPointerIcon(pi);
324 }
325
326 @Override
327 public final boolean isPointerConfined() {
328 return window.isPointerConfined();
329 }
330
331 @Override
332 public final void confinePointer(final boolean grab) {
333 window.confinePointer(grab);
334 }
335
336 @Override
337 public final void setUndecorated(final boolean value) {
338 window.setUndecorated(value);
339 }
340
341 @Override
342 public final void warpPointer(final int x, final int y) {
343 window.warpPointer(x, y);
344 }
345 @Override
346 public final boolean isUndecorated() {
347 return window.isUndecorated();
348 }
349
350 @Override
351 public final void setAlwaysOnTop(final boolean value) {
352 window.setAlwaysOnTop(value);
353 }
354
355 @Override
356 public final boolean isAlwaysOnTop() {
357 return window.isAlwaysOnTop();
358 }
359
360 @Override
361 public final void setAlwaysOnBottom(final boolean value) {
362 window.setAlwaysOnBottom(value);
363 }
364
365 @Override
366 public final boolean isAlwaysOnBottom() {
367 return window.isAlwaysOnBottom();
368 }
369
370 @Override
371 public final void setResizable(final boolean value) {
372 window.setResizable(value);
373 }
374
375 @Override
376 public final boolean isResizable() {
377 return window.isResizable();
378 }
379
380 @Override
381 public final void setSticky(final boolean value) {
382 window.setSticky(value);
383 }
384
385 @Override
386 public final boolean isSticky() {
387 return window.isSticky();
388 }
389
390 @Override
391 public final void setMaximized(final boolean horz, final boolean vert) {
392 window.setMaximized(horz, vert);
393 }
394
395 @Override
396 public final boolean isMaximizedVert() {
397 return window.isMaximizedVert();
398 }
399
400 @Override
401 public final boolean isMaximizedHorz() {
402 return window.isMaximizedHorz();
403 }
404
405 @Override
406 public final void setFocusAction(final FocusRunnable focusAction) {
407 window.setFocusAction(focusAction);
408 }
409
410 @Override
412 window.setKeyboardFocusHandler(l);
413 }
414
415 @Override
416 public final void requestFocus() {
417 window.requestFocus();
418 }
419
420 @Override
421 public final void requestFocus(final boolean wait) {
422 window.requestFocus(wait);
423 }
424
425 @Override
426 public boolean hasFocus() {
427 return window.hasFocus();
428 }
429
430 @Override
431 public final InsetsImmutable getInsets() {
432 return window.getInsets();
433 }
434
435 @Override
436 public final int getX() {
437 return window.getX();
438 }
439
440 @Override
441 public final int getY() {
442 return window.getY();
443 }
444
445 @Override
446 public final int getWidth() {
447 return window.getWidth();
448 }
449
450 @Override
451 public final int getHeight() {
452 return window.getHeight();
453 }
454
455 @Override
456 public final Rectangle getBounds() {
457 return window.getBounds();
458 }
459
460 @Override
461 public final int getSurfaceWidth() {
462 return window.getSurfaceWidth();
463 }
464
465 @Override
466 public final int getSurfaceHeight() {
467 return window.getSurfaceHeight();
468 }
469
470 @Override
472 return window.getSurfaceBounds();
473 }
474
475 @Override
476 public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) {
477 return window.convertToWindowUnits(pixelUnitsAndResult);
478 }
479
480 @Override
481 public final int[] convertToPixelUnits(final int[] windowUnitsAndResult) {
482 return window.convertToPixelUnits(windowUnitsAndResult);
483 }
484
485 /**
486 * {@inheritDoc}
487 * <p>
488 * This implementation returns true, i.e. supporting manual change of pixel-scale.
489 * </p>
490 */
491 @Override
492 public final boolean canSetSurfaceScale() { return true; }
493
494 @Override
495 public final boolean setSurfaceScale(final float[] pixelScale) {
496 return window.setSurfaceScale(pixelScale);
497 }
498
499 @Override
500 public final float[] getRequestedSurfaceScale(final float[] result) {
501 return window.getRequestedSurfaceScale(result);
502 }
503
504 @Override
505 public final float[] getCurrentSurfaceScale(final float[] result) {
506 return window.getCurrentSurfaceScale(result);
507 }
508
509 @Override
510 public final float[] getMinimumSurfaceScale(final float[] result) {
511 return window.getMinimumSurfaceScale(result);
512 }
513
514 @Override
515 public final float[] getMaximumSurfaceScale(final float[] result) {
516 return window.getMaximumSurfaceScale(result);
517 }
518
519 @Override
520 public final float[] getPixelsPerMM(final float[] ppmmStore) {
521 return window.getPixelsPerMM(ppmmStore);
522 }
523
524 @Override
525 public final void setPosition(final int x, final int y) {
526 window.setPosition(x, y);
527 }
528 @Override
529 public void setTopLevelPosition(final int x, final int y) {
530 window.setTopLevelPosition(x, y);
531 }
532
533 @Override
534 public final boolean setFullscreen(final boolean fullscreen) {
535 return window.setFullscreen(fullscreen);
536 }
537
538 @Override
539 public boolean setFullscreen(final List<MonitorDevice> monitors) {
540 return window.setFullscreen(monitors);
541 }
542
543 @Override
544 public final boolean isFullscreen() {
545 return window.isFullscreen();
546 }
547
548 @Override
549 public final boolean isVisible() {
550 return window.isVisible();
551 }
552
553 @Override
554 public final StringBuilder toSimpleString(final StringBuilder sb) {
555 sb.append("GLWindow[");
556 window.toSimpleString(sb).append("]");
557 return sb;
558 }
559 @Override
560 public final String toSimpleString() {
561 return toSimpleString(new StringBuilder()).toString();
562 }
563 @Override
564 public final StringBuilder toString(final StringBuilder sb) {
565 sb.append("GLWindow").append("[")
566 .append(PlatformPropsImpl.NEWLINE).append("\t").append("Helper: ").append(helper)
567 .append(", ").append(PlatformPropsImpl.NEWLINE).append("\t").append("Drawable: ").append(drawable)
568 .append(", ").append(PlatformPropsImpl.NEWLINE).append("\t").append("Context: ").append(context)
569 .append(", ").append(PlatformPropsImpl.NEWLINE).append("\t").append("Window: ");
570 window.toString(sb)
571 // .append(", ").append(Platform.NEWLINE).append("\t").append("Factory: ").append(factory)
572 .append("]");
573 return sb;
574 }
575
576 @Override
577 public final String toString() {
578 return toString(new StringBuilder()).toString();
579 }
580
581 @Override
582 public final ReparentOperation reparentWindow(final NativeWindow newParent, final int x, final int y, final int hints) {
583 return window.reparentWindow(newParent, x, y, hints);
584 }
585 @Override
586 public final boolean isChildWindow() {
587 return window.isChildWindow();
588 }
589
590 @Override
591 public final boolean removeChild(final NativeWindow win) {
592 return window.removeChild(win);
593 }
594
595 @Override
596 public final boolean addChild(final NativeWindow win) {
597 return window.addChild(win);
598 }
599
600 //----------------------------------------------------------------------
601 // Window.LifecycleHook Implementation
602 //
603
604 @Override
605 public final void destroy() {
606 window.destroy();
607 }
608
609 @Override
610 public void setWindowDestroyNotifyAction(final Runnable r) {
611 window.setWindowDestroyNotifyAction(r);
612 }
613
614 @Override
615 public final void setVisible(final boolean visible) {
616 window.setVisible(visible);
617 }
618
619 @Override
620 public void setVisible(final boolean wait, final boolean visible) {
621 window.setVisible(wait, visible);
622 }
623
624 @Override
625 public final void setSize(final int width, final int height) {
626 window.setSize(width, height);
627 }
628 @Override
629 public final void setSurfaceSize(final int pixelWidth, final int pixelHeight) {
630 window.setSurfaceSize(pixelWidth, pixelHeight);
631 }
632 @Override
633 public void setTopLevelSize(final int width, final int height) {
634 window.setTopLevelSize(width, height);
635 }
636
637 @Override
638 public final boolean isNativeValid() {
639 return window.isNativeValid();
640 }
641
642 @Override
643 public Point getLocationOnScreen(final Point storage) {
644 return window.getLocationOnScreen(storage);
645 }
646
647 // Hide methods here ..
648 protected class GLLifecycleHook implements WindowImpl.LifecycleHook {
649
650 @Override
651 public void preserveGLStateAtDestroy(final boolean value) {
652 GLWindow.this.preserveGLStateAtDestroy(value);
653 }
654
655 @Override
656 public synchronized void destroyActionPreLock() {
657 // nop
658 }
659
660 @Override
661 public synchronized void destroyActionInLock() {
663 final String msg = "GLWindow.destroy() "+WindowImpl.getThreadName()+", start";
664 System.err.println(msg);
665 //Exception e1 = new Exception(msg);
666 //e1.printStackTrace();
667 }
668
669 destroyImplInLock();
670
672 System.err.println("GLWindow.destroy() "+WindowImpl.getThreadName()+", fin");
673 }
674 }
675
676 @Override
677 public synchronized void resetCounter() {
679 System.err.println("GLWindow.resetCounter() "+WindowImpl.getThreadName());
680 }
682 final GLAnimatorControl animator = GLWindow.this.getAnimator();
683 if( null != animator ) {
684 animator.resetFPSCounter();
685 }
686 }
687
688 @Override
689 public synchronized void setVisibleActionPost(final boolean visible, final boolean nativeWindowCreated) {
690 long t0;
692 t0 = Clock.currentNanos();
693 System.err.println("GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+WindowImpl.getThreadName()+", start");
694 } else {
695 t0 = 0;
696 }
697
698 if (null == drawable && visible && 0 != window.getWindowHandle() && 0<getSurfaceWidth()*getSurfaceHeight()) {
699 if( ( null != context ) ) {
700 throw new InternalError("GLWindow.LifecycleHook.setVisiblePost: "+WindowImpl.getThreadName()+" - Null drawable, but valid context - "+GLWindow.this);
701 }
702 final GLContext[] shareWith = { null };
703 if( !helper.isSharedGLContextPending(shareWith) ) {
704 final NativeSurface ns;
705 {
706 final NativeSurface wrapped_ns = window.getWrappedSurface();
707 ns = null != wrapped_ns ? wrapped_ns : window;
708 }
710 if(null==factory) {
711 factory = GLDrawableFactory.getFactory(glCaps.getGLProfile());
712 }
713 drawable = (GLDrawableImpl) factory.createGLDrawable(ns);
714 drawable.setRealized(true);
715
716 if( !GLWindow.this.restoreGLEventListenerState() ) {
717 context = (GLContextImpl) drawable.createContext(shareWith[0]);
718 context.setContextCreationFlags(additionalCtxCreationFlags);
719 }
720 }
721 }
723 System.err.println("GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+WindowImpl.getThreadName()+", fin: dt "+ (Clock.currentNanos()-t0)/1e6 +"ms");
724 }
725 }
726
727 private GLAnimatorControl savedAnimator = null;
728
729 @Override
730 public synchronized boolean pauseRenderingAction() {
731 final boolean animatorPaused;
732 savedAnimator = GLWindow.this.getAnimator();
733 if ( null != savedAnimator ) {
734 animatorPaused = savedAnimator.pause();
735 } else {
736 animatorPaused = false;
737 }
738 return animatorPaused;
739 }
740
741 @Override
742 public synchronized void resumeRenderingAction() {
743 if ( null != savedAnimator && savedAnimator.isPaused() ) {
744 savedAnimator.resume();
745 }
746 }
747
748 @SuppressWarnings("deprecation")
749 @Override
751 final GLAnimatorControl anim = GLWindow.this.getAnimator();
752 if ( null != anim && anim.isAnimating() ) {
753 final Thread animThread = anim.getThread();
754 if( animThread == Thread.currentThread() ) {
755 anim.stop(); // on anim thread, non-blocking
756 } else {
757 SecurityUtil.doPrivileged(new PrivilegedAction<Object>() {
758 @Override
759 public Object run() {
760 if( anim.isAnimating() && null != animThread ) {
761 try {
762 animThread.stop();
763 } catch(final Throwable t) {
764 if( DEBUG ) {
765 System.err.println("Caught "+t.getClass().getName()+": "+t.getMessage());
766 t.printStackTrace();
767 }
768 }
769 }
770 return null;
771 } } );
772 }
773 }
774 }
775 }
776
777 //----------------------------------------------------------------------
778 // OpenGL-related methods and state
779 //
780
781 @Override
782 public void display() {
783 if( !isNativeValid() || !isVisible() ) { return; }
784
785 if(sendDestroy || ( window.hasDeviceChanged() && GLAutoDrawable.SCREEN_CHANGE_ACTION_ENABLED ) ) {
786 sendDestroy=false;
787 destroy();
788 return;
789 }
790
791 final boolean done;
792 final RecursiveLock lock = window.getLock();
793 lock.lock(); // sync: context/drawable could have been recreated/destroyed while animating
794 try {
795 if( null != context ) {
796 // surface is locked/unlocked implicit by context's makeCurrent/release
797 helper.invokeGL(drawable, context, defaultDisplayAction, defaultInitAction);
798 done = true;
799 } else {
800 done = false;
801 }
802 } finally {
803 lock.unlock();
804 }
805 if( !done && ( 0 < getSurfaceWidth() && 0 < getSurfaceHeight() ) ) {
806 // retry drawable and context creation, will itself issue resize -> display
807 setVisible(true);
808 }
809 }
810
811 /**
812 * {@inheritDoc}
813 * <p>
814 * GLWindow supports GL state preservation, hence returns <code>true</code>.
815 * </p>
816 */
817 @Override
818 public final boolean isGLStatePreservationSupported() { return true; }
819
820 //----------------------------------------------------------------------
821 // GLDrawable methods
822 //
823 private GLDrawableFactory factory;
824
825 @Override
827 return factory;
828 }
829
830 @Override
831 public final void swapBuffers() throws GLException {
832 defaultSwapBuffers();
833 }
834
835 //----------------------------------------------------------------------
836 // NEWTEventConsumer
837 //
838 @Override
839 public boolean consumeEvent(final NEWTEvent event) {
840 return window.consumeEvent(event);
841 }
842
843 //----------------------------------------------------------------------
844 // Window completion
845 //
846 @Override
847 public final boolean windowRepaint(final int x, final int y, final int width, final int height) {
848 return window.windowRepaint(x, y, width, height);
849 }
850
851 @Override
852 public final void enqueueEvent(final boolean wait, final com.jogamp.newt.event.NEWTEvent event) {
853 window.enqueueEvent(wait, event);
854 }
855
856 @Override
857 public final void runOnEDTIfAvail(final boolean wait, final Runnable task) {
858 window.runOnEDTIfAvail(wait, task);
859 }
860
861 @Override
862 public void sendWindowEvent(final int eventType) {
863 window.sendWindowEvent(eventType);
864 }
865
866 @Override
867 public final WindowListener getWindowListener(final int index) {
868 return window.getWindowListener(index);
869 }
870
871 @Override
873 return window.getWindowListeners();
874 }
875
876 @Override
877 public final void removeWindowListener(final WindowListener l) {
878 window.removeWindowListener(l);
879 }
880
881 @Override
882 public final void addWindowListener(final WindowListener l) {
883 window.addWindowListener(l);
884 }
885
886 @Override
887 public final void addWindowListener(final int index, final WindowListener l) throws IndexOutOfBoundsException {
888 window.addWindowListener(index, l);
889 }
890
891 @Override
892 public final void setKeyboardVisible(final boolean visible) {
893 window.setKeyboardVisible(visible);
894 }
895
896 @Override
897 public final boolean isKeyboardVisible() {
898 return window.isKeyboardVisible();
899 }
900
901 @Override
902 public final void addKeyListener(final KeyListener l) {
903 window.addKeyListener(l);
904 }
905
906 @Override
907 public final void addKeyListener(final int index, final KeyListener l) {
908 window.addKeyListener(index, l);
909 }
910
911 @Override
912 public final void removeKeyListener(final KeyListener l) {
913 window.removeKeyListener(l);
914 }
915
916 @Override
917 public final KeyListener getKeyListener(final int index) {
918 return window.getKeyListener(index);
919 }
920
921 @Override
922 public final KeyListener[] getKeyListeners() {
923 return window.getKeyListeners();
924 }
925
926 @Override
927 public final void addMouseListener(final MouseListener l) {
928 window.addMouseListener(l);
929 }
930
931 @Override
932 public final void addMouseListener(final int index, final MouseListener l) {
933 window.addMouseListener(index, l);
934 }
935
936 @Override
937 public final void removeMouseListener(final MouseListener l) {
938 window.removeMouseListener(l);
939 }
940
941 @Override
942 public final MouseListener getMouseListener(final int index) {
943 return window.getMouseListener(index);
944 }
945
946 @Override
948 return window.getMouseListeners();
949 }
950
951 @Override
952 public void setDefaultGesturesEnabled(final boolean enable) {
953 window.setDefaultGesturesEnabled(enable);
954 }
955 @Override
956 public boolean areDefaultGesturesEnabled() {
957 return window.areDefaultGesturesEnabled();
958 }
959 @Override
960 public final void addGestureHandler(final GestureHandler gh) {
961 window.addGestureHandler(gh);
962 }
963 @Override
964 public final void addGestureHandler(final int index, final GestureHandler gh) {
965 window.addGestureHandler(index, gh);
966 }
967 @Override
968 public final void removeGestureHandler(final GestureHandler gh) {
969 window.removeGestureHandler(gh);
970 }
971 @Override
973 window.addGestureListener(-1, gl);
974 }
975 @Override
976 public final void addGestureListener(final int index, final GestureHandler.GestureListener gl) {
977 window.addGestureListener(index, gl);
978 }
979 @Override
981 window.removeGestureListener(gl);
982 }
983
984 //----------------------------------------------------------------------
985 // NativeWindow completion
986 //
987
988 @Override
989 public RecursiveLock getLock() {
990 return window.getLock();
991 }
992
993 @Override
994 public final int lockSurface() throws NativeWindowException, RuntimeException {
995 return window.lockSurface();
996 }
997
998 @Override
999 public final void unlockSurface() {
1000 window.unlockSurface();
1001 }
1002
1003 @Override
1004 public final boolean isSurfaceLockedByOtherThread() {
1005 return window.isSurfaceLockedByOtherThread();
1006 }
1007
1008 @Override
1009 public final Thread getSurfaceLockOwner() {
1010 return window.getSurfaceLockOwner();
1011
1012 }
1013
1014 @Override
1015 public final boolean surfaceSwap() {
1016 return window.surfaceSwap();
1017 }
1018
1019 @Override
1021 window.removeSurfaceUpdatedListener(l);
1022 }
1023
1024 @Override
1026 window.addSurfaceUpdatedListener(l);
1027 }
1028
1029 @Override
1030 public final void addSurfaceUpdatedListener(final int index, final SurfaceUpdatedListener l) throws IndexOutOfBoundsException {
1031 window.addSurfaceUpdatedListener(index, l);
1032 }
1033
1034 @Override
1035 public final void surfaceUpdated(final Object updater, final NativeSurface ns, final long when) {
1036 window.surfaceUpdated(updater, ns, when);
1037 }
1038
1039 @Override
1040 public final long getWindowHandle() {
1041 return window.getWindowHandle();
1042
1043 }
1044
1045 @Override
1046 public final long getSurfaceHandle() {
1047 return window.getSurfaceHandle();
1048
1049 }
1050
1051 @Override
1053 return window.getGraphicsConfiguration();
1054 }
1055
1056 @Override
1057 public final long getDisplayHandle() {
1058 return window.getDisplayHandle();
1059 }
1060
1061 @Override
1062 public final int getScreenIndex() {
1063 return window.getScreenIndex();
1064 }
1065
1066 /**
1067 * A most simple JOGL AWT test entry
1068 */
1069 public static void main(final String args[]) {
1070 final boolean forceES2;
1071 final boolean forceES3;
1072 final boolean forceGL3;
1073 final boolean forceGL4ES3;
1074 {
1075 boolean _forceES2 = false;
1076 boolean _forceES3 = false;
1077 boolean _forceGL3 = false;
1078 boolean _forceGL4ES3 = false;
1079 if( null != args ) {
1080 for(int i=0; i<args.length; i++) {
1081 if(args[i].equals("-es2")) {
1082 _forceES2 = true;
1083 } else if(args[i].equals("-es3")) {
1084 _forceES3 = true;
1085 } else if(args[i].equals("-gl3")) {
1086 _forceGL3 = true;
1087 } else if(args[i].equals("-gl4es3")) {
1088 _forceGL4ES3 = true;
1089 }
1090 }
1091 }
1092 forceES2 = _forceES2;
1093 forceES3 = _forceES3;
1094 forceGL3 = _forceGL3;
1095 forceGL4ES3 = _forceGL4ES3;
1096 }
1097 System.err.println("forceES2 "+forceES2);
1098 System.err.println("forceES3 "+forceES3);
1099 System.err.println("forceGL3 "+forceGL3);
1100 System.err.println("forceGL4ES3 "+forceGL4ES3);
1101
1102 System.err.println(VersionUtil.getPlatformInfo());
1103 System.err.println(GlueGenVersion.getInstance());
1104 System.err.println(JoglVersion.getInstance());
1105
1106 System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, true).toString());
1107
1108 final GLProfile glp;
1109 if(forceGL4ES3) {
1111 } else if(forceGL3) {
1112 glp = GLProfile.get(GLProfile.GL3);
1113 } else if(forceES3) {
1115 } else if(forceES2) {
1117 } else {
1118 glp = GLProfile.getDefault();
1119 }
1120 final GLCapabilitiesImmutable caps = new GLCapabilities( glp );
1121 System.err.println("Requesting: "+caps);
1122
1123 final GLWindow glWindow = GLWindow.create(caps);
1124 glWindow.setSize(128, 128);
1125
1126 glWindow.addGLEventListener(new GLEventListener() {
1127 @Override
1128 public void init(final GLAutoDrawable drawable) {
1129 final MonitorDevice monitor = glWindow.getMainMonitor();
1130 System.err.println("Main Monitor: "+monitor);
1131 final float[] pixelPerMM = monitor.getPixelsPerMM(new float[2]);
1132 System.err.println(" pixel/mm ["+pixelPerMM[0]+", "+pixelPerMM[1]+"]");
1133 System.err.println(" pixel/in ["+pixelPerMM[0]*25.4f+", "+pixelPerMM[1]*25.4f+"]");
1134 final GL gl = drawable.getGL();
1135 System.err.println(JoglVersion.getGLInfo(gl, null));
1136 System.err.println("Requested: "+drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities());
1137 System.err.println("Chosen : "+drawable.getChosenGLCapabilities());
1138 System.err.println("GL impl. class "+gl.getClass().getName());
1139 if( gl.isGL4ES3() ) {
1140 final GL4ES3 _gl = gl.getGL4ES3();
1141 System.err.println("GL4ES3 retrieved, impl. class "+_gl.getClass().getName());
1142 }
1143 if( gl.isGL3() ) {
1144 final GL3 _gl = gl.getGL3();
1145 System.err.println("GL3 retrieved, impl. class "+_gl.getClass().getName());
1146 }
1147 if( gl.isGLES3() ) {
1148 final GLES3 _gl = gl.getGLES3();
1149 System.err.println("GLES3 retrieved, impl. class "+_gl.getClass().getName());
1150 }
1151 if( gl.isGLES2() ) {
1152 final GLES2 _gl = gl.getGLES2();
1153 System.err.println("GLES2 retrieved, impl. class "+_gl.getClass().getName());
1154 }
1155 }
1156
1157 @Override
1158 public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
1159 }
1160
1161 @Override
1162 public void display(final GLAutoDrawable drawable) {
1163 }
1164
1165 @Override
1166 public void dispose(final GLAutoDrawable drawable) {
1167 }
1168 });
1169
1170 glWindow.setVisible(true);
1171 glWindow.destroy();
1172 }
1173}
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
Visual output device, i.e.
final float[] getPixelsPerMM(final float[] ppmmStore)
Returns the pixels per millimeter value according to the current mode's surface resolution.
static Window createWindow(final CapabilitiesImmutable caps)
Create a top level Window entity on the default Display and default Screen.
A screen may span multiple MonitorDevices representing their combined virtual size.
Definition: Screen.java:58
NEWT events are provided for notification purposes ONLY; The NEWT will automatically handle the even...
Definition: NEWTEvent.java:52
NEWT Window events are provided for notification purposes ONLY.
synchronized void setVisibleActionPost(final boolean visible, final boolean nativeWindowCreated)
Definition: GLWindow.java:689
void preserveGLStateAtDestroy(final boolean value)
Definition: GLWindow.java:651
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
Definition: GLWindow.java:121
final void addKeyListener(final int index, final KeyListener l)
Inserts the given com.jogamp.newt.event.KeyListener at the specified position in the list.
Definition: GLWindow.java:907
final float[] getMaximumSurfaceScale(final float[] result)
Returns the maximum pixel scale of the associated NativeSurface.
Definition: GLWindow.java:515
final int getStateMask()
Returns the current status mask of this instance.
Definition: GLWindow.java:241
final void warpPointer(final int x, final int y)
Moves the pointer to x/y relative to this window's origin in pixel units.
Definition: GLWindow.java:342
void setTopLevelSize(final int width, final int height)
Sets the size of the top-level window including insets (window decorations) in window units.
Definition: GLWindow.java:633
final String toString()
Returns a full string multi-line representation of this instance using toString(StringBuilder).
Definition: GLWindow.java:577
final long getSurfaceHandle()
Returns the handle to the surface for this NativeSurface.
Definition: GLWindow.java:1046
final void setPointerIcon(final PointerIcon pi)
Definition: GLWindow.java:322
final boolean isSurfaceLockedByOtherThread()
Query if surface is locked by another thread, i.e.
Definition: GLWindow.java:1004
void setVisible(final boolean wait, final boolean visible)
setVisible(..) makes the window and children visible if visible is true, otherwise the window and chi...
Definition: GLWindow.java:620
final String getStateMaskString()
Returns a string representation of the current state mask.
Definition: GLWindow.java:246
Point getLocationOnScreen(final Point storage)
Returns the window's top-left client-area position in the screen.
Definition: GLWindow.java:643
final void enqueueEvent(final boolean wait, final com.jogamp.newt.event.NEWTEvent event)
Definition: GLWindow.java:852
final void requestFocus(final boolean wait)
Request focus for this native window.
Definition: GLWindow.java:421
void setKeyboardFocusHandler(final KeyListener l)
Sets a KeyListener allowing focus traversal with a covered window toolkit like AWT.
Definition: GLWindow.java:411
final boolean canSetSurfaceScale()
Returns true if setSurfaceScale(float[]) is supported, otherwise false.For pure downstream scalable s...
Definition: GLWindow.java:492
final RecursiveLock getUpstreamLock()
Returns the recursive lock object of the upstream widget to synchronize multithreaded access on top o...
Definition: GLWindow.java:156
final CapabilitiesImmutable getRequestedCapabilities()
Gets an immutable set of requested capabilities.
Definition: GLWindow.java:272
void setWindowDestroyNotifyAction(final Runnable r)
Set a custom action handling destruction issued by a toolkit triggered window destroy replacing the d...
Definition: GLWindow.java:610
final int lockSurface()
Lock the surface of this native window.
Definition: GLWindow.java:994
final NativeWindow getParent()
Definition: GLWindow.java:282
WindowClosingMode setDefaultCloseOperation(final WindowClosingMode op)
Definition: GLWindow.java:222
final void addGestureHandler(final int index, final GestureHandler gh)
Inserts the given GestureHandler at the specified position in the list.
Definition: GLWindow.java:964
final void swapBuffers()
Swaps the front and back buffers of this drawable.
Definition: GLWindow.java:831
final void removeGestureListener(final GestureHandler.GestureListener gl)
Removes the given GestureHandler.GestureListener from the list.
Definition: GLWindow.java:980
final int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
Definition: GLWindow.java:466
final void addGestureHandler(final GestureHandler gh)
Appends the given GestureHandler to the end of the list.
Definition: GLWindow.java:960
final void setPointerVisible(final boolean mouseVisible)
Makes the pointer visible or invisible.
Definition: GLWindow.java:312
final WindowListener[] getWindowListeners()
Definition: GLWindow.java:872
final void addMouseListener(final MouseListener l)
Appends the given MouseListener to the end of the list.
Definition: GLWindow.java:927
static void main(final String args[])
A most simple JOGL AWT test entry.
Definition: GLWindow.java:1069
final long getDisplayHandle()
Convenience: Get display handle from AbstractGraphicsConfiguration .
Definition: GLWindow.java:1057
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 ReparentOperation reparentWindow(final NativeWindow newParent, final int x, final int y, final int hints)
Change this window's parent window.
Definition: GLWindow.java:582
final boolean addChild(final NativeWindow win)
Definition: GLWindow.java:596
boolean setFullscreen(final List< MonitorDevice > monitors)
Enable fullscreen mode for this window spanning across the given MonitorDevices or across all Monitor...
Definition: GLWindow.java:539
final void setTitle(final String title)
Definition: GLWindow.java:297
final StringBuilder toSimpleString(final StringBuilder sb)
Appends this class simple string one-line representation to the given StringBuilder instance.
Definition: GLWindow.java:554
final void addGestureListener(final GestureHandler.GestureListener gl)
Appends the given GestureHandler.GestureListener to the end of the list.
Definition: GLWindow.java:972
final boolean isAlwaysOnBottom()
Definition: GLWindow.java:366
final Object getUpstreamWidget()
Method may return the upstream UI toolkit object holding this GLAutoDrawable instance,...
Definition: GLWindow.java:151
final float[] getPixelsPerMM(final float[] ppmmStore)
Returns the pixels per millimeter of this window's NativeSurface according to the main monitor's curr...
Definition: GLWindow.java:520
static GLWindow create(final Screen screen, final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing the given Screen with the given GLCapabilit...
Definition: GLWindow.java:181
final boolean isChildWindow()
Returns true if this window is a child window, i.e.
Definition: GLWindow.java:586
final void setAlwaysOnTop(final boolean value)
Definition: GLWindow.java:351
final float[] getRequestedSurfaceScale(final float[] result)
Returns the requested pixel scale of the associated NativeSurface.
Definition: GLWindow.java:500
final boolean surfaceSwap()
Provide a mechanism to utilize custom (pre-) swap surface code.
Definition: GLWindow.java:1015
final StringBuilder toString(final StringBuilder sb)
Appends this class full string multi-line representation to the given StringBuilder instance.
Definition: GLWindow.java:564
static GLWindow create(final Window window)
Creates a new GLWindow attaching the given window.
Definition: GLWindow.java:192
final void setMaximized(final boolean horz, final boolean vert)
Definition: GLWindow.java:391
final int getX()
Returns the current x position of this window, relative to it's parent.
Definition: GLWindow.java:436
final void removeSurfaceUpdatedListener(final SurfaceUpdatedListener l)
Remove the specified SurfaceUpdatedListener from the list.
Definition: GLWindow.java:1020
final int getScreenIndex()
Convenience: Get display handle from AbstractGraphicsConfiguration .
Definition: GLWindow.java:1062
final void setKeyboardVisible(final boolean visible)
In case the platform supports or even requires a virtual on-screen keyboard, this method shows or hid...
Definition: GLWindow.java:892
final void addKeyListener(final KeyListener l)
Appends the given com.jogamp.newt.event.KeyListener to the end of the list.
Definition: GLWindow.java:902
final KeyListener getKeyListener(final int index)
Definition: GLWindow.java:917
final boolean removeChild(final NativeWindow win)
Definition: GLWindow.java:591
final AbstractGraphicsConfiguration getGraphicsConfiguration()
Returns the graphics configuration corresponding to this window.
Definition: GLWindow.java:1052
final GLDrawableFactory getFactory()
Return the GLDrawableFactory being used to create this instance.
Definition: GLWindow.java:826
final void removeWindowListener(final WindowListener l)
Definition: GLWindow.java:877
final int getY()
Returns the current y position of the top-left corner of the client area relative to it's parent in w...
Definition: GLWindow.java:441
final float[] getCurrentSurfaceScale(final float[] result)
Returns the current pixel scale of the associated NativeSurface.
Definition: GLWindow.java:505
final int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
Definition: GLWindow.java:461
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 String getSupportedStateMaskString()
Returns a string representation of the supported state mask.
Definition: GLWindow.java:256
final void addGestureListener(final int index, final GestureHandler.GestureListener gl)
Inserts the given GestureHandler.GestureListener at the specified position in the list.
Definition: GLWindow.java:976
final int[] convertToWindowUnits(final int[] pixelUnitsAndResult)
Converts the given pixel units into window units in place.
Definition: GLWindow.java:476
final Rectangle getSurfaceBounds()
Returns a newly created Rectangle containing window's surface origin and size in pixel units.
Definition: GLWindow.java:471
final MonitorDevice getMainMonitor()
Returns the MonitorDevice with the highest viewport coverage of this window.
Definition: GLWindow.java:292
final boolean windowRepaint(final int x, final int y, final int width, final int height)
Trigger window repaint while passing the dirty region in pixel units.
Definition: GLWindow.java:847
final boolean setFullscreen(final boolean fullscreen)
Enable or disable fullscreen mode for this window.
Definition: GLWindow.java:534
final KeyListener[] getKeyListeners()
Definition: GLWindow.java:922
final String toSimpleString()
Returns a simple string one-line representation of this instance using toSimpleString(StringBuilder).
Definition: GLWindow.java:560
final int[] convertToPixelUnits(final int[] windowUnitsAndResult)
Converts the given window units into pixel units in place.
Definition: GLWindow.java:481
final void setAlwaysOnBottom(final boolean value)
Definition: GLWindow.java:361
final int getStatePublicBitCount()
Number of all public state bits.
Definition: GLWindow.java:231
final int getSupportedStateMask()
Returns the supported state mask of the implementation.
Definition: GLWindow.java:251
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
Definition: GLWindow.java:615
final void unlockSurface()
Unlock the surface of this native window.
Definition: GLWindow.java:999
final void setSurfaceSize(final int pixelWidth, final int pixelHeight)
Sets the size of the window's surface in pixel units which claims the window's client area excluding ...
Definition: GLWindow.java:629
final PointerIcon getPointerIcon()
Returns the current PointerIcon, which maybe null for the default.
Definition: GLWindow.java:317
final Rectangle getBounds()
Returns a newly created Rectangle containing window origin, getX() & getY(), and size,...
Definition: GLWindow.java:456
final boolean isPointerConfined()
Definition: GLWindow.java:327
final void addWindowListener(final WindowListener l)
Appends the given com.jogamp.newt.event.WindowListener to the end of the list.
Definition: GLWindow.java:882
final void removeKeyListener(final KeyListener l)
Definition: GLWindow.java:912
final void setFocusAction(final FocusRunnable focusAction)
Sets a FocusRunnable, which FocusRunnable#run() method is executed before the native focus is request...
Definition: GLWindow.java:406
final void addSurfaceUpdatedListener(final SurfaceUpdatedListener l)
Appends the given SurfaceUpdatedListener to the end of the list.
Definition: GLWindow.java:1025
final int getHeight()
Returns the height of the client area excluding insets (window decorations) in window units.
Definition: GLWindow.java:451
void setTopLevelPosition(final int x, final int y)
Sets the location of the top-level window inclusive insets (window decorations) in window units.
Definition: GLWindow.java:529
WindowClosingMode getDefaultCloseOperation()
Definition: GLWindow.java:217
final boolean isMaximizedHorz()
Definition: GLWindow.java:401
final void setSticky(final boolean value)
Definition: GLWindow.java:381
final CapabilitiesImmutable getChosenCapabilities()
Gets an immutable set of chosen capabilities.
Definition: GLWindow.java:266
void sendWindowEvent(final int eventType)
Send a WindowEvent to all WindowListener.
Definition: GLWindow.java:862
final void setResizable(final boolean value)
Definition: GLWindow.java:371
final boolean isPointerVisible()
Definition: GLWindow.java:307
final Thread getSurfaceLockOwner()
Return the locking owner's Thread, or null if not locked.
Definition: GLWindow.java:1009
final void surfaceUpdated(final Object updater, final NativeSurface ns, final long when)
Notification of a surface update event, eg.
Definition: GLWindow.java:1035
boolean hasFocus()
Returns true if this native window owns the focus, otherwise false.
Definition: GLWindow.java:426
final InsetsImmutable getInsets()
Returns the insets defined as the width and height of the window decoration on the left,...
Definition: GLWindow.java:431
final WindowListener getWindowListener(final int index)
Definition: GLWindow.java:867
final int getStatePublicBitmask()
Bitmask covering all public state bits.
Definition: GLWindow.java:236
CapabilitiesChooser setCapabilitiesChooser(final CapabilitiesChooser chooser)
Set the CapabilitiesChooser to help determine the native visual type.
Definition: GLWindow.java:261
final void setUndecorated(final boolean value)
Definition: GLWindow.java:337
boolean consumeEvent(final NEWTEvent event)
Consume the event.
Definition: GLWindow.java:839
final boolean isMaximizedVert()
Definition: GLWindow.java:396
final void removeMouseListener(final MouseListener l)
Removes the given MouseListener from the list.
Definition: GLWindow.java:937
RecursiveLock getLock()
Returns the implementation's RecursiveLock synchronizing multithreaded access if used.
Definition: GLWindow.java:989
final void addWindowListener(final int index, final WindowListener l)
Inserts the given com.jogamp.newt.event.WindowListener at the specified position in the list.
Definition: GLWindow.java:887
final boolean setSurfaceScale(final float[] pixelScale)
Request a pixel scale in x- and y-direction for the associated NativeSurface, where size_in_pixel_uni...
Definition: GLWindow.java:495
final void addMouseListener(final int index, final MouseListener l)
Inserts the given MouseListener at the specified position in the list.
Definition: GLWindow.java:932
final long getWindowHandle()
Returns the window handle for this NativeWindow.
Definition: GLWindow.java:1040
final void removeGestureHandler(final GestureHandler gh)
Removes the given GestureHandler from the list.
Definition: GLWindow.java:968
void setDefaultGesturesEnabled(final boolean enable)
Enable or disable default GestureHandler.
Definition: GLWindow.java:952
final float[] getMinimumSurfaceScale(final float[] result)
Returns the minimum pixel scale of the associated NativeSurface.
Definition: GLWindow.java:510
static GLWindow create(final NativeWindow parentNativeWindow, final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new child Window of the given parentNativeWindow with the given GL...
Definition: GLWindow.java:209
final boolean isKeyboardVisible()
Return true if the virtual on-screen keyboard is visible, otherwise false.
Definition: GLWindow.java:897
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
Definition: GLWindow.java:605
final int getWidth()
Returns the width of the client area excluding insets (window decorations) in window units.
Definition: GLWindow.java:446
final void runOnEDTIfAvail(final boolean wait, final Runnable task)
Definition: GLWindow.java:857
final Window getDelegatedWindow()
If the implementation uses delegation, return the delegated Window instance, otherwise return this in...
Definition: GLWindow.java:277
final void addSurfaceUpdatedListener(final int index, final SurfaceUpdatedListener l)
Inserts the given SurfaceUpdatedListener at the specified position in the list.
Definition: GLWindow.java:1030
final MouseListener[] getMouseListeners()
Returns all MouseListener.
Definition: GLWindow.java:947
final void confinePointer(final boolean grab)
Confine the pointer to this window, ie.
Definition: GLWindow.java:332
final MouseListener getMouseListener(final int index)
Returns the MouseListener from the list at the given index.
Definition: GLWindow.java:942
final void requestFocus()
Request focus for this native window.
Definition: GLWindow.java:416
boolean areDefaultGesturesEnabled()
Return true if default GestureHandler are enabled.
Definition: GLWindow.java:956
GLWindow(final Window window)
Constructor.
Definition: GLWindow.java:127
final boolean isGLStatePreservationSupported()
Definition: GLWindow.java:818
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
Specifies a set of OpenGL capabilities.
Abstraction for an OpenGL rendering context.
Definition: GLContext.java:74
abstract GLDrawable createGLDrawable(NativeSurface target)
Returns an unrealized GLDrawable according to it's chosen GLCapabilitiesImmutable,...
static GLDrawableFactory getFactory(final GLProfile glProfile)
Returns the sole GLDrawableFactory instance.
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
static final String GLES3
The embedded OpenGL profile ES 3.x, with x >= 0.
Definition: GLProfile.java:588
static final String GL3
The desktop OpenGL core profile 3.x, with x >= 1.
Definition: GLProfile.java:576
static final String GLES2
The embedded OpenGL profile ES 2.x, with x >= 0.
Definition: GLProfile.java:585
static GLProfile getDefault(final AbstractGraphicsDevice device)
Returns a default GLProfile object, reflecting the best for the running platform.
Definition: GLProfile.java:739
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static final String GL4ES3
The intersection of the desktop GL4 and ES3 profile, available only if either ES3 or GL4 w/ GL_ARB_ES...
Definition: GLProfile.java:600
static JoglVersion getInstance()
static StringBuilder getGLInfo(final GL gl, final StringBuilder sb)
static StringBuilder getDefaultOpenGLInfo(AbstractGraphicsDevice device, StringBuilder sb, final boolean withCapabilitiesInfo)
Window closing mode if triggered by toolkit close operation.
Reparenting operation types.
Definition: Window.java:894
A marker interface describing a graphics configuration, visual, or pixel format in a toolkit-independ...
CapabilitiesImmutable getChosenCapabilities()
Return the capabilities reflecting this graphics configuration, which may differ from the capabilitie...
CapabilitiesImmutable getRequestedCapabilities()
Return the capabilities used to choose this graphics configuration.
Provides a mechanism by which applications can customize the window type selection for a given Capabi...
Specifies an immutable set of capabilities that a window's rendering context must support,...
Provides low-level information required for hardware-accelerated rendering using a surface in a platf...
AbstractGraphicsConfiguration getGraphicsConfiguration()
Returns the graphics configuration corresponding to this window.
Extend the NativeSurface interface with windowing information such as window-handle,...
Clients may add their SurfaceUpdateListener implementation to a com.jogamp.nativewindow....
Immutable insets representing rectangular window decoration insets on all four edges in window units.
Native PointerIcon handle.
Definition: Display.java:92
Specifying NEWT's Window functionality:
Definition: Window.java:115
Window getDelegatedWindow()
If the implementation uses delegation, return the delegated Window instance, otherwise return this in...
void addWindowListener(WindowListener l)
Appends the given com.jogamp.newt.event.WindowListener to the end of the list.
static final boolean DEBUG_IMPLEMENTATION
Definition: Window.java:118
void setWindowDestroyNotifyAction(Runnable r)
Set a custom action handling destruction issued by a toolkit triggered window destroy replacing the d...
Generic gesture handler interface designed to allow pass-through filtering of InputEvents.
Listener for KeyEvents.
FPSCounter feature.
Definition: FPSCounter.java:37
void resetFPSCounter()
Reset all performance counter (startTime, currentTime, frame number)
An animator control interface, which implementation may drive a com.jogamp.opengl....
boolean isPaused()
Indicates whether this animator is started and either manually paused or paused automatically due to ...
boolean resume()
Resumes animation if paused.
boolean isAnimating()
Indicates whether this animator is started and is not paused.
boolean stop()
Stops this animator.
boolean pause()
Pauses this animator.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GLAnimatorControl getAnimator()
static final boolean SCREEN_CHANGE_ACTION_ENABLED
Flag reflecting whether the GLDrawable reconfiguration will be issued in case a screen device change ...
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.
GL4ES3 getGL4ES3()
Casts this object to the GL4ES3 interface.
GL3 getGL3()
Casts this object to the GL3 interface.
boolean isGL3()
Indicates whether this GL object conforms to the OpenGL ≥ 3.1 core profile.
GLES2 getGLES2()
Casts this object to the GLES2 interface.
boolean isGLES3()
Indicates whether this GL object conforms to the OpenGL ES ≥ 3.0 profile.
boolean isGL4ES3()
Returns true if this GL object conforms to a GL4ES3 compatible profile, i.e.
GLES3 getGLES3()
Casts this object to the GLES3 interface.
boolean isGLES2()
Indicates whether this GL object conforms to the OpenGL ES ≥ 2.0 profile.
Specifies an immutable set of OpenGL capabilities.
GLProfile getGLProfile()
Returns the GL profile you desire or used by the drawable.
An abstraction for an OpenGL rendering target.
Definition: GLDrawable.java:51
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...
NativeSurface getNativeSurface()
Returns the associated NativeSurface of this NativeSurfaceHolder.
void setRealized(boolean realized)
Indicates to GLDrawable implementations whether the underlying surface has been created and can be dr...
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.