Solaris OpenGL1.1 Implementation and Performance Guide
只搜寻这本书
以 PDF 格式下载本书

Tips and Techniques

5

This chapter presents miscellaneous topics that you may find useful as you port your application to the Solaris OpenGL software.

Identifying the Solaris OpenGL Library Version

You can identify the library version number and build date of the OpenGL library components (libGL.so, libGLU.so, libGLw.so, SUNWGLX.so) using the what(1) command. For example, any of the following commands:
% what /usr/openwin/lib/libGL.so
% what /usr/openwin/lib/libGLU.so
% what /usr/openwin/lib/libGLw.so
% what /usr/openwin/server/modules/SUNWGLX.so.1

would result in something like:
RELEASE VERSION: SUNWglrt Solaris OpenGL version 1.1, libGL.so.1,
sparc, [build date]
RELEASE VERSION: SUNWglrt Solaris OpenGL version 1.1, libGLU.so.1,
sparc, [build date]
RELEASE VERSION: SUNWglwrt Solaris OpenGL version 1.1, libGLw.so.1,
sparc, [build date]
RELEASE VERSION: SUNWglrt Solaris OpenGL version 1.1, SUNWGLX.so.1,
sparc, [build date]

This identifies the OpenGL component to be Solaris OpenGL version 1.1 built on the specified build date.

Avoiding Overlay Colormap Flashing

Colormap flashing may occur when your application uses overlay windows. This problem stems from several characteristics of the Creator3D system: the overlay visual is not the default visual, the Creator3D is a single hardware colormap device, and X11 allocates colormap cells from pixel 0 upward. When the application renders to the overlay window, it must use a non-default visual, and a non-default colormap is loaded. In this case, colormap flashing between the default and non-default colormaps can occur.
The best solution to this problem is to allocate the overlay colors at the high end of the overlay colormap. In other words, if you have n colors to allocate, allocate them in the positions colormap_size -n -1 to colormap_size -1.This avoids the colors in the default colormap, which are allocated upward starting at 0. To allocate n colors at the top of the overlay colormap, first allocate colormap_size-n read/write placeholder cells using XAllocColorCells. Then allocate the n overlay colors using XAllocColor. Finally, free the placeholder cells. This solution is portable; it works on both single- and multiple-hardware colormap devices.

Changing the Limitation on the Number of Simultaneous GLX Windows

There is a limitation on the number of GLX windows that an application can use simultaneously. Each GLX window that has an attached GLX context uses a file descriptor for DGA (Direct Graphics Access) information. You can find the current number of open file descriptors using the limit(1) command:
% limit descriptors
descriptors 64

The system response tells you that you have up to 64 direct GLX contexts, assuming that you have no other processes concurrently using file descriptors.
You can increase the per-process maximum number of open file descriptors using the limit command as follows:
% limit descriptors 128

This command changes the number of file descriptors available for DGA and other uses to 128. Use the sysdef(1M) command to determine the maximum number of file descriptors for your system.

Hardware Window ID Allocation Failure Message

On Creator3D, when a program calls glXMakeCurrent(3gl) to make a window the current OpenGL drawable, the system will attempt to allocate a unique hardware window ID (WID) for the window. This allows double buffering and hardware WID clipping to be used. Because hardware WIDs are a scarce resource and can be used for other purposes, there might not be any WIDs available when glXMakeCurrent is called. If this should happen, the following message is displayed:
OpenGL/FFB Warning: unable to allocate hardware window ID

In this situation, double buffering will not be provided for the window, and the window will be treated as a single-buffered window.

Getting Peak Frame Rate

The frame rate that ogl_install_check prints out is symchronized to monitor frequency. It measures the time it takes to render the frame, wait for vblank, then swap the buffers. Since FFB can render the ogl_install_check image very quickly, even on an FFB1 Electron 167 mhz machine, the bottleneck is waiting for the monitor vblank. So, under normal circumstances, ogl_install_check is never going to be able to get a frame rate faster than the monitor frequency.
However, there is an environment variable called OGL_NO_VBLANK that you can set to see the peak, unsynchronized frame rate. When set, this environment variable swaps buffers immediately, without waiting for vblank.

Frequently Asked Questions

How can I find out the Release Version Number of the OpenGL Library I am using?
You can identify the Release Version Number of the OpenGL Library by:
  1. Using the what(1) or mcs(1) command:

% what /usr/openwin/lib/libGL.so.1
% mcs -p /usr/openwin/lib/libGL.so.1

  1. Programatically, by calling glGetString (GL_VERSION)

(see the glGetString man page for more details)
  1. Running the Solaris OpenGL install_check demo program:

% /usr/openwin/demo/GL/ogl_install_check

What is the maximum number of GLX windows that can be used simultaneously?
Each window that is created and to which a GLX context is attached uses a file descripter of Direct Graphics Access (DGA) information. The per-process maximum number of open file descriptors can be found, and changed, using the filename command:
% limit descriptors
descriptors 64

This implies you have up to 64 direct GLX contexts (assuming you have other things in that process that use up file descriptors).
This limit can be increased by typing:
% limit descriptors 128

This will increase the number of file descriptors available for DGA use and other uses to 128. The sysdef(1M) command will tell you what the maximum number of file descriptors is, along with other information.
In addition to the limit on descriptors, there is a limit on the number of hardware double-buffered windows. On Creator3D, you have up to 32 double-buffered windows. Beyond that, OpenGL defaults to single-buffered mode.
The Creator3D graphics accelerator supports only double-buffered visuals. I want to use single-buffer behavior. How can I do this?
You can simulate single-buffer behavior using double-buffered context by calling glDrawBuffer (GL_FRONT) and avoiding calls to glXSwapBuffers.