Java2D/JOGL Interoperability Demo

I need to add my computer is a P4 1.8 Ghz laptop with 1 GB of RAM. So it’s pretty good but it’s not extremly powerful.

I downloaded the latest nVidia driver and it is still no good. No AA doesn’t help either. Setting noddraw to true seemed to help just a little bit but it is still really slow. I will put it through the netbean profiler and see if anything sticks out.

D:\DevJava\Twinkle>java -classpath bin;lib\vecmath.jar;..\JOGL\jogl.jar -Dtwinkle.aa=true -Dsun.java2d.opengl=True -Djogl.debug.Java2D org.progx.twinkle.Twinkle
OpenGL pipeline enabled for default config on screen 0
JOGL/Java2D integration enabled
exception in QueueFlusher:
java.lang.NullPointerException
        at org.progx.jogl.rendering.ReflectedQuad.render(ReflectedQuad.java:37)
        at org.progx.twinkle.ui.PictureViewer.setAndRender(PictureViewer.java:604)
        at org.progx.twinkle.ui.PictureViewer.renderItems(PictureViewer.java:584)
        at org.progx.twinkle.ui.PictureViewer.access$22(PictureViewer.java:582)
        at org.progx.twinkle.ui.PictureViewer$3.render(PictureViewer.java:532)
        at org.progx.jogl.GLUtilities.renderAntiAliased(GLUtilities.java:89)
        at org.progx.twinkle.ui.PictureViewer.render3DScene(PictureViewer.java:540)
        at org.progx.jogl.CompositeGLPanel.display(CompositeGLPanel.java:73)
        at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:77)
        at javax.media.opengl.GLJPanel$Updater.display(GLJPanel.java:708)
        at javax.media.opengl.GLJPanel$DisplayAction.run(GLJPanel.java:863)
        at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:128)
        at javax.media.opengl.GLJPanel$1.run(GLJPanel.java:349)
        at sun.java2d.opengl.OGLRenderQueue$QueueFlusher.run(Unknown Source)
exception in QueueFlusher:
java.lang.NullPointerException
        at org.progx.jogl.rendering.ReflectedQuad.render(ReflectedQuad.java:37)
        at org.progx.twinkle.ui.PictureViewer.setAndRender(PictureViewer.java:604)
        at org.progx.twinkle.ui.PictureViewer.renderItems(PictureViewer.java:584)
        at org.progx.twinkle.ui.PictureViewer.access$22(PictureViewer.java:582)
        at org.progx.twinkle.ui.PictureViewer$3.render(PictureViewer.java:532)
        at org.progx.jogl.GLUtilities.renderAntiAliased(GLUtilities.java:89)
        at org.progx.twinkle.ui.PictureViewer.render3DScene(PictureViewer.java:540)
        at org.progx.jogl.CompositeGLPanel.display(CompositeGLPanel.java:73)
        at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:77)
        at javax.media.opengl.GLJPanel$Updater.display(GLJPanel.java:708)
        at javax.media.opengl.GLJPanel$DisplayAction.run(GLJPanel.java:863)
        at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:128)
        at javax.media.opengl.GLJPanel$1.run(GLJPanel.java:349)
        at sun.java2d.opengl.OGLRenderQueue$QueueFlusher.run(Unknown Source)

After that I get the same experience. Clicking the arrows results in the first image blinking away. The next image does not slide into place. No further exceptions are reported. With Twinkle.aa=false I just got the exception once, but the end result was the same.
I’m running Win XP pro SP2, 1GB RAM, dual 2.4 GHz Xeon, GeForce4 Ti 4200 using nVidia drivers 81.85

I’m now downloading nVidia drivers v 81.98

Exiting crashes in native code related to OpenGL. See attached error log.

This is a bug in NVidia’s recent OpenGL drivers on Windows which apparently slipped through the cracks because they didn’t run the Java2D/OpenGL regression test suite which Chris Campbell provided to them on that platform. From what I’ve heard it will be fixed in their next driver release.

Hey Scott,

See this bug:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6341149

As Ken mentioned, this was a regression in Nvidia’s 81.85 driver release for Windows, and they quickly fixed it in 81.94. Are your drivers up to date?

Thanks,
Chris

I mentioned above, I’ve upgraded to 81.98 and have the same problem.

Sorry, I was tuning in and out. Is this crash-on-exit reproducible with non-JOGL apps, like just running SwingSet2 with the OGL pipeline enabled?

Thanks,
Chris.

I’m, back at work now and I can’t reproduce the crash. I must have made a mistake earlier. The Twinkle application still looks horrible and rendering is obviously hosed, but when I exit I’m not getting the crash in the nVidia code anymore so I have to conclude that the crash IS fixed in 81.98.

Sorry, I think that was a false alarm.

Would it be possible to have the twinkle and jbutton programs available again? The links on the last page are not longer good.

See here for Twinkle: http://www.jroller.com/page/gfx/?anchor=a_swing_opengl_photo_viewer
and here for the 3D button: http://www.jroller.com/page/gfx/?anchor=a_swing_button_with_3d

Thanks for posting the links again. I profiled Twinkle and there doesn’t appear to be anything out of the ordinary. GLUtilities.renderAntiAlaised and gl.glbegin take upthe most time but that would seem to be expected. I am going to see poke around with other GLJPanel apps and see if they are also really slow.

I’m experiencing a problem with the Java2D/JOGL Interoperability.

The first one is it crashes when I exit as soon as I activate the flag -Dsun.java2d.opengl=true
I’ve read it may come from the nvidia driver and I do weird things with my nvidia driver (I’ve installed
a GeForce forceware82.10 driver on a Quadro FXGo700 to enhance perfs) so I’ll have to test on a clean
computer before I can complain :wink:

The second one is an incompatibility question between the flag -Dsun.java2d.opengl=true and -Dopengl.1thread=awt
when I activate -Dopengl.1thread=awt my openGL functions init(), display()… are called by the awt event thread
Thread.currentThread() in display() returns: [AWT-EventQueue-0,6,main] (so it works)

When I activate no flag the default behavior is
Thread.currentThread() in display() returns: [JOGL GLWorkerThread,6,main]

But finally when I actiate the 2 flags together (my live is full new experiences :wink: I get
Thread.currentThread() in display() returns: [Java2D Queue Flusher,10,main]

Which is bad for me because going though the thread [AWT-EventQueue-0,6,main] allowed me to get rid of a poor deadlock in my code

with -Dsun.java2d.opengl=true I have all the speed I ever dreamed on a GLJPanel … but I really liked the awt thread stuff. On the other
hand I wonder if I don’t miss something about the whole threading issue

If someone has an insight on the problem to share, I would be very gratefull

Fred

I have the newest JOGL and Java 6 beta yet I get very low frame rates with this code. Could someone point out the error of my ways? The same code runs very fast when the AWT widget is used in place of the Swing.

//=====( Begin constructor )=================================================

/**
 * Get the JFrame, rendering canvas, and rendering thread set up.
 */

public GL_Game_Core()
{
	// Create GLCanvas, and do setup involving it

// GLCanvas canvas = new GLCanvas(new GLCapabilities());
GLJPanel canvas = new GLJPanel(new GLCapabilities());

	canvas.addGLEventListener(this);
	getContentPane().add(canvas);
	animator = new Animator(canvas);

	// Make adjustments to the JFrame
	setUndecorated(true);
	setResizable(false);

	// Go into fullscreen mode
	DisplayMode displayMode = new DisplayMode(
		SCREEN_WIDTH,
		SCREEN_HEIGHT,
		BITS_PER_PIXEL,
		REFRESH_RATE);
	GraphicsEnvironment environment =
		GraphicsEnvironment.getLocalGraphicsEnvironment();
	GraphicsDevice device = environment.getDefaultScreenDevice();
	device.setFullScreenWindow(this);
	device.setDisplayMode(displayMode);

	// Start the rendering thread
	setVisible(true);
	animator.start();
	canvas.requestFocus();
}

//=====( End Constructor )===================================================
/////////////////////////////////////////////////////////////////////////////
//=====( Begin init() )======================================================

/**
 * Do all one-time-only setup operations.
 */

public void init(GLAutoDrawable drawable)
{
	// Get current GL and GLU
	GL gl = drawable.getGL();

	// Create the GLUT object
	glut = new GLUT();
	glu  = new GLU();

	// Get TextureManager instance
	textureManager = TextureManager.getInstance(gl, glu);

	// Enable basic OpenGL functions
	gl.glEnable(GL.GL_LIGHTING);
	gl.glEnable(GL.GL_DEPTH_TEST);
	gl.glEnable(GL.GL_CULL_FACE);

	// Set state variables
	gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
	gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	gl.glClearDepth(1.0f);
	gl.glDepthFunc(GL.GL_LEQUAL);
	gl.glShadeModel(GL.GL_SMOOTH);
	gl.glCullFace(GL.GL_BACK);

	// Create and setup camera instance
	camera = new Camera(baseCameraMoveRate,
	                    baseCameraRotationRate,
	                    eyeX, eyeY, eyeZ,
	                    centerX, centerY, centerZ,
	                    upX, upY, upZ);

	// Create object to manage key and mouse events
	inputManager = new InputManager((Component)drawable);
	
	// Get rid of the cursor
	inputManager.setCursor(InputManager.INVISIBLE_CURSOR);
	
	// Create the LightManager
	lightManager = LightManager.getInstance(gl, camera);

	// Wire up key and mouse commands
	createGameActions();

	// Do initialization that is specific to the extending class
	initGameSpecificCode(gl, glu);

	// The game is about to start, so get the start time for time-based
	// movement and frames per second calculations
	currentTime = System.nanoTime();
	startTime   = currentTime;
}

//=====( End init() )========================================================

Thanks much,

Keith

Are you specifying -Dsun.java2d.opengl=true on the command line? That enables the accelerated version of the GLJPanel.

hi…
i am getting error for import javax.media.opengl statement. I have downloaded jogl.jar file but it dont show javax.media.opengl pckg.
Can please help me in this case. This is my first exp of doing programming with the JOGL. Please help me… ??? ???

sorry for bothering…

cheers,
mont[/b]

you need to download one of the jsr-beta releases or a nightly. Try the jsr-beta4 release. It’s from April 20, 2006.

What about the Mac Os X version of the Java2D/JOGL Interoperability. It is mentionned in the initial post but couldn’t find any later reference.
I have java 1.6.0-dp (universal binaries) on Mac OS X v10.4.7, the jogl version I use is 1.0.0-beta5 (universal binaries) and unfortunately get this message after
turning a couple debug option on :
JOGL specification version 1.0.0
JOGL implementation version 1.0.0-beta5
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 = apple.awt.CGraphicsConfig
JOGL/Java2D integration disabled

Am I doing something wrong or is the Java2D/Jogl bridge not enabled yet on Mac OS X ?

Excellent question. I’m pleased to be able to tell you that as of the day before yesterday (literally) the Java2D/JOGL bridge is working on Mac OS X thanks to help from Gerard Ziemski at Apple (and also Chris Campbell from Sun who helped Apple get the Java2D/OpenGL pipeline running on OS X). The new functionality will be present in the Developer Preview 5 of Mustang on OS X. There is a remaining problem on the JOGL side with GLPbuffers when the bridge is enabled, but I’ll need bits to test with before I can fix that problem.

I tried some GLJPanel stuff this past weekend with the latest Java 1.6 beta and it was significantly slower than Java 1.5. Unfortunately, I will not be able to enable the opengl pipeline, so I’m using the default pbuffer solution. I would expect, though, that 1.6 would be at least as fast as 1.5 even with the old renderer. But on my ThinkPad T41 laptop on WindowsXP running the JCanyon demo (modified to use the Swing renderer), I get 8-9fps with Java 1.5, and 3-4fps with Java 1.6. I think I’m using the latest betas of everything and the latest drivers available for my laptop.