Documentation Center

  • Trial Software
  • Product Updates
我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

opengl

Control OpenGL rendering

Syntax

opengl selection_mode
opengl info
s = opengl('data')
opengl software
opengl hardware
opengl verbose
opengl quiet
opengl DriverBugWorkaround
opengl('DriverBugWorkaround',WorkaroundState)

Description

opengl selection_mode determines how MATLAB® selects the OpenGL® renderer. Possible values for selection_mode are

  • autoselect – allows OpenGL to be automatically selected if OpenGL is available and if there is graphics hardware on the host machine.

  • neverselect – disables autoselection of OpenGL.

  • advise – prints a message to the command window if OpenGL rendering is advised, but RenderMode is set to manual.

opengl, by itself, returns the current autoselection state.

Note that the autoselection state only specifies whether OpenGL should or should not be considered for rendering; it does not explicitly set the rendering to OpenGL. You can do this by setting the Renderer property of the figure to OpenGL. For example,

set(figure_handle,'Renderer','OpenGL')

    Note:   The OpenGL autoselection mode applies when the RendererMode of the figure is auto

opengl info prints information with the version and vendor of the OpenGL on your system. Also indicates whether your system is currently using hardware or software OpenGL and the state of various driver bug workarounds. Note that calling opengl info loads the OpenGL Library.

For example, the following output is generated on a Windows® computer:

>> opengl info
              Version: '3.3.0'
               Vendor: 'NVIDIA Corporation'
             Renderer: 'Quadro 400/PCI/SSE2'
       MaxTextureSize: 8192
               Visual: ''
             Software: ''
           Extensions: {235x1 cell}
   MaxFrameBufferSize: 8192

Note that different computer systems may not list all OpenGL bugs.

s = opengl('data') returns a structure containing the same data that is displayed when you call opengl info, with the exception of the driver bug workaround state.

opengl software forces the MATLAB software to use software OpenGL rendering instead of hardware OpenGL. Note that Macintosh systems do not support software OpenGL.

opengl hardware reverses the opengl software command and enables MATLAB to use hardware OpenGL rendering if it is available. If your computer does not have OpenGL hardware acceleration, MATLAB automatically switches to software OpenGL rendering (except on Macintosh systems, which do not support software OpenGL).

Note that on UNIX® systems, the software or hardware options with the opengl command works only if MATLAB has not yet used the OpenGL renderer or you have not issued the opengl info command (which attempts to load the OpenGL Library).

opengl verbose displays verbose messages about OpenGL initialization (if OpenGL is not already loaded) and other runtime messages.

opengl quiet disables verbose message setting.

opengl DriverBugWorkaround queries the state of the specified driver bug workaround. Use the command opengl info to see a list of all driver bug workarounds. See Driver Bug Workarounds for more information.

opengl('DriverBugWorkaround',WorkaroundState) sets the state of the specified driver bug workaround. You can set WorkaroundState to one of three values:

  • 0 – Disable the specified DriverBugWorkaround (if enabled) and do not allow MATLAB to autoselect this workaround.

  • 1 – Enable the specified DriverBugWorkaround.

  • -1 – Set the specified DriverBugWorkaround to autoselection mode, which allows MATLAB to enable this workaround if the requisite conditions exist.

Driver Bug Workarounds

    Note:   Always check with your graphics hardware vendor to ensure you are using the latest driver software. Use the opengl info command to see your current version number.

The MATLAB software enables various OpenGL driver bug workarounds when it detects certain known problems with installed hardware. However, because there are many versions of graphics drivers, you might encounter situations when MATLAB does not enable a workaround that would solve a problem you are having with OpenGL rendering.

This section describes the symptoms that each workaround is designed to correct so you can decide if you want to try using one to fix an OpenGL rendering problem.

Use the opengl info command to see what driver bug workarounds are available on your computer.

    Note   These workarounds have not been tested under all driver combinations and therefore might produce undesirable results under certain conditions.

OpenGLBitmapZbufferBug

Symptom: text with background color (including data tips) and text displayed on image, patch, or surface objects is not visible when using OpenGL renderer.

Possible side effect: text is always on top of other objects.

Command to enable:

opengl('OpenGLBitmapZbufferBug',1)

OpenGLWobbleTesselatorBug

Symptom: Rendering complex patch object causes segmentation violation and returns a tesselator error message in the stack trace.

Command to enable:

opengl('OpenGLWobbleTesselatorBug',1)

OpenGLLineSmoothingBug

Symptom: Lines with a LineWidth greater than 3 look bad.

Command to enable:

opengl('OpenGLLineSmoothingBug',1)

OpenGLDockingBug

Symptom: MATLAB crashes when you dock a figure that has its Renderer property set to opengl.

Command to enable:

opengl('OpenGLDockingBug',1)

OpenGLClippedImageBug

Symptom: Images (as well as colorbar displays) do not display when the Renderer property set to opengl.

Command to enable:

opengl('OpenGLClippedImageBug',1)

OpenGLEraseModeBug

Symptom: Graphics objects with EraseMode property set to non-normal erase modes (xor, none, or background) do not draw when the figure Renderer property is set to opengl.

Command to enable:

opengl('OpenGLEraseModeBug',1)

See Also

Was this topic helpful?