Porting OpenGL Applications


OpenGL was originally developed by Silicon Graphics as a platform-independent set of graphics APIs. This has made OpenGL an attractive option for developers who want to target multiple platforms. Very little, if any, platform-specific code is necessary to move a graphics application from one platform to another. OpenGL extensions enable the segregation and handling of platform-specific code.

OpenGL is not, however, a set of windowing libraries. An OpenGL application with windows uses either the windowing system of the target platform (X Windows or Win32), or a cross-platform library such as the OpenGL Graphics Library Utility Kit (GLUT). Because of licensing concerns, however, most commercial applications incorporate the target platform windowing system. Therefore, when moving a UNIX application that uses OpenGL to Windows , migration considerations similar to those for a non-OpenGL application are likely to apply. The remainder of this section covers additional GUI considerations for the migration of OpenGL applications.

In addition to the windowing system itself, OpenGL applications require a context to the host windowing system. A special set of OpenGL extensions for window context has been developed. UNIX applications typically use the GLX OpenGL extensions for X Windows. Microsoft Windows-based applications typically use the WGL (wiggle) OpenGL extensions. In either case, these three main functions are required:

  • Create context

    • X Windows: glXCreateContext

    • Win32: wglCreateContext

  • Make context current

    • X Windows: glXMakeCurrent

    • Win32: wglMakeCurrent

  • Delete context

    • X Windows: glXDeleteContext

    • Win32: wglDeleteContext

If, after the migration, the application still needs support for UNIX, C/C++ pre-compiler directives ( #ifdef ) can be used to target the appropriate platform.

The OpenGL API is a C library on both UNIX and Windows. Fortran applications can also use OpenGL. To make it easier for Fortran applications to use OpenGL, a Fortran 90 Module often exists to handle the translation between Fortran and C calling conventions. Most Fortran compilers on Windows provide an optional Fortran module for OpenGL.

For more information about OpenGL and platform-specific examples, see the SGI OpenGL Web site ( http://www.sgi.com/software/opengl/ ) or the opengl.org Web site ( http://www.opengl.org/ ).




UNIX Application Migration Guide
Unix Application Migration Guide (Patterns & Practices)
ISBN: 0735618380
EAN: 2147483647
Year: 2003
Pages: 134

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net