Documentation

opengl

Control OpenGL rendering

The autoselect, neverselect, advise, quiet, verbose, and DriverBugWorkaround inputs have been removed in R2014b. For more information about the behavior of these syntaxes in previous releases, see opengl for R2014a.

Syntax

  • opengl info
    example
  • d = opengl('data')
  • opengl software
    example
  • opengl hardware
  • opengl hardwarebasic

Description

example

opengl info prints information about the OpenGL® implementation currently in use by MATLAB®, such as the version, vendor, and graphics features that it supports. The returned fields might change in future releases as graphics features change. Using this command loads OpenGL.

d = opengl('data') returns the same data provided with opengl info, but stores it in a structure.

example

opengl software uses a software version of OpenGL to render subsequent graphics for the current MATLAB session. This command works only on Windows® systems.

opengl hardware uses a hardware-accelerated version of OpenGL to render subsequent graphics. If your graphics hardware does not support hardware-accelerated OpenGL, then MATLAB uses a software version instead.

opengl hardwarebasic uses a hardware-accelerated version of OpenGL, but disables some advanced graphics features that are unstable with certain graphics drivers. If your graphics hardware does not support hardware-accelerated OpenGL, then MATLAB uses a software version instead.

example

opengl('save',pref) sets your preferences so that future sessions of MATLAB on this computer use the preferred version of OpenGL. Specify pref as 'software', 'hardware', 'hardwarebasic', or 'none'. This command does not affect the current session.

Examples

Display Information About OpenGL

Using the opengl info command, display information about the OpenGL implementation currently in use by MATLAB. For example, display the vendor, the version, and the supported graphics features. Also display whether MATLAB is using a hardware-accelerated implementation or a software implementation of OpenGL.

opengl info
                          Version: '2.1 Mesa 7.2'
                           Vendor: 'Brian Paul'
                         Renderer: 'Mesa X11'
                   MaxTextureSize: 2048
                           Visual: 'Visual 0x6b, (RGBA 32 bits (8 8 8 8), ...'
                         Software: 'true'
             HardwareSupportLevel: 'none'
        SupportsGraphicsSmoothing: 0
    SupportsDepthPeelTransparency: 1
       SupportsAlignVertexCenters: 0
                       Extensions: {114x1 cell}
               MaxFrameBufferSize: 4096

Determine Graphics Hardware

Using the opengl info command, determine your graphics hardware by checking the Vendor and Renderer fields.

opengl info
                          Version: '3.3.0'
                           Vendor: 'NVIDIA Corporation'
                         Renderer: 'Quadro 400/PCIe/SSE2'
            RendererDriverVersion: '9.18.13.3182'
        RendererDriverReleaseDate: '11-Nov-2013'
                   MaxTextureSize: 8192
                           Visual: 'Visual 0x07, (RGBA 32 bits (8 8 8 8...'
                         Software: 'false'
             HardwareSupportLevel: 'full'
        SupportsGraphicsSmoothing: 1
    SupportsDepthPeelTransparency: 1
       SupportsAlignVertexCenters: 1
                       Extensions: {248x1 cell}
               MaxFrameBufferSize: 8192

    Note:   If the returned fields contain the line Software: 'true', then you are using software OpenGL and the name listed in the Vendor field is not your graphics hardware vendor. Instead, the Vendor field indicates the manufacturer of the software OpenGL implementation.

Determine Graphics Hardware When Using Software OpenGL (Windows)

Close all figures, switch to hardware OpenGL, and issue the opengl info command. Then, switch back to software OpenGL.

close all 
opengl hardware
opengl info
opengl software

Determine Graphics Hardware When Using Software OpenGL (Linux)

Start MATLAB with the -nosoftwareopengl flag. Then, issue the opengl info command.

Use Software OpenGL for Current Session

Switch to using software OpenGL to render graphics in the current session.

opengl software

This command works only on Windows systems.

Use Software OpenGL for Future Sessions

Set your preferences so that MATLAB uses software OpenGL to render graphics in all future sessions. This command does not affect the current session.

opengl('save','software')

Input Arguments

collapse all

info — Information about OpenGL implementationinfo

Information about the OpenGL implementation currently in use by MATLAB, specified as info. The opengl info command returns the fields listed in this table.

FieldDescription
VersionVersion of the OpenGL implementation.
VendorManufacturer of the OpenGL implementation.
RendererDriverVersionVersion of the OpenGL driver (Windows systems with hardware-accelerated OpenGL only). This field does not display on virtual machines.
RendererDriverReleaseDateRelease date of the OpenGL driver (Windows systems with hardware-accelerated OpenGL only). This field does not display on virtual machines.
Renderer

Description of the OpenGL renderer. If you are using hardware-accelerated OpenGL, this field is the graphics card model name.

MaxTextureSize

Maximum texture size supported by the OpenGL implementation.

VisualDisplay properties of the OpenGL implementation.
SoftwareSoftware OpenGL enabled, returned as 'true' or 'false'.
HardwareSupportLevelHardware support level, returned as one of these values:
  • 'full' — Hardware-accelerated OpenGL (all graphics features enabled)

  • 'basic' — Basic hardware-accelerated OpenGL (some graphics features disabled)

  • 'none' — Software OpenGL

If MATLAB detects an unsupported driver, this field also contains 'known graphics driver issues'.
SupportsGraphicsSmoothingGraphics smoothing feature support, returned as 1 if supported or 0 otherwise.
SupportsDepthPeelTransparencyDepth peel transparency feature support, returned as 1 if supported or 0 otherwise.
SupportsAlignVertexCentersAlign vertex centers feature support, returned as 1 if supported or 0 otherwise.
Extensions

Extended capabilities supported by the OpenGL implementation.

MaxFrameBufferSize

Maximum frame buffer size supported by the OpenGL implementation.

For more information about the graphics smoothing, depth peel transparency, and align vertex centers features, see Advanced Graphics Features.

software — Software OpenGLsoftware

Software OpenGL, specified as software.

To switch to software OpenGL:

  • On Windows systems, execute opengl software.

  • On Linux® systems, start MATLAB with the -softwareopengl flag.

  • Macintosh systems do not support software OpenGL.

Software OpenGL can be slower than hardware-accelerated OpenGL and does not support all graphics features. For a table of supported features, see Advanced Graphics Features.

hardware — Hardware-accelerated OpenGLhardware

Hardware-accelerated OpenGL, specified as hardware. All systems support using the opengl hardware command to switch from basic hardware to hardware OpenGL. However, only Windows systems support using the opengl hardware command to switch from software to hardware OpenGL. To switch from software to hardware on Linux systems, start MATLAB with the -nosoftwareopengl flag.

hardwarebasic — Basic version of hardware-accelerated OpenGLhardwarebasic

Basic version of hardware-accelerated OpenGL, specified as hardwarebasic. This version of hardware-accelerated OpenGL uses your graphics hardware, but disables graphics features that are unstable with some graphics drivers. The disabled features might change in future releases as graphics features change and graphics hardware evolves. For a table of supported features, see Advanced Graphics Features.

pref — OpenGL version preference for future sessions'software' | 'hardware' | 'hardwarebasic' | 'none'

OpenGL version preference for future sessions, specified as one of these options:

  • 'software' — Software OpenGL. This option is not available on Macintosh systems.

  • 'hardware' — Hardware-accelerated OpenGL.

  • 'hardwarebasic' — Hardware-accelerated OpenGL with some advanced graphics features disabled. For more information, see Advanced Graphics Features.

  • 'none' — Default value for your system.

More About

expand all

Advanced Graphics Features

Advanced graphics features are features that require certain implementations of OpenGL. These features are graphics smoothing, depth peel transparency, and align vertex centers. Support for these features depends on:

  • Whether you are using hardware, basic hardware, or software OpenGL. To determine which implementation you are using, check the HardwareSupportLevel field returned by opengl info.

  • The version of the OpenGL implementation. To determine the version in use, check the Version field returned by opengl info. To get the latest version available for your graphics hardware, upgrade your graphics drivers from your computer manufacturer website. For more information on upgrading graphics drivers, see System Requirements for Graphics.

This table lists the advanced graphics features and the circumstances under which they are supported.

Graphics Feature Hardware OpenGLBasic Hardware OpenGLSoftware OpenGL on Windows
(Uses OpenGL 1.1)
Software OpenGL on Linux
(Uses OpenGL 2.1)
Graphics SmoothingSupported for OpenGL 2.1 or laterSupported for OpenGL 2.1 or laterNot supportedNot supported
Depth Peel TransparencySupported for OpenGL 2.1 or laterDisabledNot supportedSupported
Align Vertex CentersSupported for OpenGL 2.1 or laterDisabledNot supportedNot supported

Graphics Smoothing

Graphics smoothing is a technique to improve the appearance of plots by reducing the appearance of jagged lines. By default, this feature is enabled if your system supports it.

This table shows the difference when the feature is enabled versus disabled.

When Supported and EnabledWhen Not Supported or Disabled


(Zoomed-in view)


(Zoomed-in view)

To turn it off, set the GraphicsSmoothing property of the figure to 'off'.

Depth Peel Transparency

Depth peel transparency is a feature for correctly drawing transparent 3-D objects or complex plots that contain intersecting transparent objects. In the table, the left image shows the result of using transparency on a sphere when the depth peel transparency feature is supported. The right image shows the same sphere with unexpected shaded areas that occur when the feature is not supported.

When SupportedWhen Not Supported

Align Vertex Centers

Align vertex centers is a feature for sharp vertical and horizontal lines. If graphics smoothing is enabled, it can cause horizontal and vertical lines to appear uneven in thickness or color. The align vertex centers feature eliminates the uneven appearance. By default, the align vertex centers feature is not enabled. However, if your system supports this feature, then you can turn it on for objects that have an AlignVertexCenters property by setting the property to 'on'.

This table shows the difference when the feature is enabled versus disabled.

When Supported and EnabledWhen Not Supported or Disabled

Tips

  • Painters is an alternate rendering method for screen display and printing. For more information, see the figure's Renderer property.

  • By default, MATLAB uses hardware-accelerated OpenGL if your graphics hardware supports it. However, in some cases, MATLAB automatically switches to software OpenGL, for example, if it detects:

    • You are using a graphics driver with known issues or graphics virtualization.

    • A previous MATLAB session crashed due to a graphics issue.

    • You do not have graphics hardware or your graphics hardware does not support hardware OpenGL.

Introduced before R2006a

Was this topic helpful?