From cc63a4689c3a6456fb616341c19eb4f0d0ab722a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 19 Nov 2011 19:32:27 +0100 Subject: Demo: GearsES1/ES2 visualize focus --- .../jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java | 15 +++++++++++++-- .../jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java | 4 +++- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src/test') diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java index 8d579ce5d..b5a729e02 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java @@ -21,6 +21,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.es1; +import javax.media.nativewindow.NativeWindow; import javax.media.opengl.GL; import javax.media.opengl.GL2ES1; import javax.media.opengl.GLAutoDrawable; @@ -181,8 +182,18 @@ public class GearsES1 implements GLEventListener { // Get the GL corresponding to the drawable we are animating GL2ES1 gl = drawable.getGL().getGL2ES1(); - gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - + final boolean hasFocus; + if(drawable.getNativeSurface() instanceof NativeWindow) { + hasFocus = ((NativeWindow)drawable.getNativeSurface()).hasFocus(); + } else { + hasFocus = true; + } + if(hasFocus) { + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + } else { + gl.glClearColor(0.2f, 0.2f, 0.2f, 0.0f); + } + // Special handling for the case where the GLJPanel is translucent // and wants to be composited with other Java 2D content if (GLProfile.isAWTAvailable() && diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 63bbab66e..51bc7d137 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -246,9 +246,11 @@ public class GearsES2 implements GLEventListener { // Get the GL corresponding to the drawable we are animating GL2ES2 gl = drawable.getGL().getGL2ES2(); - boolean hasFocus = false; + final boolean hasFocus; if(drawable.getNativeSurface() instanceof NativeWindow) { hasFocus = ((NativeWindow)drawable.getNativeSurface()).hasFocus(); + } else { + hasFocus = true; } if(hasFocus) { gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); -- cgit v1.2.3