Jump to content

OPENGL.LIB

From EDM2

OPENGL.LIB is the import library for the OS/2 OpenGL implementation, distributed with the IBM OS/2 Developer's Toolkit. It combines three API layers in a single library: the core OpenGL 1.1 rendering API, the OpenGL Utility Library (GLU) 1.2, and the OS/2 Presentation Manager–specific platform extension layer (PGL) used to create and manage rendering contexts.

File size in the OS/2 Warp 4.52 Toolkit 4.5: 28,672 bytes (2000-10-16). Source DLL: OPENGL.DLL.

OS/2 OpenGL was IBM's port of OpenGL 1.1 to the Presentation Manager windowing system, delivered as part of OS/2 Warp 3 and Warp 4. It supports both software (indirect) rendering and, on equipped hardware, direct hardware-accelerated rendering.

API Layers

Prefix Count Layer Analogue on other platforms
pgl* 19 PGL platform extension — OS/2 PM context and window binding WGL (Windows), GLX (X11/Unix)
gl* ~300 Core OpenGL 1.1 API Standard on all OpenGL platforms
glu* ~45 OpenGL Utility Library (GLU) 1.2 Standard on all OpenGL platforms

All three layers are exported from the single DLL OPENGL.DLL. Applications link OPENGL.LIB and include the corresponding headers from the gl\ subdirectory of the Toolkit include path.

PGL — Presentation Manager GL Extension

PGL is the OS/2 equivalent of WGL on Windows or GLX on X11. It binds OpenGL rendering contexts to OS/2 PM windows and HDC device contexts.

Rendering context lifecycle

pglQueryConfigs(hdc, configs, maxConfigs, pNumConfigs)
Enumerates all available rendering configurations (pixel formats) for the device context hdc. Each configuration describes color depth, buffer presence, and rendering type. Fills configs with up to maxConfigs PGLCONF structures and sets *pNumConfigs to the total count.
pglChooseConfig(hdc, pAttribList, configs, maxConfigs, pNumConfigs)
Selects a configuration matching the attribute list pAttribList. The list is an array of PGL_* attribute/value pairs terminated by PGL_NONE. Common attributes:
  • PGL_BUFFER_SIZE — total color bits
  • PGL_LEVEL — overlay/underlay level (0 = normal)
  • PGL_RGBA — RGBA (not color-index) mode if TRUE
  • PGL_DOUBLEBUFFER — double-buffered if TRUE
  • PGL_DEPTH_SIZE — minimum depth buffer bits
  • PGL_STENCIL_SIZE — minimum stencil buffer bits
  • PGL_ACCUM_RED_SIZE — accumulation buffer red bits
pglCreateContext(hdc, config, shareContext, isDirect)
Creates an OpenGL rendering context (HGL) for device context hdc using the pixel format described by config (from pglChooseConfig). shareContext is another HGL whose display-list namespace is shared, or NULL. isDirect requests hardware-accelerated (direct) rendering; falls back to software if unavailable.
pglMakeCurrent(hwnd, hgl)
Makes hgl the current rendering context for the calling thread and binds it to window hwnd. All subsequent gl* and glu* calls operate on this context. Pass NULL for hgl to release the current context.
pglDestroyContext(hgl)
Destroys a rendering context and releases all its resources. The context must not be current when destroyed.
pglCopyContext(hglSrc, hglDst, mask)
Copies selected state from rendering context hglSrc to hglDst. mask is a bitmask of GL_*_BIT attrib group flags (e.g. GL_CURRENT_BIT, GL_TRANSFORM_BIT) identical to the mask passed to glPushAttrib.

Context queries

pglGetCurrentContext()
Returns the HGL of the rendering context current on the calling thread, or NULL if none.
pglGetCurrentWindow()
Returns the HWND of the window currently bound to the calling thread's rendering context, or NULLHANDLE if none.
pglIsIndirect(hgl)
Returns TRUE if hgl is an indirect (software) rendering context. Returns FALSE for direct (hardware-accelerated) contexts.
pglQueryCapability(hdc)
Returns a PGLCAP value indicating the OpenGL capability level of the device: PGLCAP_NONE (no OpenGL support), PGLCAP_ICD (hardware ICD available), or PGLCAP_MCD (mini client driver).
pglQueryVersion(hdc, pMajor, pMinor)
Returns the PGL version implemented on the device into *pMajor and *pMinor.

Synchronization

pglWaitGL()
Ensures that all pending OpenGL rendering commands have been sent to the hardware before returning. Used before PM drawing operations that must composite over finished GL output.
pglWaitPM()
Ensures that all pending PM drawing operations have completed before returning. Used before OpenGL rendering that reads back framebuffer content written by PM.

Buffer management

pglSwapBuffers(hwnd)
Exchanges the front and back color buffers for the double-buffered window hwnd. The back buffer content becomes visible; the front buffer becomes available for the next frame. Equivalent to SwapBuffers (WGL) or glXSwapBuffers (GLX).

Front buffer capture

pglGrabFrontBitmap(hwnd, ...)
Captures the current contents of the OpenGL front buffer as a PM bitmap. Returns a PM bitmap handle that can be used with GPI. The bitmap remains valid until pglReleaseFrontBitmap is called.
pglReleaseFrontBitmap(hwnd)
Releases the PM bitmap obtained from pglGrabFrontBitmap.

Font functions

pglUseFont(hdc, firstChar, count, listBase)
Creates count OpenGL display lists, starting at list number listBase, each of which draws a single character from the PM font currently selected into hdc. Characters begin at firstChar. The resulting display lists render characters as bitmap glyphs positioned at the current raster position.
pglUsePMBitmapFont(hdc, pszFacename, pointSize, firstChar, count, listBase)
Variant of pglUseFont that selects the PM font by face name and point size rather than using the font already selected into hdc.

Color-index palette

pglSelectColorIndexPalette(hwnd, hpal)
Installs PM logical palette hpal as the color-index palette for the OpenGL window hwnd. Used when the rendering context was created in color-index mode (PGL_RGBA = FALSE) and the application manages its own palette for indexed rendering.

Core OpenGL 1.1 (gl*)

The gl* functions implement the complete OpenGL 1.1 specification. They are standard across all OpenGL 1.1 implementations; the OS/2 versions are conformant to the OpenGL 1.1 specification published by Silicon Graphics in 1997.

Functional groups

Group Representative functions
Primitive assembly glBegin, glEnd, glVertex{2,3,4}{s,i,f,d}[v], glNormal3[bsifd][v], glColor{3,4}[bsifd][v], glTexCoord{1,2,3,4}[sifd][v], glIndex[sifd][v], glEdgeFlag[v]
Matrices glMatrixMode, glLoadIdentity, glLoadMatrix[fd], glMultMatrix[fd], glPushMatrix, glPopMatrix, glOrtho, glFrustum, glViewport, glRotate[fd], glTranslate[fd], glScale[fd]
Lighting glLight[fi][v], glLightModel[fi][v], glMaterial[fi][v], glColorMaterial, glShadeModel, glNormal3*
Texture mapping glTexImage1D, glTexImage2D, glTexParameter[fi][v], glTexEnv[fi][v], glTexGen[dfi][v], glGetTexImage, glGetTexLevelParameter[fi]v
Pixel operations glReadPixels, glDrawPixels, glCopyPixels, glBitmap, glRasterPos{2,3,4}[sifd][v], glPixelStore[fi], glPixelTransfer[fi], glPixelZoom, glPixelMap[fuius]v
Fragment tests glAlphaFunc, glBlendFunc, glDepthFunc, glDepthMask, glDepthRange, glStencilFunc, glStencilMask, glStencilOp, glScissor, glColorMask, glIndexMask, glLogicOp
Frame buffers glClear, glClearColor, glClearDepth, glClearIndex, glClearStencil, glClearAccum, glAccum, glDrawBuffer, glReadBuffer
Display lists glNewList, glEndList, glCallList, glCallLists, glListBase, glGenLists, glDeleteLists, glIsList
Evaluators glMap1[fd], glMap2[fd], glMapGrid1[fd], glMapGrid2[fd], glEvalCoord1[fd][v], glEvalCoord2[fd][v], glEvalMesh1, glEvalMesh2, glEvalPoint1, glEvalPoint2
Feedback / selection glFeedbackBuffer, glPassThrough, glSelectBuffer, glRenderMode, glInitNames, glPushName, glPopName, glLoadName
Fog glFog[fi][v]
Line / polygon glLineWidth, glLineStipple, glPointSize, glPolygonMode, glPolygonStipple, glGetPolygonStipple, glCullFace, glFrontFace, glClipPlane, glGetClipPlane
Attribute stacks glPushAttrib, glPopAttrib
Enable / disable glEnable, glDisable, glIsEnabled
State queries glGetBooleanv, glGetDoublev, glGetFloatv, glGetIntegerv, glGetString, glGetError, glGetLight[fi]v, glGetMaterial[fi]v, glGetMap[dfi]v, glGetTexEnv[fi]v, glGetTexGen[dfi]v, glGetTexParameter[fi]v
Flush / finish glFlush, glFinish
Geometry (inline) glRect[sifd][v]

Primitive type constants

Passed to glBegin: GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_QUADS, GL_QUAD_STRIP, GL_POLYGON.

GLU 1.2 (glu*)

The OpenGL Utility Library provides higher-level operations built on the core API.

Quadric surfaces

Quadrics render common geometric surfaces as OpenGL primitives. Each quadric object carries state for draw style, orientation, normal generation, and texture coordinates.

gluNewQuadric()
Allocates and returns a new GLUquadricObj.
gluDeleteQuadric(qobj)
Frees a quadric object.
gluQuadricDrawStyle(qobj, style)
Sets the rendering style: GLU_FILL (solid, shaded polygons), GLU_LINE (wire-frame), GLU_SILHOUETTE (outline only), GLU_POINT.
gluQuadricNormals(qobj, normals)
Controls normal generation: GLU_NONE, GLU_FLAT, or GLU_SMOOTH.
gluQuadricOrientation(qobj, orientation)
Sets face orientation: GLU_OUTSIDE or GLU_INSIDE.
gluQuadricTexture(qobj, textureCoords)
Enables (GL_TRUE) or disables texture coordinate generation on the quadric.
gluQuadricCallback(qobj, which, fn)
Registers an error callback (GLU_ERROR) for the quadric.
gluSphere(qobj, radius, slices, stacks)
Renders a sphere of radius centered at the origin with slices longitudinal and stacks latitudinal subdivisions.
gluCylinder(qobj, base, top, height, slices, stacks)
Renders an open cylinder along the positive Z axis.
gluDisk(qobj, inner, outer, slices, rings)
Renders a disk (annulus) in the XY plane.
gluPartialDisk(qobj, inner, outer, slices, rings, startAngle, sweepAngle)
Renders a partial disk (a sector of an annulus).

Mipmaps

gluBuild1DMipmaps(target, components, width, format, type, data)
Generates a complete mipmap chain for a 1D texture from data and loads all levels with glTexImage1D.
gluBuild2DMipmaps(target, components, width, height, format, type, data)
Generates and loads a complete mipmap chain for a 2D texture. The most commonly used GLU function for texture setup.
gluScaleImage(format, widthIn, heightIn, typeIn, dataIn, widthOut, heightOut, typeOut, dataOut)
Resamples an image to a new size using box filtering. Used to resize textures to power-of-two dimensions required by OpenGL 1.1.

Transformation utilities

gluPerspective(fovY, aspect, zNear, zFar)
Multiplies the current projection matrix by a perspective transformation. fovY is the vertical field of view in degrees; aspect is width/height.
gluLookAt(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ)
Multiplies the current matrix by a view transformation that places the camera at eye, looking at center, with the up direction up.
gluOrtho2D(left, right, bottom, top)
Sets up a 2D orthographic projection. (Calls glOrtho with zNear=-1 and zFar=1.)
gluProject(objX, objY, objZ, model, proj, viewport, winX, winY, winZ)
Projects an object-space point to window coordinates using the given model, projection, and viewport. Used to determine where a 3D point appears on screen.
gluUnProject(winX, winY, winZ, model, proj, viewport, objX, objY, objZ)
Inverse of gluProject: maps a window coordinate back to object space. Used for mouse picking.
gluPickMatrix(x, y, deltax, deltay, viewport)
Constructs a picking matrix that restricts rendering to a small region around point (x, y). Used together with GL_SELECT render mode for mouse-click object selection.

NURBS

gluNewNurbsRenderer()
Allocates a NURBS renderer object (GLUnurbsObj).
gluDeleteNurbsRenderer(nobj)
Frees a NURBS renderer.
gluNurbsProperty(nobj, property, value)
Sets a NURBS rendering property: GLU_SAMPLING_TOLERANCE, GLU_DISPLAY_MODE (GLU_FILL, GLU_OUTLINE_POLYGON, GLU_OUTLINE_PATCH), etc.
gluGetNurbsProperty(nobj, property, pValue)
Queries a NURBS property.
gluLoadSamplingMatrices(nobj, model, proj, viewport)
Supplies the current model-view, projection, and viewport to the NURBS renderer so it can compute adaptive sampling rates.
gluNurbsCurve(nobj, knotCount, knots, stride, ctlArray, order, type)
Defines a NURBS curve within a gluBeginCurve / gluEndCurve block.
gluNurbsSurface(nobj, sKnotCount, sKnots, tKnotCount, tKnots, sStride, tStride, ctlArray, sOrder, tOrder, type)
Defines a NURBS surface within a gluBeginSurface / gluEndSurface block.
gluPwlCurve(nobj, count, array, stride, type)
Defines a piecewise linear trim curve within a gluBeginTrim / gluEndTrim block.
gluNurbsCallback(nobj, which, fn)
Registers an error callback for the NURBS renderer.

Tessellator

gluNewTess()
Allocates a polygon tessellator (GLUtesselatorObj).
gluDeleteTess(tobj)
Frees a tessellator.
gluTessVertex(tobj, coords, vertexData)
Adds a vertex to the polygon being tessellated.
gluNextContour(tobj, type)
Begins a new contour within a polygon. type is GLU_EXTERIOR, GLU_INTERIOR, GLU_UNKNOWN, GLU_CCW, or GLU_CW.
gluTessCallback(tobj, which, fn)
Registers callbacks for tessellated output: GLU_BEGIN, GLU_VERTEX, GLU_END, GLU_ERROR, GLU_EDGE_FLAG.

Miscellaneous

gluErrorString(errCode)
Returns a human-readable string for a GL_* or GLU_* error code.
gluGetString(name)
Returns version and extension strings for the GLU implementation. name can be GLU_VERSION or GLU_EXTENSIONS.

Usage

IBM VisualAge C++ / ILINK

icc -O2 -Gm -c myapp.c
ilink /PM:PM myapp.obj os2386.lib opengl.lib

OpenWatcom (wlink)

wcl386 -bt=os2 -mf -c myapp.c
wlink system os2_pm file myapp.obj library os2386.lib library opengl.lib

EMX/GCC

gcc -Zomf -c myapp.c
gcc -Zomf -o myapp.exe myapp.o os2386.lib opengl.lib

Include files

Header Contents
gl\gl.h Core OpenGL 1.1 API: all gl* prototypes, type definitions (GLfloat, GLdouble, GLint, GLenum, GLbitfield, etc.), all GL_* constants.
gl\glu.h GLU 1.2 API: all glu* prototypes, GLU_* constants, GLUnurbsObj, GLUtesselatorObj, GLUquadricObj types.
gl\pgl.h PGL OS/2 extension: all pgl* prototypes, HGL handle type, PGLCONF, PGL_* attribute constants, PGLCAP_* constants.

PGL context setup skeleton

#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\pgl.h>

HGL hgl = NULL;

/* In WM_CREATE */
{
    int attribs[] = {
        PGL_RGBA, TRUE,
        PGL_DOUBLEBUFFER, TRUE,
        PGL_DEPTH_SIZE, 16,
        PGL_NONE
    };
    PGLCONF configs[16];
    int nConfigs;
    HDC hdc = WinOpenWindowDC(hwnd);
    pglChooseConfig(hdc, attribs, configs, 16, &nConfigs);
    hgl = pglCreateContext(hdc, &configs[0], NULL, TRUE);
    pglMakeCurrent(hwnd, hgl);
    /* OpenGL state initialization here */
}

/* In WM_PAINT / display callback */
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    /* draw scene */
    glFlush();
    pglSwapBuffers(hwnd);
}

/* In WM_DESTROY */
{
    pglMakeCurrent(NULLHANDLE, NULL);
    pglDestroyContext(hgl);
}

OS/2 OpenGL Extensions

The OS/2 OpenGL implementation supports the following GL_EXTENSIONS strings at the Warp 4.52 level (queried via glGetString(GL_EXTENSIONS)):

  • GL_EXT_bgra — BGRA pixel format for glTexImage2D and glReadPixels
  • GL_EXT_blend_color — constant blend color
  • GL_EXT_blend_logic_op — logic operations on blended pixels
  • GL_EXT_blend_minmax — min/max blend equations
  • GL_EXT_blend_subtract — subtract blend equations
  • GL_EXT_paletted_texture — color-index textures
  • GL_EXT_polygon_offset — depth offset for coplanar polygons
  • GL_EXT_texture3D — 3D textures

Version History

OpenGL version OS/2 release Date Notes
OpenGL 1.0 OS/2 Warp 3 (CSD or OpenGL feature pack) 1995 Initial OS/2 OpenGL port. Software rendering only on most hardware; IBM GRADD-based hardware acceleration optional. PGL context API established.
OpenGL 1.1 OS/2 Warp 4 1996 Updated to OpenGL 1.1: vertex arrays, texture objects, polygon offset, color logic ops, improved blending. OPENGL.DLL ships with OS/2 Warp 4 base.
OpenGL 1.1 + GLU 1.2 OS/2 Warp 4.52 Developer's Toolkit 4.5 2000 Final IBM release. GLU updated to 1.2 (revised tessellator API). File size: 28,672 bytes. No OpenGL 1.2+ support; IBM did not ship OpenGL 1.2 for OS/2.

Note: OS/2 OpenGL was never updated beyond 1.1 by IBM. Third-party OpenGL implementations for OS/2 (such as Mesa-based solutions and SNAP Graphics) may provide later versions with additional extensions but are separate from OPENGL.DLL.

See Also