JOGL/Java2D/GLJPanel problems

Hi Ken,

I would like to report a bug which is related to the OGL pipeline, but before I go into details let me tell you what I have done:

  • First, I have ported my application to Jogl 1.0.0-beta4 without any major problem;
  • My application is compatible with the java 1.5 and I have tested it on Java version 1.5 (Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)) and on Mustang (1.6.0-beta2-b81 and 1.6.0-beta2-b83) - it works correctly on all these Java versions;
  • I have also installed special RepaintManager to be absolutely sure that all painting in my application is done on EDT (see http://weblogs.java.net/blog/alexfromsun/);
  • I have also taken care that the latest NVidia driver version 84.21 is installed on my Windows computer (GPU: NVidia GeForceFX 5700LE) ;
  • All tests have been done on Windows XP SP2.

So, I can say that my application works correctly without any problems (log [1]) . Problems occur when I try to enable JOGL/Java2D integration (OGL pipeline) with an option (-sun.java2d.opengl=True). I can definitely see that the rendering is completely wrong - “inedible” (please see log [2]). If the RepaintManager is not installed I can see that there are less problems(log [3]). In both cases (2 and 3) the upper part of GLJPanel object is “cut off” - my object is translated to the bottom.

I would like to send you a few pictures of my application (one picture is worth more than a thousands words) so that you could see how it works and I would you like to send you those pictures in private. If you are interested in would that be possible? If yes, please, tell me where should I send them. Should I send any other infromation?

Kind regards and many thanks for your help,
Andrei

[1.] Here is part of the log with OGL pipeline disabled, RepaintManager installed, application works correctly:
Options: -Djogl.verbose -Djogl.debug.Java2D -Djogl.debug.GLJPanel
Installed repaint manager java version "1.6.0-beta2" Java(TM) SE Runtime Environment (build 1.6.0-beta2-b83) Java HotSpot(TM) Client VM (build 1.6.0-beta2-b83, mixed mode, sharing) JOGL specification version 1.0.0 JOGL implementation version 1.0.0-beta4 JOGL implementation vendor Sun Microsystems, Inc. OGLUtilities.UNDEFINED = 0 OGLUtilities.WINDOW = 1 OGLUtilities.PBUFFER = 2 OGLUtilities.TEXTURE = 3 OGLUtilities.FLIP_BACKBUFFER = 4 OGLUtilities.FBOBJECT = 5 Checking for Java2D/OpenGL support Java2D support: default GraphicsConfiguration = sun.awt.Win32GraphicsConfig JOGL/Java2D integration disabled GLJPanel.addNotify() Using AWT thread for performing OpenGL work in javax.media.opengl implementation GLJPanel.handleReshape: (w,h) = (624,419) Resizing pbuffer from (256, 256) to fit (624, 419) New pbuffer size is (1024, 512) glViewport(0, 0, 624, 419) GLJPanel.removeNotify() GLJPanel.addNotify() repaint GLJPanel.handleReshape: (w,h) = (624,419) glViewport(0, 0, 624, 419) GLJPanel.removeNotify() GLJPanel.addNotify() repaint GLJPanel.handleReshape: (w,h) = (624,419) glViewport(0, 0, 624, 419) GLJPanel.handleReshape: (w,h) = (736,545) Resizing pbuffer from (1024, 512) to fit (736, 545) New pbuffer size is (1024, 1024) glViewport(0, 0, 736, 545) GLJPanel.handleReshape: (w,h) = (1000,632) glViewport(0, 0, 1000, 632) GLJPanel.handleReshape: (w,h) = (736,545) glViewport(0, 0, 736, 545) GLJPanel.removeNotify()

[2.] Here is part of the log with OGL pipeline enabled, RepaintManager installed, rendering is not correct, upper part of GLJPanel is “cut off” :
Options: -Djogl.verbose -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Dsun.java2d.opengl=True
Installed repaint manager OpenGL pipeline enabled for default config on screen 0 java version "1.6.0-beta2" Java(TM) SE Runtime Environment (build 1.6.0-beta2-b83) Java HotSpot(TM) Client VM (build 1.6.0-beta2-b83, mixed mode, sharing) JOGL specification version 1.0.0 JOGL implementation version 1.0.0-beta4 JOGL implementation vendor Sun Microsystems, Inc. OGLUtilities.UNDEFINED = 0 OGLUtilities.WINDOW = 1 OGLUtilities.PBUFFER = 2 OGLUtilities.TEXTURE = 3 OGLUtilities.FLIP_BACKBUFFER = 4 OGLUtilities.FBOBJECT = 5 Checking for Java2D/OpenGL support Java2D support: default GraphicsConfiguration = sun.java2d.opengl.WGLGraphicsConfig JOGL/Java2D integration enabled GLJPanel.addNotify() GLJPanel.handleReshape: (w,h) = (624,419) -- In invokeWithOGLContextCurrent -- Surface type: PBUFFER GLJPanel: gl.glScissor(8, 282, 624, 419) Sending reshape because viewport changed viewportX (0) ?= oglViewport.x ( 8 ) viewportY (0) ?= oglViewport.y (282) GLJPanel: Setting up drawBuffer 1028 and readBuffer 1028 GLJPanel: gl.glScissor(8, 282, 624, 419) GLJPanel: Setting up drawBuffer 1028 and readBuffer 1028 glViewport(8, 282, 624, 419) -- In invokeWithOGLContextCurrent -- Surface type: PBUFFER GLJPanel: gl.glScissor(0, 641, 193, 18) Sending reshape because viewport changed viewportX ( 8 ) ?= oglViewport.x (-70) viewportY (282) ?= oglViewport.y (240) GLJPanel: Setting up drawBuffer 1028 and readBuffer 1028 glViewport(-70, 240, 624, 419) -- In invokeWithOGLContextCurrent -- Surface type: PBUFFER GLJPanel: gl.glScissor(0, 641, 193, 18 ) GLJPanel: Setting up drawBuffer 1028 and readBuffer 1028 -- In invokeWithOGLContextCurrent -- Surface type: PBUFFER GLJPanel: gl.glScissor(8, 282, 624, 419) Sending reshape because viewport changed viewportX (-70) ?= oglViewport.x ( 8 ) viewportY (240) ?= oglViewport.y (282) GLJPanel: Setting up drawBuffer 1028 and readBuffer 1028 glViewport(8, 282, 624, 419) -- In invokeWithOGLContextCurrent -- Surface type: PBUFFER GLJPanel: gl.glScissor(0, 315, 624, 419) Sending reshape because viewport changed viewportX ( 8 ) ?= oglViewport.x (0) viewportY (282) ?= oglViewport.y (315) GLJPanel: Setting up drawBuffer 1028 and readBuffer 1028

[3.] Here is part of the log with OGL pipeline enabled, RepaintManager is not instaled, upper part of GLJPanel is “cut off”:
Options: -Djogl.verbose -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Dsun.java2d.opengl=True
java version "1.6.0-beta2" Java(TM) SE Runtime Environment (build 1.6.0-beta2-b83) Java HotSpot(TM) Client VM (build 1.6.0-beta2-b83, mixed mode, sharing) Opening file C:\CNS\Data2\Ball-C540.xml JOGL specification version 1.0.0 JOGL implementation version 1.0.0-beta4 JOGL implementation vendor Sun Microsystems, Inc. OGLUtilities.UNDEFINED = 0 OGLUtilities.WINDOW = 1 OGLUtilities.PBUFFER = 2 OGLUtilities.TEXTURE = 3 OGLUtilities.FLIP_BACKBUFFER = 4 OGLUtilities.FBOBJECT = 5 Checking for Java2D/OpenGL support Java2D support: default GraphicsConfiguration = sun.java2d.opengl.WGLGraphicsConfig JOGL/Java2D integration enabled GLJPanel.addNotify() GLJPanel.handleReshape: (w,h) = (624,419) -- In invokeWithOGLContextCurrent -- Surface type: PBUFFER GLJPanel: gl.glScissor(28, 240, 624, 419) Sending reshape because viewport changed viewportX (0) ?= oglViewport.x (28) viewportY (0) ?= oglViewport.y (240) GLJPanel: Setting up drawBuffer 1028 and readBuffer 1028 GLJPanel: gl.glScissor(28, 240, 624, 419) GLJPanel: Setting up drawBuffer 1028 and readBuffer 1028 glViewport(28, 240, 624, 419) -- In invokeWithOGLContextCurrent -- Surface type: PBUFFER GLJPanel: gl.glScissor(28, 240, 624, 419) GLJPanel: Setting up drawBuffer 1028 and readBuffer 1028 -- In invokeWithOGLContextCurrent -- Surface type: PBUFFER GLJPanel: gl.glScissor(28, 240, 624, 419) GLJPanel: Setting up drawBuffer 1028 and readBuffer 1028 -- In invokeWithOGLContextCurrent -- Surface type: PBUFFER GLJPanel: gl.glScissor(28, 240, 624, 419)

Do the JOGL demos like JGears work with -Dsun.java2d.opengl=true on your machine?

Have you tried removing your custom RepaintManager?

It’s basically impossible to tell what’s going wrong even from your detailed description. If you can boil things down into a small standalone test case then please feel free to file a bug.

Hi Ken,

thank you very much for your response. I have repeated my test to make my problem more clear - at least I hope so. I have removed custom RepaintManager because I suspect that inclusion of RepaintManager is related with another bug.

My application is very simple. I open a model and render it inside JInternalFrame using GLJPanel object. After my model is shown the JInternalFrame and my application are closed. OGL pipeline in the first case [see log 1] is disabled and in the second case [see log 2] is enabled (I have used the same UI actions in both cases). The problem is in the second case because my model is not shown completely and is translated to the bottom of the JInternalFrame window - I see a large area at the top of GLJPanel unused.

Just a hint - I’m not claiming that your are responsible for this bug - but are sure that the coordinates for glViewport() function are calculated correctly? I see glViewport(0, 0, 624, 419) in the first test and glViewport(28, 240, 624, 419) in the second test.

Kind regards,
Andrei

[1] Model is shown correctly:
Options: -Djogl.debug.Java2D -Djogl.debug.GLJPanel
java version "1.6.0-beta2" Java(TM) SE Runtime Environment (build 1.6.0-beta2-b83) Java HotSpot(TM) Client VM (build 1.6.0-beta2-b83, mixed mode, sharing) JOGL specification version 1.0.0 JOGL implementation version 1.0.0-beta4 JOGL implementation vendor Sun Microsystems, Inc. OGLUtilities.UNDEFINED = 0 OGLUtilities.WINDOW = 1 OGLUtilities.PBUFFER = 2 OGLUtilities.TEXTURE = 3 OGLUtilities.FLIP_BACKBUFFER = 4 OGLUtilities.FBOBJECT = 5 Checking for Java2D/OpenGL support Java2D support: default GraphicsConfiguration = sun.awt.Win32GraphicsConfig JOGL/Java2D integration disabled GLJPanel.addNotify() Using AWT thread for performing OpenGL work in javax.media.opengl implementation GLJPanel.handleReshape: (w,h) = (624,419) Resizing pbuffer from (256, 256) to fit (624, 419) New pbuffer size is (1024, 512) glViewport(0, 0, 624, 419) GLJPanel.removeNotify()

[2] Model is not shown correctly, it is translated to the bottom:
Options: -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Dsun.java2d.opengl=True
OpenGL pipeline enabled for default config on screen 0 java version "1.6.0-beta2" Java(TM) SE Runtime Environment (build 1.6.0-beta2-b83) Java HotSpot(TM) Client VM (build 1.6.0-beta2-b83, mixed mode, sharing) JOGL specification version 1.0.0 JOGL implementation version 1.0.0-beta4 JOGL implementation vendor Sun Microsystems, Inc. OGLUtilities.UNDEFINED = 0 OGLUtilities.WINDOW = 1 OGLUtilities.PBUFFER = 2 OGLUtilities.TEXTURE = 3 OGLUtilities.FLIP_BACKBUFFER = 4 OGLUtilities.FBOBJECT = 5 Checking for Java2D/OpenGL support Java2D support: default GraphicsConfiguration = sun.java2d.opengl.WGLGraphicsConfig JOGL/Java2D integration enabled GLJPanel.addNotify() GLJPanel.handleReshape: (w,h) = (624,419) -- In invokeWithOGLContextCurrent -- Surface type: PBUFFER GLJPanel: gl.glScissor(28, 240, 624, 419) Sending reshape because viewport changed viewportX (0) ?= oglViewport.x (28) viewportY (0) ?= oglViewport.y (240) GLJPanel: Setting up drawBuffer 1028 and readBuffer 1028 GLJPanel: gl.glScissor(28, 240, 624, 419) GLJPanel: Setting up drawBuffer 1028 and readBuffer 1028 glViewport(28, 240, 624, 419) -- In invokeWithOGLContextCurrent -- Surface type: PBUFFER GLJPanel: gl.glScissor(644, 640, 8, 16) GLJPanel: Setting up drawBuffer 1028 and readBuffer 1028 -- In invokeWithOGLContextCurrent -- Surface type: PBUFFER GLJPanel: gl.glScissor(644, 640, 8, 16) GLJPanel: Setting up drawBuffer 1028 and readBuffer 1028 GLJPanel.removeNotify()

There’s nothing obviously wrong here. When the Java2D/JOGL bridge is enabled, this is the only time non-zero x and y coordinates for the reshape() callback are generated, due to how the underlying OpenGL context is being used. I do recall a bug in some of the JOGL demos where they were ignoring the incoming x and y coordinates and instead always passing 0, 0 to glViewport; is it possible your code has the same problem?

Is there any way you can post a reduced test case?

Hi Ken

[quote]Do the JOGL demos like JGears work with -Dsun.java2d.opengl=true on your machine?
[/quote]
Yes, I have verified and I can confirm that demos JGears and JRefract works but my complain is that Gears demo inside JRefract is 10 times slower than JGears. To my very surprice I have noticed that the Gears demo does not work. I get the following exception:
`
C:\Andrej\Jogl-JSR231-beta4>java -classpath .;C:\Andrej\Jogl-JSR231-beta4\jogl.j
ar;C:\Andrej\Jogl-JSR231-beta4\jogl-demos.jar;C:\Andrej\Jogl-JSR231-beta4\jogl-d
emos-util.jar;C:\Andrej\Jogl-JSR231-beta4\jogl-demos-data.jar -showversion -Djo
gl.debug.Java2D -Djogl.debug.GLJPanel -Djava.library.path=C:\Andrej\Jogl-JSR231-
beta4\ -Dsun.java2d.opengl=True demos.gears.Gears
java version “1.6.0-beta2”
Java™ SE Runtime Environment (build 1.6.0-beta2-b83)
Java HotSpot™ Client VM (build 1.6.0-beta2-b83, mixed mode, sharing)

OpenGL pipeline enabled for default config on screen 0
JOGL/Java2D integration enabled
Exception in thread “Thread-2” javax.media.opengl.GLException: javax.media.openg
l.GLException: wglShareLists(0x10001, 0x10002) failed: error code 0
at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:266)
at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:256)
at javax.media.opengl.GLCanvas.display(GLCanvas.java:130)
at com.sun.opengl.util.Animator.display(Animator.java:144)
at com.sun.opengl.util.Animator$MainLoop.run(Animator.java:181)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.media.opengl.GLException: wglShareLists(0x10001, 0x10002) failed: error code 0
at com.sun.opengl.impl.windows.WindowsGLContext.create(WindowsGLContext.java:133 )
at com.sun.opengl.impl.windows.WindowsGLContext.makeCurrentImpl(WindowsGLContext.java:147 )
at com.sun.opengl.impl.windows.WindowsOnscreenGLContext.makeCurrentImpl(WindowsOnscreenGLContext.java:65 )
at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:118 )
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:182)
at javax.media.opengl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:298 )
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
GL_VENDOR: NVIDIA Corporation
GL_RENDERER: GeForce FX 5700LE/AGP/SSE2/3DNOW!
GL_VERSION: 2.0.1
`
What have I done wrong?

Kind regards,
Andrei

The JRefract demo caps the animation at 60 FPS while JGears doesn’t, so this isn’t surprising and shouldn’t impact real applications.

Yes, I can reproduce this. I’ve filed Issue 220 to track it. The issue is probably recently-added support to the Java2D/JOGL bridge for the case where Java2D’s OpenGL pipeline is using Frame Buffer Objects to do its rendering.

To get back to your issue, as long as JGears and JRefract are working, I would have to assume that your application is making an invalid assumption like passing wrong values to glViewport somewhere. Can you post a small test case?

Hi Ken

[quote]I do recall a bug in some of the JOGL demos where they were ignoring the incoming x and y coordinates and instead always passing 0, 0 to glViewport; is it possible your code has the same problem?
[/quote]
You have solved my problem. Thank you, thank you, thank you. I have verified my method reshape(GLAutoDrawable gLDrawable, int x, int y, int width, int height) and I have noticed that I had gl.glViewport(0, 0, width, height) inside of it. When I changed that part of code to gl.glViewport(x, y, width, height) everything now works as it should - and there is no more problems with custom RepaintManager anymore. So, actually it was my bug.

Best regards,
Andrei

Glad things are working for you. Please post if you run into any more problems.