GLJPanel flicker and origin strangeness

I finally got my system going (Linux FC10, GeForce 9500 GT, JDK 1.6) and starting building my application.

I started using GLCanvas objects and switched to GLJPanel objects n turned on Java2D.opengl (with -Dsun.java2d.opengl=true in cmd line). Boy, what problems…

The application implements an MDI look n feel. I plop GLJPanels on it that display some real-time graphs. In summary:

  1. with using GLCanvas (instead of GLJPanels), everything works but I’m seeing some funny business with the simple menu system I have. If one of the GLCanvas objects is near the menu bar, then it hides the menus as I pull them down. This didn’t happen with JDK 1.5. CPU utilization is about 40-45% with 5 separate graphs going at 64Hz display rate.

  2. If I enable sun.java2d.opengl=true, the CPU utilization is roughly the same, maybe a less.

  3. When I change the GLCanvas objects to GLJPanels and disable sun.java2d.opengl, everything works well - no funny business with the menus, but CPU utilization is about 120% on my dual core duo.

  4. when I then enable sun.java2d.opengl (using GLJPanels), I experience lots of problems (but the CPU utilization drops to about 40% with 5 graphs going!):

a) serious flashing of graphs. Some partially hide others and the borders of those in back flash through to those in the front.

b) coordinate system is screwed up - 0,0 seems to be relative to my JFrame.

c) my text object that uses com.sun.opengl.util.j2d.TextRenderer causes the application to completely hang.

Ouch.

I can supply sample code if anyone wishes.

i am not sure if this will help :confused: the java2d opengl pipeline is very instable and therefore not widely used. Try to circumvent it whenever possible to enable the pipeline.

This is caused by mixing lightweight (swing) and heavyweight (awt) components and is a known issue on all java versons (even 1.5). You need to switch to heavyweight popups with


    JPopupMenu.setDefaultLightWeightPopupEnabled(false);

before making the frame visibe

is unstable, don’t use it unless there is an update to this in any future jdk/jogl version sigh

could be your code that is screwed up :stuck_out_tongue: but always use


-Dsun.java2d.noddraw=true -Dsun.awt.noerasebackground=true

hmm, dunno. maybe your didn’t setup your viewport/projection matrix correctly in reshape(), so the last java2d setting is used?

smells like a bug. did you use the textrenderer inside of display lists?

:slight_smile: don’t use the java2d opengl pipeline for know.

A agree with Cylab, stay away from the Java2d OpenGL pipeline if you want to run your application on other computers.
The better is to use the GLCanvas, it works on every plateforms. And since JDK 1.6.0 update 12 mixing of Swing and Awt components is more supported (it’s still not perfect, but much better).

If you’re using GLJPanel without the Java2D pipeline, you’ll obtain worth performances and an higher CPU consumption. It’s because for each frame, the whole content of an underlying Pbuffer is copied into a Java Image which is then displayed on the screen.

Concerning the issue with viewport see http://www.java-gaming.org/index.php/topic,16414.0.html.

To test if the flashing and other artifacts you are experiencing are related to the pipeline or error in your code, you may try the GLJPanel demo (on the JOGL demo page).

Thanks for everyone’s comments. I’ve quickly tried some stuff:


-Dsun.java2d.noddraw=true -Dsun.awt.noerasebackground=true

Didn’t seem to have any effect. I’ll check my code against the JRefract demo to see if I missed anything.

Concerning the TextRenderer, I don’t add these to displayLists. Here’s the code in my renderer:


	public void display(GLAutoDrawable drawable) {
		final GL gl = drawable.getGL();
		gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
		gl.glLoadIdentity();

		renderer.beginRendering(drawable.getWidth(), drawable.getHeight());
	        // optionally set the color
	        renderer.setColor(1.0f, 0.2f, 0.2f, 0.8f);
	        renderer.draw(format.format(meterValue),
                        (int) (PANEL_WIDTH * 0.30),
                        (int) (PANEL_HEIGHT * 0.30));
	         renderer.endRendering();
	    
	         drawable.swapBuffers();
	}

	public void init(GLAutoDrawable drawable) {
		renderer = new TextRenderer (new Font ("SansSerif", Font.BOLD, 72));
                GL gl = drawable.getGL();
        
                gl.glClearColor(backgroundColor[0], backgroundColor[1],
        		backgroundColor[2], 0.0f);
                gl.glShadeModel(GL.GL_FLAT);
        
		gl.glMatrixMode(GL.GL_PROJECTION);
		gl.glLoadIdentity();
		setProjection(gl);

		gl.glMatrixMode(GL.GL_MODELVIEW);
	}

I’ll continue working on this. Thanks again for the responses.