openGL not moving with GLJPanel

First there is something wrong with registering for this site. The letters you have to type in don’t all show most of the time and the part where it reads you the letters usually only reads the first two. It took me about 10 trys to register. (I’m using the latest version of Firefox)

Anyway:
I am having a spot of trouble with GLJPanel. When I move the JFrame that contains the GLJPanel, OpenGL doesn’t recognize the new location of the GLJPanel. OpenGL still tries to draw the image where the panel use to be. You can’t see it, but it’s there if you move the GLJPanel back. If I resize the JFrame, OpenGL pops into place.

I came up with a workaround that works OK. I listen to the JFrame’s componentMoved event and resize the JFrame to emulate what happens when I resize the JFrame manually.


	int sign=1;
	public void componentMoved(ComponentEvent e){
		sign*=-1;
		frame.setSize(frame.getWidth()+sign,frame.getHeight());
	}

However, I don’t particularly like this solution. The changing of the frame size by a pixel is a bit annoying. Is there a better way?

Does this happen with e.g. the JGears demo as well?

What OS, graphics card, and driver version are you running? Are you running with the latest set of drivers on your platform? If you’re on Windows, are you specifying -Dsun.java2d.noddraw=true on the command line (required for all JOGL applications)?

JGears works just fine.

GL_VENDOR: ATI Technologies Inc.
GL_RENDERER: RADEON 9800 Pro x86/SSE2
GL_VERSION: 2.0.5949 WinXP Release

I think so.

I’m on Windows and I did specify -Dsun.java2d.noddraw=true . I also specified -Dsun.java2d.opengl=true.

When I resize the JFrame the GLJPanel fires GLEvents for init, display, and reshape. When I move the window no GLEvents are fired.

Also, OpenGL will track the GLJPanel as long as I don’t interact with what I’m viewing. As soon as I use the mouse to change my view on the object (i.e. change some of the rotation angles.), OpenGL sticks in place until the panel is resized. (I don’t get this behavior)

The one thing that might be fixing it in place is that I do a gljPanel.repaint() after I change the the view parameters. The repaint command causes the display GLEvent to be fired. That’s the only thing that ocures between the time OpenGL tracks the GLJPanel and and when it stops tracking. Calling gljPanel.display() does the same thing.

Is there another way to update the OpenGL display?

What JDK version are you running? We only recommend trying the Java2D/OpenGL pipeline (-Dsun.java2d.opengl=true) beginning with JDK 6.

You can call GLJPanel.display() to force a synchronous repaint just as with the GLCanvas.

I am using jdk version 1.6.0-rc-b94

I tried that. It has the same effect as calling GLJPanel.repaint().

The problem has to do with -Dsun.java2d.opengl=true. If I don’t set that parameter then it works. Unfortunately, if I don’t set it then the OpenGL output doesn’t look as good. Fragments of wire frame objects show through solid object that are in front of the wire frame objects.

Can you put up source code somewhere for a small and self-contained test case? I don’t have any ideas about what could be going wrong just based on this description.

You can pick it up here

http://cast.uark.edu/~wgj/export/TestJOGL.java

mouse left button changes camera position about the center of focus
mouse wheel moves the camera in and out
mouse right button pans the camera accross the surface

To see the problem click in the window with the left mouse (or any other operation that will call repaint) then move the window and then use the mouse again to try to interact with object.

Sorry but I can’t reproduce this problem on my machine which has NVidia hardware. Can you find another machine with a different / more recent graphics card and see whether it occurs there? At this point my best guess is some driver-level problem triggered by the Java2D/JOGL bridge. I don’t see the artifacts you mentioned with lines showing through solid objects with -Dsun.java2d.noddraw=true but believe that is probably caused by the zNear and zFar settings you’re passing to gluPerspective. You should never pass 0 as zNear as my understanding is that can cause severe problems with depth buffer resolution, and you should try to keep the number of orders of magnitude between zNear and zFar to a minimum.

Your right, changing the near setting to 0.01 fixed the see though problem. Thanks.

What about the more serious problem of OpenGL not tracking the GLJPanel when -Dsun.java2d.opengl=true is set (and using Java 1.6 build 94). Did you see that?

With -Dsun.java2d.opengl=true set I have to resize the window everytime I move it. Resizing causes OpenGL to recognize the new location of the window.

With -Dsun.java2d.opengl=true set resizing calls init(). With -Dsun.java2d.opengl=true not set resizing does not call init().

I suspect that for whatever reason that init() is called when the window is resized it should also be called when the window is moved (when Dsun.java2d.opengl=true is set).

I can’t reproduce this problem on my machines. I suspect it is a driver-level bug.

No, init() is only called when the OpenGL context is destroyed and re-created. Given the way this has been implemented in Java SE 6 when the Java2D/OpenGL pipeline is enabled it occurs every time a top-level window is resized (though not if a JInternalFrame is resized, for example). You might want to also try specifying -Dsun.java2d.opengl.fbobject=false along with -Dsun.java2d.opengl=true and see whether that changes the behavior, as well as trying the latest Java SE 6 build. I’d also again recommend you see if there are updated drivers for your machine as well as trying on a different vendor’s hardware.

That figures.

No effect

No effect

Hey, what do you know? That worked. :slight_smile: I understand that this slows things down by about 10%. It also causes an EXCEPTION_ACCESS_VIOLATION and dumps an error log when the program closes. :frowning: There are always trade-offs.

I’ll have to try it on other machines at some other time.

BTW Ken, thanks a ton for all the attention you give to the users of this board. I am sure we are all very grateful that you are answering our questions.

Just a follow up.

I tried this on an Nvidia GeForce FX 5200 this weekend. I had no problems. So it seems it’s a problem with just my video card (ATI Radeon 9800 Pro).