Soapbox of Destiny

$ cat /dev/brain > here

9 notes

How to make Swing and fullscreen OpenGL applications cohabitate

Just had an interesting situation where we were unable to start a Swing application under Windows while an OpenGL app was currently running in fullscreen. The symptoms were a JVM crash, citing a null pointer exception (Exception Code: c0000005) in java.dll.

After some research we found that for some environments, the JVM may choose to use a Direct3D pipeline for its 2D drawings. It seems that internally the JVM maybe trying to initialise Direct3D, but unable to get hold of a context as it is already reserved for OpenGLs use in fullscreen.

To overcome this, you can prevent the JVM from using the Direct3D pipeline by either:

  • Specifying the JVM argument -Dsun.java2d.d3d=false
  • Setting the environment variable J2D_D3D=false

After making this change, the Swing app was able to start behind the scenes while the OpenGL app was running in fullscreen.

For more information on how you can configure the behavior Java2D, check out the official System Properties for Java2D at http://download.oracle.com/javase/1.5.0/docs/guide/2d/flags.html

Filed under java opengl direct3d programming

  1. leetmrfhaxftw posted this