Bug 274

Summary: GLException when GLJPanel (initially not visible) is made visible/showing
Product: [JogAmp] Jogl Reporter: Sven Gothel <sgothel>
Component: coreAssignee: Sven Gothel <sgothel>
Status: VERIFIED FIXED    
Severity: normal    
Priority: P3    
Version: 1   
Hardware: All   
OS: windows   
Type: DEFECT SCM Refs:
Workaround: ---

Description Sven Gothel 2010-03-24 07:50:03 CET


---- Reported by dmgaskin 2007-02-21 02:58:40 ----

The following code demonstrates the problem

package de.gaskin.jogl.bugs;

import javax.media.opengl.GLJPanel;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.JLabel;

class DMGJOGLhttps://jogl.dev.java.net/bugs/show_bug.cgi?id=1 extends JFrame {
   DMGJOGLhttps://jogl.dev.java.net/bugs/show_bug.cgi?id=1(boolean produceBug) {
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      JTabbedPane tp     = new JTabbedPane();
      GLJPanel    threeD = new GLJPanel();
      JLabel      label  = new JLabel("Now select the '3D' tab");
      tp.setPreferredSize(new java.awt.Dimension(400, 400));
      if (produceBug) {
         tp.add("2D", label);
         tp.add("3D", threeD);
      }
      else {
         tp.add("3D", threeD);
         tp.add("2D", label);
      }
      add(tp);
      pack();
      setVisible(true);
   }
   public static void main(String[] args) {
      boolean produceBug = true;
      if (args.length > 0)
         produceBug = false;
      new DMGJOGLhttps://jogl.dev.java.net/bugs/show_bug.cgi?id=1(produceBug);
   }
}



---- Additional Comments From kbr 2007-02-21 07:51:30 ----

I don't see any exception on my machine with NVidia graphics. What OS, graphics
card, and JDK version are you using? Did you properly specify
-Dsun.java2d.noddraw=true? Are you running the latest drivers from your vendor?
What is the stack trace of the exception thrown?




---- Additional Comments From dmgaskin 2007-02-21 10:17:16 ----

As you had no problems running my code I experimented a bit more with options
and properties.

The problem ONLY Occurs when invoked with "-Dsun.java2d.opengl=true"

The details follow.




Invoked:
========
java -Dsun.awt.noerasebackground=true -Dsun.java2d.noddraw=true
-Dsun.java2d.opengl=true de.gaskin.jogl.bugs.DMGJOGLhttps://jogl.dev.java.net/bugs/show_bug.cgi?id=1


OS:
==
  Microsoft Windows XP [Version 5.1.2600]

JDK:
====
java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b104)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b104, mixed mode, sharing)

Graphics:
=========

INIT GL IS: com.sun.opengl.impl.GLImpl
Chosen GLCapabilities: GLCapabilities [DoubleBuffered: true, Stereo: false, Hard
wareAccelerated: true, DepthBits: 24, StencilBits: 0, Red: 8, Green: 8, Blue: 8,
 Alpha: 0, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0, 
 Multisample: false ]
GL_VENDOR: NVIDIA Corporation
GL_RENDERER: GeForce 6150 LE/PCI/SSE2/3DNOW!
GL_VERSION: 2.0.1

Exception Stack trace is:
=========================

exception in QueueFlusher:
javax.media.opengl.GLException: Unable to create OpenGL context for device
context 0x4f01139d
        at
com.sun.opengl.impl.windows.WindowsGLContext.create(WindowsGLContext.java:122)
        at
com.sun.opengl.impl.windows.WindowsGLContext.makeCurrentImpl(WindowsGLContext.java:150)
        at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:134)
        at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:182)
        at javax.media.opengl.GLJPanel$1.run(GLJPanel.java:596)
        at
sun.java2d.opengl.OGLRenderQueue$QueueFlusher.run(OGLRenderQueue.java:203)

JOGL Version is:
================
  jogl-1.1.0-rc3-windows-i586

Please let me know if you need more information.

Regards
   Dave




---- Additional Comments From kbr 2007-02-27 14:10:36 ----

This appears to be a driver-related bug. We are unlikely to have the resources
to investigate it further in the near future. A workaround is to specify
-Dsun.java2d.opengl.fbobject=false along with -Dsun.java2d.opengl=true . You
should probably report this bug to NVidia.




---- Additional Comments From kbr 2007-02-27 14:21:32 ----

Downgrading to normal priority.




---- Additional Comments From kbr 2007-03-21 13:44:05 ----

Copying in comments from user chrisnf from Issue 289, which is a duplicate of
this one:

This bug was already reported as 274 but I'm not sure how to add a comment.  I
could just vote, but I want to mention new info.  It also happens with me when I
put a GLJPanel on a JTabbedPane.  When the tab is shown, it's ok.  When it is
hidden then shown again, I get the exception:

exception in QueueFlusher:
javax.media.opengl.GLException: Unable to create OpenGL context for device
context 0x74012321
...

As advised in 274, with -Dsun.opengl.fbobject=false it seems not to happen.  

However, I'm using an ATI Radeon X550 with the latest JOGL and ATI drivers, not
NVIDIA.  It seems this fbobject problem is common to both.

Chris




---- Additional Comments From kbr 2007-03-21 13:45:05 ----

*** Issue 289 has been marked as a duplicate of this issue. ***



---- Additional Comments From kbr 2007-03-21 13:58:38 ----

Added chrisnf to CC: list



---- Additional Comments From kbr 2007-03-21 14:07:00 ----

Investigation revealed that the symptom was similar to what happens
when one tries to create a new OpenGL context against an invalid HDC
on Windows. Discussion with Chris Campbell from the Java 2D team
indicated that in situations where the Java 2D OpenGL pipeline is
using Frame Buffer Objects for its rendering, it is possible that its
internal OpenGL context can be left current to the on-screen drawable,
and it only has a valid device context for the brief period of time
when its OpenGL context was being made current. This means that by the
time JOGL's code got a chance to run, it did not have a valid HDC and
therefore could not create its OpenGL context against it. The
workaround, suggested by Chris, is to forcibly make the Java 2D
context current against its internal "scratch" pbuffer, which can be
done with the internal invokeWithOGLSharedContextCurrent method. Added
this workaround and verified it fixes the problem with the user's test
case. This issue will be fixed in a forthcoming Java SE 6 update
release, hopefully 6u2.

The fix for this bug will be present in nightly builds dated 3/22 and later.




--- Bug imported by sgothel@jausoft.com 2010-03-24 07:50 EDT  ---

This bug was previously known as _bug_ 274 at https://jogl.dev.java.net/bugs/show_bug.cgi?id=274

Unknown bug field "has_duplicates" encountered while moving bug
   <has_duplicates>
     <bug_id>289</bug_id>
     <who>kbr</who>
     <when>2007-03-21 13:45:06</when>
</has_duplicates>
CC member chrisnf does not have an account here