The OpenGL pipeline is available on Oracle Solaris, Linux, and Windows. This alternate pipeline uses the hardware-accelerated, cross-platform OpenGL API when rendering to VolatileImages
, to backbuffers created with BufferStrategy
API, and to the screen.
This pipeline can offer great performance advantages over the default (X11 or GDI/DirectDraw) pipelines for certain applications. Consider enabling the pipeline for your application if it makes heavy use of rendering operations like alpha compositing, antialiasing, and transforms.
For a complete list of Java 2D operations that are accelerated by the OpenGL pipeline, refer to the article Behind the Graphics2D: The OpenGL-based Pipeline.
The following are use cases for troubleshooting problems in OpenGL pipeline
The OpenGL pipeline is currently disabled by default. To attempt to enable the OpenGL pipeline, provide the following option to the JVM:
-Dsun.java2d.opengl=true
To receive verbose console output about whether the OpenGL pipeline is initialized successfully for a particular screen, set the option to True (note the uppercase "T"):
The OpenGL pipeline will not be enabled if the hardware or drivers do not meet the minimum requirements. If for some reason one of the following requirements is not met, Java 2D will fall back and use the default pipeline (X11 on Oracle Solaris/Linux, GDI/DirectDraw on Windows), which means your application will continue to work correctly, but without the OpenGL acceleration.
The minimum requirements for Oracle Solaris and Linux operating systems are the following:
Hardware accelerated OpenGL/GLX libraries installed and configured properly
OpenGL version 1.2 or higher
GLX version 1.3 or higher
At least one TrueColor visual with an available depth buffer
The minimum requirements for Windows OS are the following:
Hardware accelerated drivers supporting the extensions WGL_ARB_pbuffer
, WGL_ARB_render_texture
, and WGL_ARB_pixel_format
OpenGL version 1.2 or higher
At least one pixel format with an available depth buffer
As mentioned above, the OpenGL pipeline might not be enabled on certain machines for various reasons. For example, the drivers might not be properly installed and might report an insufficient version number. Alternatively, your machine might have an older graphics card that does not support the appropriate OpenGL version or extensions.
In the Java SE 6 and later releases, you can get detailed information about the startup procedures of the OpenGL-based Java 2D pipeline by using the J2D_TRACE_LEVEL
environment variable as shown in Example 11-2 and Example 11-3.
Example 11-2 Set J2D_TRACE_LEVEL Environment Variable on Windows
# set J2D_TRACE_LEVEL=4 # java -Dsun.java2d.opengl=True YourApp
Example 11-3 Set J2D_TRACE_LEVEL Environment Variable on Solaris and Linux
# export J2D_TRACE_LEVEL=4 # java -Dsun.java2d.opengl=True YourApp
The output will be different depending on your platform and the installed graphics hardware, but it can give you some insight into the reasons why the OpenGL pipeline is not being successfully enabled for your configuration.
Note: This output is especially useful when filing bug reports intended for the Java 2D team at Sun, as discussed below. |
Since the OpenGL pipeline relies so heavily on the underlying graphics hardware and drivers, it might sometimes be difficult to determine whether rendering or performance issues are being caused by Java 2D or by the OpenGL drivers.
One feature new to the OpenGL pipeline in the Java SE 6 release is the use of the GL_EXT_framebuffer_object
extension, which provides better performance for rendering and reduced VRAM consumption when using VolatileImages
. This "FBO" codepath is enabled by default when the OpenGL pipeline is enabled, but only if your graphics hardware and driver support this OpenGL extension. This extension is generally available on Nvidia GeForce/Quadro FX series and newer, and on ATI Radeon 9500 and newer. If you suspect that the "FBO" codepath is causing problems in your application, you can disable it by setting the following system property:
-Dsun.java2d.opengl.fbobject=false
Setting this property will cause Java 2D to fall back on the older pbuffer-based
codepath.
If you find that a certain Java 2D operation causes different visual results with the OpenGL pipeline enabled than without, it probably indicates a graphics driver bug. Similarly, if the performance of Java 2D rendering is significantly worse with the OpenGL pipeline enabled than without, it is most likely caused by a driver or hardware problem.
In either case, file a detailed bug report through the normal bug reporting channels. See Submit a Bug Report. When filing bug reports, be as detailed as possible, and always include the following information:
Operating system (for example, Ubuntu Linux 6.06, Windows XP SP2)
Name of graphics hardware manufacturer and device (for example, Nvidia GeForce 2 MX 440)
Exact driver version (for example, ATI Catalyst 6.8, Nvidia 91.33)
Output when J2D_TRACE_LEVEL=4
is specified on the command line (as described in previous section)
If on Oracle Solaris or Linux, the output of the glxinfo command