Jogamp
NEWT: Fix EDTUtil/DefaultEDTUtil - Locking/Behaviour
[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.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * - Redistribution of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * - Redistribution in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * Neither the name of Sun Microsystems, Inc. or the names of
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * This software is provided "AS IS," without a warranty of any kind. ALL
20 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
21 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
22 * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
23 * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
24 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
25 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
26 * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
27 * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
28 * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
29 * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
30 * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
31 *
32 */
33
2d57c252 34package com.jogamp.newt.opengl;
a959c53b 35
2d57c252 36import com.jogamp.newt.*;
1ad8c39d 37import com.jogamp.newt.event.*;
969e4276 38import com.jogamp.newt.util.*;
811bd23e 39import com.jogamp.nativewindow.impl.RecursiveToolkitLock;
a959c53b
KR
40import javax.media.nativewindow.*;
41import javax.media.opengl.*;
f3bc93b0 42import com.jogamp.opengl.impl.GLDrawableHelper;
a92906bc 43import java.util.*;
a959c53b
KR
44
45/**
46 * An implementation of {@link Window} which is customized for OpenGL
2268a6ce
SG
47 * use, and which implements the {@link javax.media.opengl.GLAutoDrawable} interface.
48 * <P>
49 * This implementation does not make the OpenGL context current<br>
50 * before calling the various input EventListener callbacks (MouseListener, KeyListener,
51 * etc.).<br>
52 * This design decision is made to favor a more performant and simplified
53 * implementation, as well as the event dispatcher shall be allowed
54 * not having a notion about OpenGL.
55 * <p>
a959c53b
KR
56 */
57public class GLWindow extends Window implements GLAutoDrawable {
a959c53b
KR
58 private Window window;
59
476d1d75
MB
60 /**
61 * Constructor. Do not call this directly -- use {@link #create()} instead.
62 */
811bd23e 63 protected GLWindow(Window window) {
969e4276 64 this.startTime = System.currentTimeMillis();
a959c53b 65 this.window = window;
811bd23e 66 this.window.setHandleDestroyNotify(false);
1ad8c39d 67 window.addWindowListener(new WindowAdapter() {
969e4276
SG
68 public void windowRepaint(WindowUpdateEvent e) {
69 if( !windowIsLocked() && null == getAnimator() ) {
70 display();
71 }
72 }
73
a959c53b
KR
74 public void windowResized(WindowEvent e) {
75 sendReshape = true;
969e4276
SG
76 if( !windowIsLocked() && null == getAnimator() ) {
77 display();
78 }
a959c53b
KR
79 }
80
a959c53b 81 public void windowDestroyNotify(WindowEvent e) {
969e4276
SG
82 if( !windowIsLocked() && null == getAnimator() ) {
83 destroy();
84 } else {
63be4a40
SG
85 sendDestroy = true;
86 }
a959c53b
KR
87 }
88 });
89 }
90
6e599a26
SG
91 /** Creates a new GLWindow attaching the given window - not owning the Window. */
92 public static GLWindow create(Window window) {
93 return create(null, window, null, false);
a959c53b
KR
94 }
95
811bd23e 96 /** Creates a new GLWindow attaching a new native child Window of the given <code>parentNativeWindow</code>
6e599a26 97 with the given GLCapabilities - owning the Window */
811bd23e
SG
98 public static GLWindow create(NativeWindow parentNativeWindow, GLCapabilities caps) {
99 return create(parentNativeWindow, null, caps, false);
a959c53b
KR
100 }
101
6e599a26
SG
102 /** Creates a new GLWindow attaching a new decorated Window on the local display, screen 0, with a
103 dummy visual ID and given GLCapabilities - owning the window */
a959c53b 104 public static GLWindow create(GLCapabilities caps) {
6e599a26 105 return create(null, null, caps, false);
a959c53b
KR
106 }
107
6e599a26
SG
108 /** Creates a new GLWindow attaching a new Window on the local display, screen 0, with a
109 dummy visual ID and given GLCapabilities - owning the window */
a959c53b 110 public static GLWindow create(GLCapabilities caps, boolean undecorated) {
6e599a26 111 return create(null, null, caps, undecorated);
a959c53b
KR
112 }
113
3cc7335e 114 /** Either or: window (prio), or caps and undecorated (2nd choice) */
811bd23e 115 private static GLWindow create(NativeWindow parentNativeWindow, Window window,
3cc7335e
SG
116 GLCapabilities caps,
117 boolean undecorated) {
a959c53b 118 if (window == null) {
3cc7335e
SG
119 if (caps == null) {
120 caps = new GLCapabilities(null); // default ..
121 }
811bd23e 122 window = NewtFactory.createWindow(parentNativeWindow, caps, undecorated);
a959c53b
KR
123 }
124
811bd23e 125 return new GLWindow(window);
a959c53b
KR
126 }
127
63be4a40
SG
128 public boolean isNativeValid() {
129 return (null!=window)?window.isNativeValid():false;
811bd23e
SG
130 }
131
63be4a40
SG
132 public boolean isValid() {
133 return (null!=window)?window.isValid():true;
6e599a26
SG
134 }
135
d94115b3 136 public final Window getInnerWindow() {
811bd23e 137 return window.getInnerWindow();
6e599a26
SG
138 }
139
d94115b3
SG
140 public final Object getWrappedWindow() {
141 return window.getWrappedWindow();
142 }
143
6e599a26 144 protected void createNativeImpl() {
a959c53b
KR
145 shouldNotCallThis();
146 }
147
63be4a40 148 protected void closeNativeImpl() {
a959c53b
KR
149 shouldNotCallThis();
150 }
151
1d333a77
SG
152 class DisposeAction implements Runnable {
153 public void run() {
154 // Lock: Covered by DestroyAction ..
155 helper.dispose(GLWindow.this);
a959c53b
KR
156 }
157 }
1d333a77 158 private DisposeAction disposeAction = new DisposeAction();
a959c53b 159
811bd23e 160 class DestroyAction implements Runnable {
63be4a40
SG
161 boolean unrecoverable;
162 public DestroyAction(boolean unrecoverable) {
163 this.unrecoverable = unrecoverable;
811bd23e
SG
164 }
165 public void run() {
1d333a77 166 // Lock: Have to cover whole workflow (dispose all, context, drawable and window)
811bd23e
SG
167 windowLock();
168 try {
63be4a40 169 if( !isValid() ) {
811bd23e
SG
170 return; // nop
171 }
1d333a77 172 if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
63be4a40 173 Exception e1 = new Exception("GLWindow.destroy("+unrecoverable+") "+Thread.currentThread()+", start: "+GLWindow.this);
1d333a77
SG
174 e1.printStackTrace();
175 }
176
63be4a40 177 if( window.isNativeValid() && null != drawable && drawable.isRealized() ) {
969e4276
SG
178 if( null != context && context.isCreated() ) {
179 // Catch dispose GLExceptions by GLEventListener, just 'print' them
180 // so we can continue with the destruction.
181 try {
182 helper.invokeGL(drawable, context, disposeAction, null);
183 } catch (GLException gle) {
184 gle.printStackTrace();
185 }
186
187 context.destroy();
188 context = null;
1d333a77 189 }
1d333a77 190
1d333a77
SG
191 drawable.setRealized(false);
192 drawable = null;
193 }
a92906bc 194
811bd23e 195 if(null!=window) {
63be4a40 196 window.destroy(unrecoverable);
811bd23e 197 }
a959c53b 198
63be4a40 199 if(unrecoverable) {
811bd23e
SG
200 helper=null;
201 }
1d333a77 202 if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
63be4a40 203 System.out.println("GLWindow.destroy("+unrecoverable+") "+Thread.currentThread()+", fin: "+GLWindow.this);
1d333a77 204 }
811bd23e
SG
205 } finally {
206 windowUnlock();
a959c53b 207 }
a959c53b 208 }
811bd23e 209 }
a959c53b 210
63be4a40
SG
211 public void destroy(boolean unrecoverable) {
212 if( isValid() ) {
213 runOnEDTIfAvail(true, new DestroyAction(unrecoverable));
811bd23e 214 }
a959c53b
KR
215 }
216
217 public boolean getPerfLogEnabled() { return perfLog; }
218
219 public void enablePerfLog(boolean v) {
220 perfLog = v;
221 }
222
811bd23e 223 protected void setVisibleImpl(boolean visible) {
6e599a26
SG
224 shouldNotCallThis();
225 }
226
1ceebc12
SG
227 public void reparentWindow(NativeWindow newParent) {
228 window.reparentWindow(newParent);
811bd23e
SG
229 }
230
231 class VisibleAction implements Runnable {
232 boolean visible;
233 public VisibleAction(boolean visible) {
234 this.visible = visible;
235 }
236 public void run() {
1d333a77 237 // Lock: Have to cover whole workflow (window, may do nativeCreation, drawable and context)
811bd23e
SG
238 windowLock();
239 try{
240 window.setVisible(visible);
241 if (null == context && visible && 0 != window.getWindowHandle() && 0<getWidth()*getHeight()) {
242 NativeWindow nw;
d94115b3
SG
243 if (getWrappedWindow() != null) {
244 nw = NativeWindowFactory.getNativeWindow(getWrappedWindow(), window.getGraphicsConfiguration());
811bd23e
SG
245 } else {
246 nw = window;
247 }
248 GLCapabilities glCaps = (GLCapabilities) nw.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
249 if(null==factory) {
250 factory = GLDrawableFactory.getFactory(glCaps.getGLProfile());
251 }
252 if(null==drawable) {
253 drawable = factory.createGLDrawable(nw);
254 }
255 drawable.setRealized(true);
256 context = drawable.createContext(null);
257 sendReshape = true; // ensure a reshape event is send ..
258 }
259 } finally {
260 windowUnlock();
a959c53b 261 }
a959c53b
KR
262 }
263 }
264
811bd23e 265 public void setVisible(boolean visible) {
63be4a40 266 if(isValid()) {
811bd23e
SG
267 runOnEDTIfAvail(true, new VisibleAction(visible));
268 }
269 }
270
271 public Capabilities getRequestedCapabilities() {
272 return window.getRequestedCapabilities();
273 }
274
275 public NativeWindow getParentNativeWindow() {
276 return window.getParentNativeWindow();
277 }
278
a959c53b
KR
279 public Screen getScreen() {
280 return window.getScreen();
281 }
282
283 public void setTitle(String title) {
284 window.setTitle(title);
285 }
286
287 public String getTitle() {
288 return window.getTitle();
289 }
290
291 public void setUndecorated(boolean value) {
292 window.setUndecorated(value);
293 }
294
295 public boolean isUndecorated() {
296 return window.isUndecorated();
297 }
298
ccc30b05
SG
299 public void requestFocus() {
300 window.requestFocus();
301 }
a4b16ad5
SG
302 public void setFocusAction(FocusRunnable focusAction) {
303 window.setFocusAction(focusAction);
304 }
ccc30b05 305
811bd23e
SG
306 public Insets getInsets() {
307 return window.getInsets();
308 }
309
a959c53b
KR
310 public void setSize(int width, int height) {
311 window.setSize(width, height);
312 }
811bd23e
SG
313 protected void setSizeImpl(int width, int height) {
314 shouldNotCallThis();
315 }
a959c53b
KR
316
317 public void setPosition(int x, int y) {
318 window.setPosition(x, y);
319 }
811bd23e
SG
320 protected void setPositionImpl(int x, int y) {
321 shouldNotCallThis();
7bed517f 322 }
323
a959c53b
KR
324 public boolean setFullscreen(boolean fullscreen) {
325 return window.setFullscreen(fullscreen);
326 }
a4b16ad5 327 protected void setFullscreenImpl(boolean fullscreen, int x, int y, int w, int h) {
811bd23e 328 shouldNotCallThis();
811bd23e 329 }
a959c53b
KR
330
331 public boolean isVisible() {
332 return window.isVisible();
333 }
334
335 public int getX() {
336 return window.getX();
337 }
338
339 public int getY() {
340 return window.getY();
341 }
342
343 public int getWidth() {
344 return window.getWidth();
345 }
346
347 public int getHeight() {
348 return window.getHeight();
349 }
350
351 public boolean isFullscreen() {
352 return window.isFullscreen();
353 }
354
969e4276
SG
355 public void enqueueEvent(boolean wait, com.jogamp.newt.event.NEWTEvent event) {
356 window.enqueueEvent(wait, event);
357 }
358 public boolean consumeEvent(NEWTEvent e) {
359 return window.consumeEvent(e);
360 }
361
302f183c
SG
362 public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) {
363 window.addSurfaceUpdatedListener(index, l);
bf584fba
SG
364 }
365 public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
366 window.removeSurfaceUpdatedListener(l);
367 }
e8f4dc96
SG
368 public void removeAllSurfaceUpdatedListener() {
369 window.removeAllSurfaceUpdatedListener();
370 }
302f183c
SG
371 public SurfaceUpdatedListener getSurfaceUpdatedListener(int index) {
372 return window.getSurfaceUpdatedListener(index);
373 }
374 public SurfaceUpdatedListener[] getSurfaceUpdatedListeners() {
375 return window.getSurfaceUpdatedListeners();
bf584fba
SG
376 }
377 public void surfaceUpdated(Object updater, NativeWindow window0, long when) {
378 window.surfaceUpdated(updater, window, when);
379 }
380
302f183c
SG
381 public void addMouseListener(int index, MouseListener l) {
382 window.addMouseListener(index, l);
a959c53b 383 }
a959c53b
KR
384 public void removeMouseListener(MouseListener l) {
385 window.removeMouseListener(l);
386 }
302f183c
SG
387 public MouseListener getMouseListener(int index) {
388 return window.getMouseListener(index);
389 }
a959c53b
KR
390 public MouseListener[] getMouseListeners() {
391 return window.getMouseListeners();
392 }
393
302f183c
SG
394 public void addKeyListener(int index, KeyListener l) {
395 window.addKeyListener(index, l);
a959c53b 396 }
a959c53b
KR
397 public void removeKeyListener(KeyListener l) {
398 window.removeKeyListener(l);
399 }
302f183c
SG
400 public KeyListener getKeyListener(int index) {
401 return window.getKeyListener(index);
402 }
a959c53b
KR
403 public KeyListener[] getKeyListeners() {
404 return window.getKeyListeners();
405 }
406
969e4276
SG
407 public void sendWindowEvent(int eventType) {
408 window.sendWindowEvent(eventType);
409 }
410 public void enqueueWindowEvent(boolean wait, int eventType) {
411 window.enqueueWindowEvent(wait, eventType);
412 }
302f183c
SG
413 public void addWindowListener(int index, WindowListener l) {
414 window.addWindowListener(index, l);
a959c53b 415 }
a959c53b
KR
416 public void removeWindowListener(WindowListener l) {
417 window.removeWindowListener(l);
418 }
302f183c
SG
419 public WindowListener getWindowListener(int index) {
420 return window.getWindowListener(index);
421 }
a959c53b
KR
422 public WindowListener[] getWindowListeners() {
423 return window.getWindowListeners();
424 }
969e4276
SG
425 public void setPropagateRepaint(boolean v) {
426 window.setPropagateRepaint(v);
427 }
428 public void windowRepaint(int x, int y, int width, int height) {
429 window.windowRepaint(x, y, width, height);
430 }
a959c53b
KR
431
432 public String toString() {
1c1053c6 433 return "NEWT-GLWindow[ \n\tHelper: "+helper+", \n\tDrawable: "+drawable + /** ", \n\tWindow: "+window+", \n\tFactory: "+factory+ */ "]";
a959c53b
KR
434 }
435
436 //----------------------------------------------------------------------
437 // OpenGL-related methods and state
438 //
439
a959c53b
KR
440 private GLDrawableFactory factory;
441 private GLDrawable drawable;
442 private GLContext context;
443 private GLDrawableHelper helper = new GLDrawableHelper();
444 // To make reshape events be sent immediately before a display event
445 private boolean sendReshape=false;
446 private boolean sendDestroy=false;
447 private boolean perfLog = false;
448
449 public GLDrawableFactory getFactory() {
450 return factory;
451 }
452
453 public void setContext(GLContext newCtx) {
454 context = newCtx;
455 }
456
457 public GLContext getContext() {
458 return context;
459 }
460
461 public GL getGL() {
462 if (context == null) {
463 return null;
464 }
465 return context.getGL();
466 }
467
4e0a5af0 468 public GL setGL(GL gl) {
a959c53b
KR
469 if (context != null) {
470 context.setGL(gl);
4e0a5af0 471 return gl;
a959c53b 472 }
4e0a5af0 473 return null;
a959c53b
KR
474 }
475
476 public void addGLEventListener(GLEventListener listener) {
477 helper.addGLEventListener(listener);
478 }
479
302f183c
SG
480 public void addGLEventListener(int index, GLEventListener listener) {
481 helper.addGLEventListener(index, listener);
482 }
483
a959c53b
KR
484 public void removeGLEventListener(GLEventListener listener) {
485 helper.removeGLEventListener(listener);
486 }
487
969e4276
SG
488 public void setAnimator(Thread animator) {
489 helper.setAnimator(animator);
490 window.setPropagateRepaint(null==animator);
491 }
492
493 public Thread getAnimator() {
494 return helper.getAnimator();
495 }
496
0d24458c 497 public void invoke(boolean wait, GLRunnable glRunnable) {
969e4276 498 helper.invoke(this, wait, glRunnable);
0d24458c
SG
499 }
500
a959c53b 501 public void display() {
cf4c4037
SG
502 display(false);
503 }
504
505 public void display(boolean forceReshape) {
6e599a26
SG
506 if( null == window ) { return; }
507
969e4276 508 if(sendDestroy || ( null!=window && window.hasDeviceChanged() && GLAutoDrawable.SCREEN_CHANGE_ACTION_ENABLED ) ) {
63be4a40
SG
509 sendDestroy=false;
510 destroy();
511 return;
512 }
969e4276 513
6e599a26
SG
514 if( null == context && window.isVisible() ) {
515 // retry native window and drawable/context creation
516 setVisible(true);
517 }
518
63be4a40 519 if( window.isVisible() && window.isNativeValid() && null != context ) {
969e4276
SG
520 if(forceReshape) {
521 sendReshape = true;
a92906bc 522 }
969e4276
SG
523 windowLock();
524 try{
525 helper.invokeGL(drawable, context, displayAction, initAction);
526 } finally {
527 windowUnlock();
a959c53b
KR
528 }
529 }
530 }
531
a92906bc 532 /** This implementation uses a static value */
a959c53b 533 public void setAutoSwapBufferMode(boolean onOrOff) {
2268a6ce 534 helper.setAutoSwapBufferMode(onOrOff);
a959c53b
KR
535 }
536
a92906bc 537 /** This implementation uses a static value */
a959c53b 538 public boolean getAutoSwapBufferMode() {
2268a6ce 539 return helper.getAutoSwapBufferMode();
a959c53b
KR
540 }
541
542 public void swapBuffers() {
2268a6ce 543 if(drawable!=null && context != null) {
1d333a77 544 // Lock: Locked Surface/Window by MakeCurrent/Release
2268a6ce 545 if (context != GLContext.getCurrent()) {
a959c53b
KR
546 // Assume we should try to make the context current before swapping the buffers
547 helper.invokeGL(drawable, context, swapBuffersAction, initAction);
548 } else {
549 drawable.swapBuffers();
550 }
551 }
552 }
553
554 class InitAction implements Runnable {
555 public void run() {
1d333a77 556 // Lock: Locked Surface/Window by MakeCurrent/Release
a959c53b 557 helper.init(GLWindow.this);
969e4276 558 startTime = System.currentTimeMillis(); // overwrite startTime to real init one
a959c53b
KR
559 curTime = startTime;
560 if(perfLog) {
561 lastCheck = startTime;
562 totalFrames = 0; lastFrames = 0;
563 }
564 }
565 }
566 private InitAction initAction = new InitAction();
567
a959c53b
KR
568 class DisplayAction implements Runnable {
569 public void run() {
1d333a77 570 // Lock: Locked Surface/Window by display _and_ MakeCurrent/Release
a959c53b 571 if (sendReshape) {
969e4276 572 helper.reshape(GLWindow.this, 0, 0, getWidth(), getHeight());
a959c53b
KR
573 sendReshape = false;
574 }
575
576 helper.display(GLWindow.this);
577
578 curTime = System.currentTimeMillis();
579 totalFrames++;
580
581 if(perfLog) {
582 long dt0, dt1;
583 lastFrames++;
584 dt0 = curTime-lastCheck;
585 if ( dt0 > 5000 ) {
586 dt1 = curTime-startTime;
587 System.out.println(dt0/1000 +"s: "+ lastFrames + "f, " + (lastFrames*1000)/dt0 + " fps, "+dt0/lastFrames+" ms/f; "+
588 "total: "+ dt1/1000+"s, "+(totalFrames*1000)/dt1 + " fps, "+dt1/totalFrames+" ms/f");
589 lastCheck=curTime;
590 lastFrames=0;
591 }
592 }
593 }
594 }
a92906bc 595 private DisplayAction displayAction = new DisplayAction();
a959c53b
KR
596
597 public long getStartTime() { return startTime; }
969e4276
SG
598 public long getCurrentTime() { curTime = System.currentTimeMillis(); return curTime; }
599 public long getDuration() { return getCurrentTime()-startTime; }
a959c53b
KR
600 public int getTotalFrames() { return totalFrames; }
601
602 private long startTime = 0;
603 private long curTime = 0;
604 private long lastCheck = 0;
605 private int totalFrames = 0, lastFrames = 0;
a959c53b 606
a959c53b
KR
607 class SwapBuffersAction implements Runnable {
608 public void run() {
609 drawable.swapBuffers();
610 }
611 }
a959c53b
KR
612 private SwapBuffersAction swapBuffersAction = new SwapBuffersAction();
613
614 //----------------------------------------------------------------------
6e599a26 615 // NativeWindow/Window methods
a959c53b
KR
616 //
617
811bd23e 618 public int lockSurface() throws NativeWindowException {
a959c53b 619 if(null!=drawable) return drawable.getNativeWindow().lockSurface();
811bd23e 620 return window.lockSurface();
a959c53b
KR
621 }
622
811bd23e 623 public void unlockSurface() {
a959c53b 624 if(null!=drawable) drawable.getNativeWindow().unlockSurface();
811bd23e 625 else window.unlockSurface();
a959c53b
KR
626 }
627
811bd23e 628 public boolean isSurfaceLocked() {
a959c53b 629 if(null!=drawable) return drawable.getNativeWindow().isSurfaceLocked();
811bd23e 630 return window.isSurfaceLocked();
a959c53b
KR
631 }
632
811bd23e 633 public Exception getLockedStack() {
a959c53b 634 if(null!=drawable) return drawable.getNativeWindow().getLockedStack();
811bd23e 635 return window.getLockedStack();
a959c53b
KR
636 }
637
8883fa88 638 public boolean surfaceSwap() {
639 if(null!=drawable) return drawable.getNativeWindow().surfaceSwap();
640 return super.surfaceSwap();
641 }
642
a959c53b
KR
643 public long getWindowHandle() {
644 if(null!=drawable) return drawable.getNativeWindow().getWindowHandle();
6e599a26 645 return window.getWindowHandle();
a959c53b
KR
646 }
647
648 public long getSurfaceHandle() {
649 if(null!=drawable) return drawable.getNativeWindow().getSurfaceHandle();
6e599a26
SG
650 return window.getSurfaceHandle();
651 }
652
653 public AbstractGraphicsConfiguration getGraphicsConfiguration() {
654 if(null!=drawable) return drawable.getNativeWindow().getGraphicsConfiguration();
655 return window.getGraphicsConfiguration();
656 }
657
658 //----------------------------------------------------------------------
659 // GLDrawable methods
660 //
661
662 public NativeWindow getNativeWindow() {
663 return null!=drawable ? drawable.getNativeWindow() : null;
a959c53b
KR
664 }
665
1d333a77
SG
666 public long getHandle() {
667 return null!=drawable ? drawable.getHandle() : 0;
668 }
669
a959c53b
KR
670 //----------------------------------------------------------------------
671 // GLDrawable methods that are not really needed
672 //
673
674 public GLContext createContext(GLContext shareWith) {
675 return drawable.createContext(shareWith);
676 }
677
678 public void setRealized(boolean realized) {
679 }
680
811bd23e
SG
681 public boolean isRealized() {
682 return ( null != drawable ) ? drawable.isRealized() : false;
683 }
684
a959c53b
KR
685 public GLCapabilities getChosenGLCapabilities() {
686 if (drawable == null) {
687 throw new GLException("No drawable yet");
688 }
689
690 return drawable.getChosenGLCapabilities();
691 }
692
693 public GLProfile getGLProfile() {
694 if (drawable == null) {
695 throw new GLException("No drawable yet");
696 }
697
698 return drawable.getGLProfile();
699 }
a959c53b 700}
http://JogAmp.org git info: FAQ, tutorial and man pages.