Jogamp
Relocated RecursiveToolkitLock -> gluegen ; NEWT AWTParentWindowAdapter fix & WindowI...
[jogl.git] / src / newt / classes / com / jogamp / newt / opengl / GLWindow.java
CommitLineData
a959c53b
KR
1/*
2 * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
0feca163 3 * Copyright (c) 2010 JogAmp Community. All rights reserved.
a959c53b
KR
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
2d57c252 35package com.jogamp.newt.opengl;
a959c53b 36
2d57c252 37import com.jogamp.newt.*;
1ad8c39d 38import com.jogamp.newt.event.*;
0feca163 39import com.jogamp.newt.impl.WindowImpl;
a959c53b 40import javax.media.nativewindow.*;
018c7e86 41import javax.media.nativewindow.util.Point;
a959c53b 42import javax.media.opengl.*;
f3bc93b0 43import com.jogamp.opengl.impl.GLDrawableHelper;
018c7e86 44import javax.media.nativewindow.util.Insets;
a959c53b
KR
45
46/**
0feca163
SG
47 * An implementation of {@link javax.media.opengl.GLAutoDrawable} interface,
48 * using an aggregation of a {@link com.jogamp.newt.Window} implementation.
2268a6ce
SG
49 * <P>
50 * This implementation does not make the OpenGL context current<br>
0feca163
SG
51 * before calling the various input EventListener callbacks, ie {@link com.jogamp.newt.event.MouseListener} etc.<br>
52 * This design decision is made in favor of a more performant and simplified
53 * implementation. Also the event dispatcher shall be implemented OpenGL agnostic.<br>
54 * To be able to use OpenGL commands from within such input {@link com.jogamp.newt.event.NEWTEventListener},<br>
55 * you can inject {@link javax.media.opengl.GLRunnable} objects
56 * via {@link #invoke(boolean, javax.media.opengl.GLRunnable)} to the OpenGL command stream.<br>
2268a6ce 57 * <p>
a959c53b 58 */
0feca163
SG
59public class GLWindow implements GLAutoDrawable, Window {
60 private WindowImpl window;
a959c53b 61
476d1d75
MB
62 /**
63 * Constructor. Do not call this directly -- use {@link #create()} instead.
64 */
811bd23e 65 protected GLWindow(Window window) {
018c7e86 66 resetCounter();
0feca163
SG
67 this.window = (WindowImpl) window;
68 ((WindowImpl)this.window).setHandleDestroyNotify(false);
1ad8c39d 69 window.addWindowListener(new WindowAdapter() {
969e4276 70 public void windowRepaint(WindowUpdateEvent e) {
0feca163 71 if( !GLWindow.this.window.isSurfaceLockedByOtherThread() && !GLWindow.this.helper.isExternalAnimatorAnimating() ) {
969e4276
SG
72 display();
73 }
74 }
75
a959c53b
KR
76 public void windowResized(WindowEvent e) {
77 sendReshape = true;
0feca163 78 if( !GLWindow.this.window.isSurfaceLockedByOtherThread() && !GLWindow.this.helper.isExternalAnimatorAnimating() ) {
969e4276
SG
79 display();
80 }
a959c53b
KR
81 }
82
a959c53b 83 public void windowDestroyNotify(WindowEvent e) {
0feca163 84 if( !GLWindow.this.window.isSurfaceLockedByOtherThread() && !GLWindow.this.helper.isExternalAnimatorAnimating() ) {
969e4276
SG
85 destroy();
86 } else {
63be4a40
SG
87 sendDestroy = true;
88 }
a959c53b
KR
89 }
90 });
0feca163 91 this.window.setLifecycleHook(new GLLifecycleHook());
a959c53b
KR
92 }
93
0feca163
SG
94 /**
95 * Creates a new GLWindow attaching a new Window referencing a new Screen
96 * with the given GLCapabilities.
97 * <P>
98 * The resulting GLWindow owns the Window, Screen and Device, ie it will be destructed.
99 */
a959c53b 100 public static GLWindow create(GLCapabilities caps) {
0feca163 101 return new GLWindow(NewtFactory.createWindow(caps));
a959c53b
KR
102 }
103
0feca163
SG
104 /**
105 * Creates a new GLWindow attaching a new Window referencing the given Screen
106 * with the given GLCapabilities.
107 * <P>
108 * The resulting GLWindow owns the Window, ie it will be destructed.
109 */
110 public static GLWindow create(Screen screen, GLCapabilities caps) {
111 return new GLWindow(NewtFactory.createWindow(screen, caps));
a959c53b
KR
112 }
113
0feca163
SG
114 /**
115 * Creates a new GLWindow attaching the given window.
116 * <P>
117 * The resulting GLWindow does not own the given Window, ie it will not be destructed.
118 */
119 public static GLWindow create(Window window) {
811bd23e 120 return new GLWindow(window);
a959c53b 121 }
6e599a26 122
0feca163
SG
123 /**
124 * Creates a new GLWindow attaching a new child Window
125 * of the given <code>parentNativeWindow</code> with the given GLCapabilities.
126 * <P>
127 * The Display/Screen will be compatible with the <code>parentNativeWindow</code>,
128 * or even identical in case it's a Newt Window.
129 * <P>
130 * The resulting GLWindow owns the Window, ie it will be destructed.
131 */
132 public static GLWindow create(NativeWindow parentNativeWindow, GLCapabilities caps) {
133 return new GLWindow(NewtFactory.createWindow(parentNativeWindow, caps));
a959c53b 134 }
a959c53b 135
0feca163
SG
136 //----------------------------------------------------------------------
137 // Window Access
138 //
a959c53b 139
0feca163
SG
140 public final Capabilities getChosenCapabilities() {
141 if (drawable == null) {
142 return window.getChosenCapabilities();
811bd23e 143 }
811bd23e 144
0feca163 145 return drawable.getChosenGLCapabilities();
a959c53b
KR
146 }
147
0feca163
SG
148 public final Capabilities getRequestedCapabilities() {
149 return window.getRequestedCapabilities();
811bd23e
SG
150 }
151
0feca163
SG
152 public final Window getWindow() {
153 return window;
811bd23e
SG
154 }
155
018c7e86
SG
156 public final NativeWindow getParent() {
157 return window.getParent();
811bd23e
SG
158 }
159
0feca163 160 public final Screen getScreen() {
a959c53b
KR
161 return window.getScreen();
162 }
163
0feca163 164 public final void setTitle(String title) {
a959c53b
KR
165 window.setTitle(title);
166 }
167
0feca163 168 public final String getTitle() {
a959c53b
KR
169 return window.getTitle();
170 }
171
0feca163 172 public final void setUndecorated(boolean value) {
a959c53b
KR
173 window.setUndecorated(value);
174 }
175
0feca163 176 public final boolean isUndecorated() {
a959c53b
KR
177 return window.isUndecorated();
178 }
179
0feca163 180 public final void setFocusAction(FocusRunnable focusAction) {
a4b16ad5
SG
181 window.setFocusAction(focusAction);
182 }
0feca163
SG
183
184 public final void requestFocus() {
185 window.requestFocus();
811bd23e
SG
186 }
187
609e3083
SG
188 public boolean hasFocus() {
189 return window.hasFocus();
190 }
191
0feca163
SG
192 public final Insets getInsets() {
193 return window.getInsets();
811bd23e 194 }
a959c53b 195
0feca163 196 public final void setPosition(int x, int y) {
a959c53b
KR
197 window.setPosition(x, y);
198 }
7bed517f 199
0feca163 200 public final boolean setFullscreen(boolean fullscreen) {
a959c53b
KR
201 return window.setFullscreen(fullscreen);
202 }
0feca163
SG
203
204 public final boolean isFullscreen() {
205 return window.isFullscreen();
811bd23e 206 }
a959c53b 207
0feca163 208 public final boolean isVisible() {
a959c53b
KR
209 return window.isVisible();
210 }
211
0feca163
SG
212 public final String toString() {
213 return "NEWT-GLWindow[ \n\tHelper: " + helper + ", \n\tDrawable: " + drawable +
214 ", \n\tContext: " + context + /** ", \n\tWindow: "+window+", \n\tFactory: "+factory+ */ "]";
a959c53b
KR
215 }
216
0feca163
SG
217 public final int reparentWindow(NativeWindow newParent) {
218 return window.reparentWindow(newParent);
a959c53b
KR
219 }
220
0feca163
SG
221 public final int reparentWindow(NativeWindow newParent, boolean forceDestroyCreate) {
222 return window.reparentWindow(newParent, forceDestroyCreate);
a959c53b
KR
223 }
224
0feca163
SG
225 public final void removeChild(NativeWindow win) {
226 window.removeChild(win);
a959c53b
KR
227 }
228
0feca163
SG
229 public final void addChild(NativeWindow win) {
230 window.addChild(win);
a959c53b
KR
231 }
232
0feca163
SG
233 //----------------------------------------------------------------------
234 // Window.LifecycleHook Implementation
235 //
969e4276 236
0feca163
SG
237 public final void destroy(boolean unrecoverable) {
238 window.destroy(unrecoverable);
bf584fba
SG
239 }
240
0feca163
SG
241 public final void setVisible(boolean visible) {
242 window.setVisible(visible);
a959c53b
KR
243 }
244
0feca163
SG
245 public final void setSize(int width, int height) {
246 window.setSize(width, height);
a959c53b
KR
247 }
248
0feca163
SG
249 public final boolean isValid() {
250 return window.isValid();
969e4276 251 }
a959c53b 252
0feca163
SG
253 public final boolean isNativeValid() {
254 return window.isNativeValid();
a959c53b
KR
255 }
256
018c7e86
SG
257 public Point getLocationOnScreen(Point storage) {
258 return window.getLocationOnScreen(storage);
259 }
260
0feca163
SG
261 // Hide methods here ..
262 protected class GLLifecycleHook implements WindowImpl.LifecycleHook {
263
264 class DisposeAction implements Runnable {
265 public void run() {
266 // Lock: Covered by DestroyAction ..
267 helper.dispose(GLWindow.this);
268 }
269 }
270 DisposeAction disposeAction = new DisposeAction();
271
272 /** Window.LifecycleHook */
273 public synchronized void destroyAction(boolean unrecoverable) {
274 if(Window.DEBUG_WINDOW_EVENT || Window.DEBUG_IMPLEMENTATION) {
275 String msg = new String("GLWindow.destroy("+unrecoverable+") "+Thread.currentThread()+", start");
276 System.err.println(msg);
277 //Exception e1 = new Exception(msg);
278 //e1.printStackTrace();
279 }
280
281 if( window.isNativeValid() && null != drawable && drawable.isRealized() ) {
282 if( null != context && context.isCreated() ) {
283 // Catch dispose GLExceptions by GLEventListener, just 'print' them
284 // so we can continue with the destruction.
285 try {
286 helper.invokeGL(drawable, context, disposeAction, null);
287 } catch (GLException gle) {
288 gle.printStackTrace();
289 }
290 context.destroy();
291 }
292 drawable.setRealized(false);
293 }
294 context = null;
295 drawable = null;
296
297 if(unrecoverable) {
298 helper=null;
299 }
300
301 if(Window.DEBUG_WINDOW_EVENT || Window.DEBUG_IMPLEMENTATION) {
302 System.err.println("GLWindow.destroy("+unrecoverable+") "+Thread.currentThread()+", fin");
303 }
304 }
305
306 /** Window.LifecycleHook */
307 public synchronized void setVisibleAction(boolean visible, boolean nativeWindowCreated) {
308 if(Window.DEBUG_WINDOW_EVENT || Window.DEBUG_IMPLEMENTATION) {
309 String msg = new String("GLWindow.setVisibleAction("+visible+", "+nativeWindowCreated+") "+Thread.currentThread()+", start");
310 System.err.println(msg);
311 // Exception e1 = new Exception(msg);
312 // e1.printStackTrace();
313 }
314
315 /* if (nativeWindowCreated && null != context) {
316 throw new GLException("InternalError: Native Windows has been just created, but context wasn't destroyed (is not null)");
317 } */
318 if (null == context && visible && 0 != window.getWindowHandle() && 0<getWidth()*getHeight()) {
319 NativeWindow nw;
320 if (window.getWrappedWindow() != null) {
321 nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), window.getGraphicsConfiguration());
322 } else {
323 nw = window;
324 }
325 GLCapabilities glCaps = (GLCapabilities) nw.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
326 if(null==factory) {
327 factory = GLDrawableFactory.getFactory(glCaps.getGLProfile());
328 }
329 if(null==drawable) {
330 drawable = factory.createGLDrawable(nw);
331 }
332 drawable.setRealized(true);
333 context = drawable.createContext(null);
018c7e86 334 resetCounter();
0feca163 335 } else if(!visible) {
018c7e86 336 resetCounter();
0feca163
SG
337 }
338 if(Window.DEBUG_WINDOW_EVENT || Window.DEBUG_IMPLEMENTATION) {
339 String msg = new String("GLWindow.setVisibleAction("+visible+", "+nativeWindowCreated+") "+Thread.currentThread()+", fin");
340 System.err.println(msg);
341 //Exception e1 = new Exception(msg);
342 //e1.printStackTrace();
343 }
344 }
345
346 boolean animatorPaused = false;
347
348 public synchronized void reparentActionPre() {
349 GLAnimatorControl ctrl = GLWindow.this.getAnimator();
350 if ( null!=ctrl && ctrl.isAnimating() && ctrl.getThread() != Thread.currentThread() ) {
351 animatorPaused = true;
352 ctrl.pause();
353 }
354 }
355
356 public synchronized void reparentActionPost(int reparentActionType) {
018c7e86 357 resetCounter();
0feca163
SG
358 GLAnimatorControl ctrl = GLWindow.this.getAnimator();
359 if ( null!=ctrl && animatorPaused ) {
360 animatorPaused = false;
361 ctrl.resume();
362 }
363 }
364 }
a959c53b
KR
365 //----------------------------------------------------------------------
366 // OpenGL-related methods and state
367 //
368
a959c53b
KR
369 private GLDrawableFactory factory;
370 private GLDrawable drawable;
371 private GLContext context;
372 private GLDrawableHelper helper = new GLDrawableHelper();
373 // To make reshape events be sent immediately before a display event
374 private boolean sendReshape=false;
375 private boolean sendDestroy=false;
376 private boolean perfLog = false;
0feca163
SG
377 private long startTime, curTime, lastCheck;
378 private int totalFrames, lastFrames;
379
a959c53b
KR
380 public GLDrawableFactory getFactory() {
381 return factory;
382 }
383
384 public void setContext(GLContext newCtx) {
385 context = newCtx;
386 }
387
388 public GLContext getContext() {
389 return context;
390 }
391
392 public GL getGL() {
393 if (context == null) {
394 return null;
395 }
396 return context.getGL();
397 }
398
4e0a5af0 399 public GL setGL(GL gl) {
a959c53b
KR
400 if (context != null) {
401 context.setGL(gl);
4e0a5af0 402 return gl;
a959c53b 403 }
4e0a5af0 404 return null;
a959c53b
KR
405 }
406
407 public void addGLEventListener(GLEventListener listener) {
408 helper.addGLEventListener(listener);
409 }
410
302f183c
SG
411 public void addGLEventListener(int index, GLEventListener listener) {
412 helper.addGLEventListener(index, listener);
413 }
414
a959c53b
KR
415 public void removeGLEventListener(GLEventListener listener) {
416 helper.removeGLEventListener(listener);
417 }
418
0feca163
SG
419 public void setAnimator(GLAnimatorControl animatorControl) {
420 helper.setAnimator(animatorControl);
969e4276
SG
421 }
422
0feca163 423 public GLAnimatorControl getAnimator() {
969e4276
SG
424 return helper.getAnimator();
425 }
426
0feca163
SG
427 public boolean getPerfLogEnabled() { return perfLog; }
428
429 public void enablePerfLog(boolean v) {
430 perfLog = v;
431 }
432
0d24458c 433 public void invoke(boolean wait, GLRunnable glRunnable) {
969e4276 434 helper.invoke(this, wait, glRunnable);
0d24458c
SG
435 }
436
a959c53b 437 public void display() {
cf4c4037
SG
438 display(false);
439 }
440
441 public void display(boolean forceReshape) {
6e599a26
SG
442 if( null == window ) { return; }
443
969e4276 444 if(sendDestroy || ( null!=window && window.hasDeviceChanged() && GLAutoDrawable.SCREEN_CHANGE_ACTION_ENABLED ) ) {
63be4a40
SG
445 sendDestroy=false;
446 destroy();
447 return;
448 }
969e4276 449
018c7e86 450 if( null == context && isVisible() ) {
6e599a26
SG
451 // retry native window and drawable/context creation
452 setVisible(true);
453 }
454
0feca163 455 if( isVisible() && isNativeValid() && null != context ) {
969e4276
SG
456 if(forceReshape) {
457 sendReshape = true;
a92906bc 458 }
c8a9c59e
SG
459 if( NativeSurface.LOCK_SURFACE_NOT_READY < lockSurface() ) {
460 try{
461 helper.invokeGL(drawable, context, displayAction, initAction);
462 } finally {
463 unlockSurface();
464 }
a959c53b
KR
465 }
466 }
467 }
468
a92906bc 469 /** This implementation uses a static value */
a959c53b 470 public void setAutoSwapBufferMode(boolean onOrOff) {
2268a6ce 471 helper.setAutoSwapBufferMode(onOrOff);
a959c53b
KR
472 }
473
a92906bc 474 /** This implementation uses a static value */
a959c53b 475 public boolean getAutoSwapBufferMode() {
2268a6ce 476 return helper.getAutoSwapBufferMode();
a959c53b
KR
477 }
478
479 public void swapBuffers() {
2268a6ce 480 if(drawable!=null && context != null) {
1d333a77 481 // Lock: Locked Surface/Window by MakeCurrent/Release
2268a6ce 482 if (context != GLContext.getCurrent()) {
a959c53b
KR
483 // Assume we should try to make the context current before swapping the buffers
484 helper.invokeGL(drawable, context, swapBuffersAction, initAction);
485 } else {
486 drawable.swapBuffers();
487 }
488 }
489 }
490
491 class InitAction implements Runnable {
492 public void run() {
1d333a77 493 // Lock: Locked Surface/Window by MakeCurrent/Release
a959c53b 494 helper.init(GLWindow.this);
018c7e86 495 resetCounter();
a959c53b
KR
496 }
497 }
498 private InitAction initAction = new InitAction();
499
a959c53b
KR
500 class DisplayAction implements Runnable {
501 public void run() {
1d333a77 502 // Lock: Locked Surface/Window by display _and_ MakeCurrent/Release
a959c53b 503 if (sendReshape) {
969e4276 504 helper.reshape(GLWindow.this, 0, 0, getWidth(), getHeight());
a959c53b
KR
505 sendReshape = false;
506 }
507
508 helper.display(GLWindow.this);
509
510 curTime = System.currentTimeMillis();
511 totalFrames++;
512
513 if(perfLog) {
514 long dt0, dt1;
515 lastFrames++;
516 dt0 = curTime-lastCheck;
517 if ( dt0 > 5000 ) {
518 dt1 = curTime-startTime;
0feca163 519 System.err.println(dt0/1000 +"s: "+ lastFrames + "f, " + (lastFrames*1000)/dt0 + " fps, "+dt0/lastFrames+" ms/f; "+
a959c53b
KR
520 "total: "+ dt1/1000+"s, "+(totalFrames*1000)/dt1 + " fps, "+dt1/totalFrames+" ms/f");
521 lastCheck=curTime;
522 lastFrames=0;
523 }
524 }
525 }
526 }
a92906bc 527 private DisplayAction displayAction = new DisplayAction();
a959c53b 528
0feca163
SG
529 /**
530 * @return Time of the first display call in milliseconds.
531 * This value is reset if becoming visible again or reparenting.
0feca163
SG
532 */
533 public final long getStartTime() {
018c7e86 534 return startTime;
0feca163 535 }
a959c53b 536
0feca163
SG
537 /**
538 * @return Time of the last display call in milliseconds.
539 * This value is reset if becoming visible again or reparenting.
0feca163
SG
540 */
541 public final long getCurrentTime() {
018c7e86 542 return curTime;
0feca163
SG
543 }
544
545 /**
546 * @return Duration <code>getCurrentTime() - getStartTime()</code>.
547 *
548 * @see #getStartTime()
549 * @see #getCurrentTime()
550 */
551 public final long getDuration() {
552 return getCurrentTime()-getStartTime();
553 }
554
555 /**
556 * @return Number of frames displayed since the first display call, ie <code>getStartTime()</code>.
557 * This value is reset if becoming visible again or reparenting.
0feca163 558 */
018c7e86
SG
559 public final int getTotalFrames() {
560 return totalFrames;
561 }
562
563 /** Reset all counter (startTime, currentTime, frame number) */
564 public synchronized void resetCounter() {
565 startTime = System.currentTimeMillis(); // overwrite startTime to real init one
566 curTime = startTime;
567 lastCheck = startTime;
568 totalFrames = 0; lastFrames = 0;
0feca163 569 }
a959c53b 570
a959c53b
KR
571 class SwapBuffersAction implements Runnable {
572 public void run() {
573 drawable.swapBuffers();
574 }
575 }
a959c53b
KR
576 private SwapBuffersAction swapBuffersAction = new SwapBuffersAction();
577
578 //----------------------------------------------------------------------
0feca163 579 // GLDrawable methods
a959c53b
KR
580 //
581
018c7e86
SG
582 public final NativeSurface getNativeSurface() {
583 return null!=drawable ? drawable.getNativeSurface() : null;
a959c53b
KR
584 }
585
0feca163
SG
586 public final long getHandle() {
587 return null!=drawable ? drawable.getHandle() : 0;
8883fa88 588 }
589
0feca163
SG
590 public final void destroy() {
591 window.destroy();
a959c53b
KR
592 }
593
0feca163
SG
594 public final int getX() {
595 return window.getX();
6e599a26
SG
596 }
597
0feca163
SG
598 public final int getY() {
599 return window.getY();
6e599a26
SG
600 }
601
0feca163
SG
602 public final int getWidth() {
603 return window.getWidth();
a959c53b
KR
604 }
605
0feca163
SG
606 public final int getHeight() {
607 return window.getHeight();
1d333a77
SG
608 }
609
a959c53b
KR
610 //----------------------------------------------------------------------
611 // GLDrawable methods that are not really needed
612 //
613
0feca163 614 public final GLContext createContext(GLContext shareWith) {
a959c53b
KR
615 return drawable.createContext(shareWith);
616 }
617
0feca163 618 public final void setRealized(boolean realized) {
a959c53b
KR
619 }
620
0feca163 621 public final boolean isRealized() {
811bd23e
SG
622 return ( null != drawable ) ? drawable.isRealized() : false;
623 }
624
0feca163 625 public final GLCapabilities getChosenGLCapabilities() {
a959c53b
KR
626 if (drawable == null) {
627 throw new GLException("No drawable yet");
628 }
629
630 return drawable.getChosenGLCapabilities();
631 }
632
0feca163 633 public final GLProfile getGLProfile() {
a959c53b
KR
634 if (drawable == null) {
635 throw new GLException("No drawable yet");
636 }
637
638 return drawable.getGLProfile();
639 }
0feca163
SG
640
641 //----------------------------------------------------------------------
642 // Window completion
643 //
644 public final void windowRepaint(int x, int y, int width, int height) {
645 window.windowRepaint(x, y, width, height);
646 }
647
648 public final void enqueueEvent(boolean wait, com.jogamp.newt.event.NEWTEvent event) {
649 window.enqueueEvent(wait, event);
650 }
651
652 public final void runOnEDTIfAvail(boolean wait, final Runnable task) {
653 window.runOnEDTIfAvail(wait, task);
654 }
655
656 public final SurfaceUpdatedListener getSurfaceUpdatedListener(int index) {
657 return window.getSurfaceUpdatedListener(index);
658 }
659
660 public final SurfaceUpdatedListener[] getSurfaceUpdatedListeners() {
661 return window.getSurfaceUpdatedListeners();
662 }
663
664 public final void removeAllSurfaceUpdatedListener() {
665 window.removeAllSurfaceUpdatedListener();
666 }
667
668 public final void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
669 window.removeSurfaceUpdatedListener(l);
670 }
671
672 public final void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
673 window.addSurfaceUpdatedListener(l);
674 }
675
676 public final void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException {
677 window.addSurfaceUpdatedListener(index, l);
678 }
679
680 public void sendWindowEvent(int eventType) {
681 window.sendWindowEvent(eventType);
682 }
683
684 public final WindowListener getWindowListener(int index) {
685 return window.getWindowListener(index);
686 }
687
688 public final WindowListener[] getWindowListeners() {
689 return window.getWindowListeners();
690 }
691
692 public final void removeWindowListener(WindowListener l) {
693 window.removeWindowListener(l);
694 }
695
696 public final void addWindowListener(WindowListener l) {
697 window.addWindowListener(l);
698 }
699
700 public final void addWindowListener(int index, WindowListener l) throws IndexOutOfBoundsException {
701 window.addWindowListener(index, l);
702 }
703
704 public final void addKeyListener(KeyListener l) {
705 window.addKeyListener(l);
706 }
707
708 public final void addKeyListener(int index, KeyListener l) {
709 window.addKeyListener(index, l);
710 }
711
712 public final void removeKeyListener(KeyListener l) {
713 window.removeKeyListener(l);
714 }
715
716 public final KeyListener getKeyListener(int index) {
717 return window.getKeyListener(index);
718 }
719
720 public final KeyListener[] getKeyListeners() {
721 return window.getKeyListeners();
722 }
723
724 public final void addMouseListener(MouseListener l) {
725 window.addMouseListener(l);
726 }
727
728 public final void addMouseListener(int index, MouseListener l) {
729 window.addMouseListener(index, l);
730 }
731
732 public final void removeMouseListener(MouseListener l) {
733 window.removeMouseListener(l);
734 }
735
736 public final MouseListener getMouseListener(int index) {
737 return window.getMouseListener(index);
738 }
739
740 public final MouseListener[] getMouseListeners() {
741 return window.getMouseListeners();
742 }
743
744 //----------------------------------------------------------------------
745 // NativeWindow completion
746 //
747
748 public final int lockSurface() {
749 return window.lockSurface();
750 }
751
752 public final void unlockSurface() throws NativeWindowException {
753 window.unlockSurface();
754 }
755
756 public final boolean isSurfaceLockedByOtherThread() {
757 return window.isSurfaceLockedByOtherThread();
758 }
759
760 public final boolean isSurfaceLocked() {
761 return window.isSurfaceLocked();
762 }
763
764 public final Thread getSurfaceLockOwner() {
765 return window.getSurfaceLockOwner();
766
767 }
768
769 public final Exception getSurfaceLockStack() {
770 return window.getSurfaceLockStack();
771 }
772
773 public final boolean surfaceSwap() {
774 return window.surfaceSwap();
775 }
776
777 public final void invalidate() {
778 window.invalidate();
779 }
780
781 public final long getWindowHandle() {
782 return window.getWindowHandle();
783
784 }
785
786 public final long getSurfaceHandle() {
787 return window.getSurfaceHandle();
788
789 }
790
791 public final AbstractGraphicsConfiguration getGraphicsConfiguration() {
792 return window.getGraphicsConfiguration();
793 }
794
795 public final long getDisplayHandle() {
796 return window.getDisplayHandle();
797 }
798
799 public final int getScreenIndex() {
800 return window.getScreenIndex();
801 }
802
018c7e86
SG
803 public final void surfaceUpdated(Object updater, NativeSurface ns, long when) {
804 window.surfaceUpdated(updater, ns, when);
0feca163 805 }
a959c53b 806}
http://JogAmp.org git info: FAQ, tutorial and man pages.