| United States-English |
|
|
|
![]() |
HP VISUALIZE-IVL Documentation: HP 9000 Series 700 Computers > Chapter 4 Chapter 4: Interaction with the X Window SystemX Windows Capabilities |
|
This section describes the steps involved in setting up an IVL program in the X environment. It then describes some of the IVL-specific steps in more detail. Finally, it describes other, optional capabilities of IVL in an X environment. There are nine main steps for setting up an IVL application. They are listed below. (Note that it is good programming practice to check the return value from these functions and respond to any errors.)
See the sample code provided with IVL for source code that demonstrates these steps (though not necessarily in the exact order shown above). Over the years, a number of frame-buffer architectures with different capabilities have been developed:
To expose these different capabilities in a portable way, the X Window System introduced the concept of a visual type. There are six visual types in X: TrueColor, DirectColor, PseudoColor, StaticColor, GrayScale, and StaticGray. In the X environment, applications create windows (regions of the frame buffer that they can draw into) of a particular visual type. The visual type of a window defines its behavior in some important ways, and it is through this mechanism that frame buffer features are exposed and software portability is defined. To be specific, an XVisualInfo structure in X defines the visual type, screen, and depth of the window, as well as the number of bits of red, green, and blue information in a pixel. To achieve true portability, applications should work on systems that support any visual types that meet their minimum requirements. In the X Window System environment, IVL adds attributes to the X visual type. These attributes can be queried using routines defined by the GLX extension which provides support for IVL in the X environment. All visual types that are supported are defined within the X server and are reported back to the client at connection time. Since X does not return information about the extended attributes defined by IVL, it is quite possible that an X server will report two or more visuals that look identical to the client. However, these visual types will differ in the IVL attributes they support, and the differences may be ascertained using the IVL routines provided for this purpose. The easiest method to find a visual that meets your application's requirements is to use glXChooseVisual. This routine has its own prioritization algorithm to select the "best" visual from the list of attributes that you specify. If you wish to implement your own prioritization algorithm, use XGetVisualInfo and glXGetConfig. In order to render anything with IVL, you need to specify both a current rendering context and a current drawable (either a window or a GLX pixmap). The glXMakeCurrent routine accomplishes this. This routine seems a bit different from most other IVL routines in that it requires you to specify two separate pieces of state simultaneously. The reason this routine requires you to set the drawable and the rendering context simultaneously is that the two are related. When you create a rendering context, you must specify a visual type. This tells IVL that the rendering context will be used in conjunction with drawables of that type. The glXMakeCurrent routine checks to ensure that the rendering context you specify will work with the drawable you specify. If the drawable is not a visual type that will work with the rendering context you provide, IVL generates an error. With glXMakeCurrent, it is easy to change both the drawable and the rendering context at the same time. This is something that applications drawing into multiple windows may need to do quite often. If IVL required you to change the current rendering context and the current drawable with independent commands, there would be no way to change the current rendering context and the current drawable for use on a different visual type without generating an error. In order to eliminate the flicker effect caused by clearing and redrawing an image in a visible window, IVL supports the notion of double-buffering. Visuals that support double-buffering have two drawing buffers: a front buffer and a back buffer. The front buffer is displayed while rendering is occurring in the back buffer. When rendering is completed, use glXSwapBuffers to display the rendered image. Also, remember to set the current draw buffer using glDrawBuffer. There are three supported ways for IVL applications to perform double-buffering:
Please note that although MBX is supported with this release of IVL, it is not recommended. MBX has not been adopted as an industry standard, and it may become obsolete in the future. If you are currently using MBX, you should plan to migrate to one of the other double-buffering methods. Furthermore, note that the combination of glXSwapBuffers and DBE in the same application is not supported; you must choose one or the other. It is also possible to use IVL to render into off-screen memory. X pixmaps are the basis for supporting off-screen rendering. X is limited in that it does not define visual types for pixmaps. In X, pixmaps are not necessarily associated with a screen; they have a depth, but no visual type. Since IVL extends the notion of visual types by defining additional visual attributes, the definition of a pixmap is also extended. IVL does this by defining a superset of an X pixmap, called a GLX pixmap. Unlike an X pixmap, a GLX pixmap has a visual type, so it may contain the extended visual attributes defined by IVL. In order to use a pixmap as a rendering destination, it is necessary to enable it for rendering with IVL by calling glXCreateGLXPixmap. Once a GLX pixmap is no longer needed, deallocate it using glXDestroyGLXPixmap. For efficiency reasons, IVL contains the notion of a processing pipeline. For the most part, applications are shielded from the implementation details of this processing pipeline. However, since each stage of the pipeline takes finite time and could potentially involve some buffering, applications need a method to check that all the commands they have issued have completed. One way to achieve this is with the glFinish routine. This routine can be quite inefficient, so use it sparingly. It requires notification from the lowest levels of the rendering system that all the commands have been processed, all state changes have been fully realized, and that everything that should be displayed is displayed. It may be necessary to use glFinish in order to synchronize IVL rendering with rendering commands from Xlib or Motif. Sometimes it is only necessary to tell IVL to flush any/all internal command buffers so that all commands will be sent to the display hardware for processing. Use the glFlush routine to achieve this. This routine can be more efficient than glFinish. It does not wait until the results of all the commands are completed, but just issues commands to flush any and all buffers in the system so that all pending commands are at least queued up for processing. The results of subsequent rendering commands are guaranteed to complete in a finite amount of time after the issuing of a glFlush call. In a system with rendering hardware that is independent of the CPU, it may be possible for the CPU to continue processing while the rendering hardware completes processing the rendering commands. Therefore, applications should call glFlush rather than glFinish whenever possible. Note: the glFlush routine can be more efficient than glFinish, but should still be used sparingly for highest application performance. The following routines implicitly invoke glFlush:
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||