1313import com .jogamp .newt .event .MouseListener ;
1414import com .jogamp .newt .event .WindowAdapter ;
1515import com .jogamp .newt .opengl .GLWindow ;
16- import com .jogamp .opengl .GL ;
1716import com .jogamp .opengl .DefaultGLCapabilitiesChooser ;
17+ import com .jogamp .opengl .GL ;
1818import com .jogamp .opengl .GLAutoDrawable ;
1919import com .jogamp .opengl .GLCapabilities ;
2020import com .jogamp .opengl .GLCapabilitiesChooser ;
@@ -39,6 +39,7 @@ public class ClearGLWindow implements ClearGLDisplayable
3939
4040 private FPSAnimator mAnimator ;
4141 private int mFramesPerSecond = 60 ;
42+ private ClearGLEventListener mClearGLWindowEventListener ;
4243
4344 static
4445 {
@@ -131,6 +132,7 @@ public ClearGLWindow( String pWindowTitle,
131132 mWindowTitle = pWindowTitle ;
132133 mWindowDefaultWidth = pDefaultWidth ;
133134 mWindowDefaultHeight = pDefaultHeight ;
135+ mClearGLWindowEventListener = pClearGLWindowEventListener ;
134136
135137 mProjectionMatrix = new GLMatrix ();
136138 mViewMatrix = new GLMatrix ();
@@ -150,8 +152,8 @@ public ClearGLWindow( String pWindowTitle,
150152 mGlWindow .setCapabilitiesChooser (lMultisampleChooser );
151153 mGlWindow .setTitle (pWindowTitle );
152154
153- pClearGLWindowEventListener .setClearGLWindow (this );
154- mGlWindow .addGLEventListener (pClearGLWindowEventListener );
155+ mClearGLWindowEventListener .setClearGLWindow (this );
156+ mGlWindow .addGLEventListener (mClearGLWindowEventListener );
155157 mGlWindow .setSize (pDefaultWidth , pDefaultHeight );
156158 mGlWindow .setAutoSwapBufferMode (true );
157159
@@ -192,6 +194,7 @@ public void close() throws GLException
192194 try
193195 {
194196 mGlWindow .setVisible (false );
197+ mGlWindow .removeGLEventListener (mClearGLWindowEventListener );
195198 }
196199 catch (final Throwable e )
197200 {
@@ -277,12 +280,12 @@ public void setOrthoProjectionMatrix( final float left,
277280 final float zFar )
278281 {
279282 if (mProjectionMatrix != null )
280- mProjectionMatrix .setOrthoProjectionMatrix (left ,
281- right ,
282- bottom ,
283- top ,
284- zNear ,
285- zFar );
283+ mProjectionMatrix .setOrthoProjectionMatrix ( left ,
284+ right ,
285+ bottom ,
286+ top ,
287+ zNear ,
288+ zFar );
286289 }
287290
288291 /* (non-Javadoc)
@@ -386,17 +389,24 @@ public void display()
386389 mGlWindow .display ();
387390 }
388391
389- public static boolean isRetina (GL pGL ) {
392+ public static boolean isRetina (GL pGL )
393+ {
390394 int [] trialSizes = new int [2 ];
391395
392396 trialSizes [0 ] = 512 ;
393397 trialSizes [1 ] = 512 ;
394398
395- pGL .getContext ().getGLDrawable ().getNativeSurface ().convertToPixelUnits (trialSizes );
399+ pGL .getContext ()
400+ .getGLDrawable ()
401+ .getNativeSurface ()
402+ .convertToPixelUnits (trialSizes );
396403
397- if (trialSizes [0 ] == 512 && trialSizes [1 ] == 512 ) {
404+ if (trialSizes [0 ] == 512 && trialSizes [1 ] == 512 )
405+ {
398406 return false ;
399- } else {
407+ }
408+ else
409+ {
400410 return true ;
401411 }
402412 }
@@ -417,7 +427,7 @@ public WindowClosingMode setDefaultCloseOperation(WindowClosingMode pWindowClosi
417427 public int getHeight ()
418428 {
419429 int factor = isRetina (this .mGlWindow .getGL ()) ? 2 : 1 ;
420- return mGlWindow .getHeight ()* factor ;
430+ return mGlWindow .getHeight () * factor ;
421431 }
422432
423433 /* (non-Javadoc)
@@ -427,7 +437,7 @@ public int getHeight()
427437 public int getWidth ()
428438 {
429439 int factor = isRetina (this .mGlWindow .getGL ()) ? 2 : 1 ;
430- return mGlWindow .getWidth ()* factor ;
440+ return mGlWindow .getWidth () * factor ;
431441 }
432442
433443 @ Override
0 commit comments