From bee7e4acd087a2de8369c47149c9b2c35e9f3a68 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Thu, 30 Jun 2005 19:30:24 +0000 Subject: Fixed Issue 168: Add support for transparency in GLJPanel Obey setOpaque() when selecting buffered image type. User must still request alpha bits in the GLCapabilities. Not supported on all back-end renderers; for example, Microsoft GDI renderer does not implement alpha bits when rendering to DIB sections. Added examples of use in JGears and JRefract demos. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@314 232f8b59-042b-4e1e-8c03-345bb8c30851 --- src/net/java/games/jogl/GLJPanel.java | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/net/java/games/jogl/GLJPanel.java') diff --git a/src/net/java/games/jogl/GLJPanel.java b/src/net/java/games/jogl/GLJPanel.java index 59b2ee86d..e9b58bdae 100644 --- a/src/net/java/games/jogl/GLJPanel.java +++ b/src/net/java/games/jogl/GLJPanel.java @@ -310,6 +310,16 @@ public final class GLJPanel extends JPanel implements GLDrawable { } } + public void setOpaque(boolean opaque) { + if (opaque != isOpaque()) { + if (offscreenImage != null) { + offscreenImage.flush(); + offscreenImage = null; + } + } + super.setOpaque(opaque); + } + public void addGLEventListener(GLEventListener listener) { drawableHelper.addGLEventListener(listener); } @@ -546,15 +556,17 @@ public final class GLJPanel extends JPanel implements GLDrawable { int awtFormat = 0; int hwGLFormat = 0; if (!hardwareAccelerationDisabled) { - // Should be more flexible in these BufferedImage formats; - // perhaps see what the preferred image types are on the - // given platform - awtFormat = BufferedImage.TYPE_INT_RGB; - // This seems to be a good choice on all platforms hwGLFormat = GL.GL_UNSIGNED_INT_8_8_8_8_REV; + } + + // Should be more flexible in these BufferedImage formats; + // perhaps see what the preferred image types are on the + // given platform + if (isOpaque()) { + awtFormat = BufferedImage.TYPE_INT_RGB; } else { - awtFormat = offscreenContext.getOffscreenContextBufferedImageType(); + awtFormat = BufferedImage.TYPE_INT_ARGB; } offscreenImage = new BufferedImage(panelWidth, -- cgit v1.2.3