Documentation

This document does not explain how to use Glide, or what the functions do.
You cannot really use this library without also getting the Glide 3.0 SDK, with a full Glide tutorial and reference guide included.
Visit the 3DFX web site to download it.

Modules

PyGlide has two modules - the pyglide module, written in C, which interfaces directly to the Glide library, and the Python module glide, which contains these functions, plus all the constant values from the C header files.

The recommended interface is to use the glide module and not touch the pyglide module at all - it is a private module that only the glide module uses. Note there is no gain in speed from referencing the C module directly.

Note that the prefixes are still kept in the modules, so grGlideInit becomes glide.grGlideInit and not glide.glideInit.

Exceptions

PyGlide functions can throw some standard Python exceptions, but have no user-defined exceptions. The exceptions they may throw are:

MemoryError means that there was not enough memory to convert the parameters into C types.
ValueError means that PyGlide needs to recognise the parameters in order to convert the data properly (as in grGet etc) and it cannot do so.
TypeError means that PyGlide cannot convert the arguments passed to it into C types.

Function Doc-Strings

The docstring to each pyglide function provides a quick reference to the parameters needed for that function.
From the Python interpreter you can type e.g. glide.grSstSelect.__doc__ to see the parameters to the grSstSelect function.

Function Parameters

Most of the Glide functions have simple signatures with integer or floating-point parameters (all the Glide enumerations are represented in PyGlide as integers) and either void, integer or float return values.
The signatures of these functions are mapped directly to the Python equivalents.
Boolean values are passed as Python integers (0 for false, anything else for true) - other values such as lists are not recognised.
Those functions which have not been converted directly are documented below.

grDrawPoint(vert1)
grDrawLine(vert1, vert2)
grDrawTriangle(vert1, vert2, vert3)
grAADrawTriangle(vert1, vert2, vert3, antialiasAB, antialiasBC, antialiasCA)
grDrawVertexArray(mode, vertlist)

vert1, vert2 and vert3 are a list/tuple of Python numbers (anything convertable to an integer or float), the format of which is specified by the grVertexLayout function.
Note that only lists and tuples are recognised, user-defined sequence types will cause a TypeError.
vertlist is a sequence of vertices, where each vertex has the list-type specified above.
At the moment there is a maximum of 32 parameters per vertex (due to the conversion method)

grVertexLayout(param, offset, enabled)

Like the Glide grVertexLayout function, this specifies the organisation of the vertices passed to the grDraw... functions.
offset is an index into the vertex lists between 0 and 31 specifying where that parameter appears. (no need to multiply by sizeof(float))

For example, after the initialisation:

glide.grVertexLayout(glide.GR_PARAM_XY, 0, glide.GR_PARAM_ENABLE)
glide.grVertexLayout(glide.GR_PARAM_PARGB, 2, glide.GR_PARAM_ENABLE)

now vertex lists are in the format [x, y, pargb] assuming all other parameters are disabled.

See the C Glide API for a description on how this works in C.

grFogTable(list)

list - Python sequence of integers for fog table entries. The size of list should be
equal to glide.grGet(glide.GR_FOG_TABLE_ENTRIES).

param = grGet(paramnum)

Returns the parameter named by paramnum (an integer, one of the GR_ constants)
Only works for parameters mentioned in the Glide 3.0 reference manual.
Most parameters return a single integer.
GR_FIFO_FULLNESS, GR_VIDEO_POSITION, GR_ZDEPTH_MIN_MAX and GR_WDEPTH_MIN_MAX return a list of two integers.
GR_VIEWPORT and GR_BITS_RGBA return a list of four integers.
Unrecognised values cause a ValueError exception.

string = grGetString(paramnum)

Returns a Python string corresponding to Glide string parameter paramnum, or throws a ValueError if the parameter is not recognised.

state = grGetState()
grSetState(state)
layout = grGetVertexLayout()
grSetVertexLayout(layout)

layout and state are strings containing the bytes of data returned by Glide.
Note that the layout value contains extra information added by the PyGlide library
itself.

data = grLfbReadRegion(sourceBuffer, x, y, width, height, stride)

Returns a string containing the screen data corresponding to a particular region of one of the buffers. All other parameters are same as C Glide API.

grLfbWriteRegion(buffer, x, y, sourceFormat, width, height, usePipeline, stride, data)

 Writes the image contained in string data to the Glide buffer. All other parameters are as in C Glide API.

grTexDownloadMipMap(tmu, textureMemAddress, evenOdd, smallLOD, largeLOD, aspect, format, data)
grTexDownloadMipMapLevel(tmu, textureMemAddress, thisLOD, largeLOD, aspect, format, evenOdd, data)
result = grTexDownloadMipMapLevelPartial(tmu, textureMemAddress, thisLOD, largeLOD, aspect, format, evenOdd, data, start, end)

The GrTexInfo parameter from the C API has been extracted, the relevant structure fields are passed directly to the function.
data is a Python string containing the texture data you wish to download.

grTexDownloadTable(tableType, dataList)

If table is GR_TEXTABLE_NCC?, then dataList should be a list of the elements of a GuNccTable structure.
If table is GR_TEXTABLE_PALETTE or GR_TEXTABLE_PALETTE_6666_EXT then dataList should be a list of the 32-bit palette entries.

grTexDownloadTablePartial(tableType, dataList, start, end)

Table should be same format as palette table above. First entry in list is interpreted as colour number start in the palette.

grTexSource(tmu, texAddress, evenOdd, LODmin, LODmax, aspect, format)
mem = grTexTextureMemRequired(evenOdd, LODmin, LODmax, aspect, format)
grTexMultibaseAddress(tmu, range, startAddress, evenOdd, minLOD, maxLOD, aspect, format)

The GrTexInfo parameter has been removed, and the relevant structure members have been placed directly into the argument list.

grLfbLock() - NOT IMPLEMENTED
grLfbUnlock() - NOT IMPLEMENTED

Not implemented, since you can't write directly to memory in Python anyway.
I may write an indirect binding to these methods later once I have decided on the best way to do it.

tuple = grQueryResolutions(resolution, refresh, numColourBuffers, numAuxBuffers)

All parameters are entries to the GrResolution structure passed to the C function.
Use glide.GR_QUERY_ANY to specify no constraint on a parameter.
Each entry in the return tuple is a tuple in the format (resolution, refresh, numColorBuffers, numAuxBuffers)

grLoadGammaTable(redlist, greenlist, bluelist)

Parameters are lists of integers interpreted as 32-bit gamma values.

grGetProcAddress(procName) - NOT IMPLEMENTED

Not implemented, since you couldn't do a lot with the procedure address once you got it.