HP Workstation zx2000 OpenGL 1.1 Reference for HP-UX 11.x - Page 238
Overview, Examples
View all HP Workstation zx2000 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 238 highlights
I glXIntro 238 glXIntro glXIntro: Introduction to OpenGL in the X Window system. Overview OpenGL (called GL in other pages) is a high-performance 3D-oriented renderer. It is available in the X window system through the GLX extension. To determine whether the GLX extension is supported by an X server, and if so, what version is supported, call glXQueryExtension and glXQueryVersion. GLX extended servers make a subset of their visuals available for OpenGL rendering. Drawables created with these visuals can also be rendered using the core X renderer and with the renderer of any other X extension that is compatible with all core X visuals. GLX extends drawables with several buffers other than the standard color buffer. These buffers include back and auxiliary color buffers, a depth buffer, a stencil buffer, and a color accumulation buffer. Some or all are included in each X visual that supports OpenGL. To render using OpenGL into an X drawable, you must first choose a visual that defines the required OpenGL buffers. glXChooseVisual can be used to simplify selecting a compatible visual. If more control of the selection process is required, use XGetVisualInfo and glXGetConfig to select among all the available visuals. Use the selected visual to create both a GLX context and an X drawable. GLX contexts are created with glXCreateContext, and drawables are created with either XCreateWindow or glXCreateGLXPixmap. Finally, bind the context and the drawable together using glXMakeCurrent. This context/drawable pair becomes the current context and current drawable, and it is used by all OpenGL commands until glXMakeCurrent is called with different arguments. Both core X and OpenGL commands can be used to operate on the current drawable. The X and OpenGL command streams are not synchronized, however, except at explicitly created boundaries generated by calling glXWaitGL, glXWaitX, XSync, and glFlush. Examples Below is the minimum code required to create an RGBA-format, X window that's compatible with OpenGL and to clear it to yellow. The code is correct, but it does not include any error checking. Return values dpy, vi, cx, cmap, and win should all be tested. #include #include #include static int attributeListSgl[] = { GLX_RGBA, GLX_RED_SIZE, 1, /*get the deepest buffer with 1 red bit*/ GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, None}; static int attributeListDbl[] = { Chapter 9