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