_sgl_ _opengl_ _sgl.ss_ _gl_ _gl.ss_ _gl-unsafe_ _gl-unsafe.ss_ _gl-vectors_ _gl-vectors.ss_


GL bindings for PLT Scheme

sgl provides access to the system's GL libraries.  sgl supports the
functionality of GL version 1.3 and before.  If a function defined in
1.3 is used on a system that supports only a previous version (1.2, 1.1)
a runtime error will be signaled.  GLenum constansts that are not
defined on the system have a value of -1.  The GL library does not
address the way in which GL rendering contexts are attached to displays
and other system level concerns.  The GL library is only concerned
rendering.  Thus sgl should work with any other PLT Scheme extension
that provides GL with access to the system (such as a binding for glx).
mred (and hence DrScheme) currently supports this type of functionality
on Windows, Linux and OS X systems.

sgl takes a two layered approach.  The gl and gl-unsafe libraries
provide access to the C-language style GL API.  The sgl library provides
access to the GL API through a more Scheme-like interface, that should
be more convenient to use than the C-style bindings.

sgl also defines a homogeneous vector extension to support GL functions
that consume array arguments.


Many thanks to Robert Kooima who wrote the GL binding that the gl and
gl-unsafe modules are based on.

_gl-vectors.ss_

The gl-vectors module provides homogeneous vectors of the different
numeric types.  10 functions are provided for each of 9 types of
vectors, gl-double-vector, gl-float-vector, gl-int-vector,
gl-short-vector, gl-byte-vector, gl-uint-vector, gl-ushort-vector,
gl-ubyte-vector, gl-boolean-vector.

The functions are as follows (replacing [type] with double, float,
etc...):

(vector->gl-[type]-vector v): takes a Scheme vector and converts it to a
gl-[type]vector.  Fails if v is not a vector containing only Scheme real
numbers.

(gl-[type]-vector->vector v): Takes a gl-[type]-vector and returns a
Scheme vector with the same numbers.

(gl-[type]-vector-ref v i): Returns the ith element of v.  Fails if i >=
the length of v.

(gl-[type]-vector-set! v i n): Sets n to be the ith element of
gl-[type]-vector v.  Fails if i >= length of v or if n is not a Scheme
real number.

(gl-[type]-vector-length v): Returns the number of elements in
gl-[type]-vector v.

(gl-[type]-vector? v): Return #t if v is a gl-[type]-vector.  Returns #f
otherwise.

(gl-[type]-vector+ v1 v2): Returns a new gl-[type]-vector that is the
element-by-element sum of gl-[type]-vectors v1 and v2.

(gl-[type]-vector- v1 v2): Returns a new gl-[type]-vector that is the
element-by-element difference of gl-[type]-vectors v1 and v2.

(gl-[type]-vector* r v): Returns a new gl-[type]-vector with element i
equal to r times the ith element of gl-[type]-vector v.

(gl-[type]-vector-norm v): Returns the square root of the sum of the
squares of the elements of gl-[type]-vector v.

_gl.ss_

Use the gl module by adding (require (lib "gl.ss" "gl")) to your
program.  gl provides a direct interface to the systems underlying
interface closely following the conventions of the C-language GL API.
However, the functions provided by the gl module check the types of
their arguments and the size of their array arguments and signal an
error if the they are incorrect.

Examples:
(require (lib "gl.ss" "sgl")
         (lib "gl-vectors.ss" "sgl"))
(glBegin GL_TRIANGLES)
(glVertex3i 1 2 3)
(glVertex4fv (vector->gl-float-vector (vector 1 2 3 4)))
(glEnd)

_gl-unsafe.ss_

Use the gl-unsafe module by adding (require (lib "gl-unsafe.ss" "gl"))
to your program.  The gl-unsafe module follows the conventions of the gl
module except that function arguments are not necessarily checked, so an
incorrect call to a gl-unsafe function could crash the entire Scheme
system.  gl-unsafe consists of the GL functions that are not in gl
because appropriate checks have not been added to them or appropriate
checks cannot be added to them.

_sgl.ss_

Use the sgl module by adding (require (lib "sgl.ss" "sgl)) tp your
program.  To prefix the function names with "gl-" use the form
(require (prefix gl- (lib "sgl.ss" "sgl"))) instead.  sgl provides a more
Scheme-like interface to the GL functions in gl (sgl does not provide an
interface to the functions of gl-unsafe).

Arguments to GL functions that receive enumerated constants must be
passed Scheme symbols instead of integers as in the C-language API.
These symbolic arguments are checked to ensure that the given symbol is
an appropriate value for that particular function.  Given the name of a
C-language #define constant, the corresponding symbolic argument is
determined by removing the leading "GL_", converting the letters to
lower-case and replacing all underscores with dashes.  For example:
GL_TRIANGLES becomes 'triangles and GL_TRIANGLE_STRIP becomes
'triangle-strip.

Functions have also been renamed.  The leading "gl" has been dropped
(allowing the programmer to choose whatever prefix he wants with the
above prefix form of require), all the characters have been converted to
lower-case and subsequent words are separated with dashes. Furthermore,
functions that have several variants to accomodate different numbers and
types of arguments have been collapsed into one or two functions.  For
example, sgl provides two vertex functions, vertex and vertex-v.  Vertex
can be passed 2, 3 or 4 numerical arguments, and vertex-v can be passed
a gl-vector argument of length 2, 3 or 4.

The sgl module is still not yet complete and many functions from the gl
module do not yet have counterparts in the sgl module.

Examples:
(require (prefix gl- (lib "gl.ss" "sgl"))
         (lib "gl-vectors.ss" "sgl"))
(gl-begin 'triangles)
(gl-vertex 1 2 3)
(gl-vertex-v (vector->gl-float-vector (vector 1 2 3 4)))
(gl-end)



Function lists:

-----------------------------  sgl: -------------------------------


active-texture
are-textures-resident
begin
bitmap
call-list
clear
clear-accum
clear-color
clear-depth
clear-index
clear-stencil
client-active-textures
clip-plane
color
color-mask
color-material
color-v
cull-face
delete-lists
delete-textures
depth-mask
depth-range
disable
disable-client-state
edge-flag
edge-flag-v
enable
enable-client-state
end
end-list
eval-coord
eval-coord-v
finish
flush
front-face
frustum
gen-lists
gen-textures
get-error
get-string
index
index-mask
index-v
init-names
is-list
is-texture
light
light-model
light-model-v
light-v
line-stipple
line-width
list-base
load-identity
load-matrix
load-name
load-transpose-matrix
material
material-v
matrix-mode
mult-matrix
mult-transpose-matrix
new-list
normal
normal-v
ortho
pass-through
pixel-zoom
point-size
polygon-mode
polygon-offset
polygon-stipple
pop-attrib
pop-client-attrib
pop-matrix
pop-name
prioritize-textures
push-matrix
push-name
raster-pos
raster-pos-v
rect
rect-v
rotate
scale
scissor
select-buffer
shade-model
stencil-mask
tex-coord
tex-coord-v
translate
vertex
vertex-v
viewport


------------------------------  gl:  ------------------------------
Version 1.1
glAccum
glAlphaFunc
glAreTexturesResident
glBegin
glBindTexture
glBitmap
glBlendFunc
glCallList
glCallLists
glClear
glClearAccum
glClearColor
glClearDepth
glClearIndex
glClearStencil
glClipPlane
glColor3b
glColor3bv
glColor3d
glColor3dv
glColor3f
glColor3fv
glColor3i
glColor3iv
glColor3s
glColor3sv
glColor3ub
glColor3ubv
glColor3ui
glColor3uiv
glColor3us
glColor3usv
glColor4b
glColor4bv
glColor4d
glColor4dv
glColor4f
glColor4fv
glColor4i
glColor4iv
glColor4s
glColor4sv
glColor4ub
glColor4ubv
glColor4ui
glColor4uiv
glColor4us
glColor4usv
glColorMask
glColorMaterial
glCopyPixels
glCopyTexImage1D
glCopyTexImage2D
glCopyTexSubImage1D
glCopyTexSubImage2D
glCullFace
glDeleteLists
glDeleteTextures
glDepthFunc
glDepthMask
glDepthRange
glDisable
glDisableClientState
glDrawBuffer
glDrawPixels
glEdgeFlag
glEdgeFlagv
glEnable
glEnableClientState
glEnd
glEndList
glEvalCoord1d
glEvalCoord1dv
glEvalCoord1f
glEvalCoord1fv
glEvalCoord2d
glEvalCoord2dv
glEvalCoord2f
glEvalCoord2fv
glEvalMesh1
glEvalMesh2
glEvalPoint1
glEvalPoint2
glFeedbackBuffer
glFinish
glFlush
glFogf
glFogfv
glFogi
glFogiv
glFrontFace
glFrustum
glGenLists
glGenTextures
glGetClipPlane
glGetError
glGetLightfv
glGetLightiv
glGetMaterialfv
glGetMaterialiv
glGetPolygonStipple
glGetString
glHint
glIndexMask
glIndexd
glIndexdv
glIndexf
glIndexfv
glIndexi
glIndexiv
glIndexs
glIndexsv
glIndexub
glIndexubv
glInitNames
glIsEnabled
glIsList
glIsTexture
glLightModelf
glLightModelfv
glLightModeli
glLightModeliv
glLightf
glLightfv
glLighti
glLightiv
glLineStipple
glLineWidth
glListBase
glLoadIdentity
glLoadMatrixd
glLoadMatrixf
glLoadName
glLogicOp
glMap1d
glMap1f
glMap2d
glMap2f
glMapGrid1d
glMapGrid1f
glMapGrid2d
glMapGrid2f
glMaterialf
glMaterialfv
glMateriali
glMaterialiv
glMatrixMode
glMultMatrixd
glMultMatrixf
glNewList
glNormal3b
glNormal3bv
glNormal3d
glNormal3dv
glNormal3f
glNormal3fv
glNormal3i
glNormal3iv
glNormal3s
glNormal3sv
glOrtho
glPassThrough
glPixelMapfv
glPixelMapuiv
glPixelMapusv
glPixelStoref
glPixelStorei
glPixelTransferf
glPixelTransferi
glPixelZoom
glPointSize
glPolygonMode
glPolygonOffset
glPolygonStipple
glPopAttrib
glPopClientAttrib
glPopMatrix
glPopName
glPrioritizeTextures
glPushAttrib
glPushClientAttrib
glPushMatrix
glPushName
glRasterPos2d
glRasterPos2dv
glRasterPos2f
glRasterPos2fv
glRasterPos2i
glRasterPos2iv
glRasterPos2s
glRasterPos2sv
glRasterPos3d
glRasterPos3dv
glRasterPos3f
glRasterPos3fv
glRasterPos3i
glRasterPos3iv
glRasterPos3s
glRasterPos3sv
glRasterPos4d
glRasterPos4dv
glRasterPos4f
glRasterPos4fv
glRasterPos4i
glRasterPos4iv
glRasterPos4s
glRasterPos4sv
glReadBuffer
glReadPixels
glRectd
glRectdv
glRectf
glRectfv
glRecti
glRectiv
glRects
glRectsv
glRenderMode
glRotated
glRotatef
glScaled
glScalef
glScissor
glSelectBuffer
glShadeModel
glStencilFunc
glStencilMask
glStencilOp
glTexCoord1d
glTexCoord1dv
glTexCoord1f
glTexCoord1fv
glTexCoord1i
glTexCoord1iv
glTexCoord1s
glTexCoord1sv
glTexCoord2d
glTexCoord2dv
glTexCoord2f
glTexCoord2fv
glTexCoord2i
glTexCoord2iv
glTexCoord2s
glTexCoord2sv
glTexCoord3d
glTexCoord3dv
glTexCoord3f
glTexCoord3fv
glTexCoord3i
glTexCoord3iv
glTexCoord3s
glTexCoord3sv
glTexCoord4d
glTexCoord4dv
glTexCoord4f
glTexCoord4fv
glTexCoord4i
glTexCoord4iv
glTexCoord4s
glTexCoord4sv
glTexEnvf
glTexEnvfv
glTexEnvi
glTexEnviv
glTexGend
glTexGendv
glTexGenf
glTexGenfv
glTexGeni
glTexGeniv
glTexImage1D
glTexImage2D
glTexParameterf
glTexParameterfv
glTexParameteri
glTexParameteriv
glTexSubImage1D
glTexSubImage2D
glTranslated
glTranslatef
glVertex2d
glVertex2dv
glVertex2f
glVertex2fv
glVertex2i
glVertex2iv
glVertex2s
glVertex2sv
glVertex3d
glVertex3dv
glVertex3f
glVertex3fv
glVertex3i
glVertex3iv
glVertex3s
glVertex3sv
glVertex4d
glVertex4dv
glVertex4f
glVertex4fv
glVertex4i
glVertex4iv
glVertex4s
glVertex4sv
glViewport

Version 1.2
glBlendColor
glBlendEquation
glColorSubTable
glColorTable
glColorTableParameterfv
glColorTableParameteriv
glConvolutionFilter1D
glConvolutionFilter2D
glConvolutionParameterf
glConvolutionParameterfv
glConvolutionParameteri
glConvolutionParameteriv
glCopyColorSubTable
glCopyColorTable
glCopyConvolutionFilter1D
glCopyConvolutionFilter2D
glCopyTexSubImage3D
glGetColorTableParameterfv
glGetColorTableParameteriv
glGetConvolutionParameterfv
glGetConvolutionParameteriv
glGetHistogramParameterfv
glGetHistogramParameteriv
glGetMinmaxParameterfv
glGetMinmaxParameteriv
glHistogram
glMinmax
glResetHistogram
glResetMinmax
glSeparableFilter2D
glTexImage3D
glTexSubImage3D

Version 1.3
glActiveTexture
glClientActiveTexture
glLoadTransposeMatrixd
glLoadTransposeMatrixf
glMultTransposeMatrixd
glMultTransposeMatrixf
glMultiTexCoord1d
glMultiTexCoord1dv
glMultiTexCoord1f
glMultiTexCoord1fv
glMultiTexCoord1i
glMultiTexCoord1iv
glMultiTexCoord1s
glMultiTexCoord1sv
glMultiTexCoord2d
glMultiTexCoord2dv
glMultiTexCoord2f
glMultiTexCoord2fv
glMultiTexCoord2i
glMultiTexCoord2iv
glMultiTexCoord2s
glMultiTexCoord2sv
glMultiTexCoord3d
glMultiTexCoord3dv
glMultiTexCoord3f
glMultiTexCoord3fv
glMultiTexCoord3i
glMultiTexCoord3iv
glMultiTexCoord3s
glMultiTexCoord3sv
glMultiTexCoord4d
glMultiTexCoord4dv
glMultiTexCoord4f
glMultiTexCoord4fv
glMultiTexCoord4i
glMultiTexCoord4iv
glMultiTexCoord4s
glMultiTexCoord4sv
glSampleCoverage

------------------------------  gl-unsafe:  --------------------------
Version 1.1
glEdgeFlagPointer
glTexCoordPointer
glColorPointer
glIndexPointer
glNormalPointer
glVertexPointer
glArrayElement
glDrawArrays
glDrawElements
glInterleavedArrays
glGetBooleanv
glGetDoublev
glGetFloatv
glGetIntegerv
glGetMapdv
glGetMapfv
glGetMapiv
glGetPixelMapfv
glGetPixelMapuiv
glGetPixelMapusv
glGetPointerv
glGetTexEnvfv
glGetTexEnviv
glGetTexGenfv
glGetTexGeniv
glGetTexImage
glGetTexLevelParameterfv
glGetTexLevelParameteriv
glGetTexParameterfv
glGetTexParameteriv

Version 1.2  
glDrawRangeElements
glGetColorTable
glGetConvolutionFilter
glGetHistogram
glGetMinmax
glGetSeparableFilter
  
Version 1.3
glCompressedTexImage1D
glCompressedTexImage2D
glCompressedTexImage3D
glCompressedTexSubImage1D
glCompressedTexSubImage2D
glCompressedTexSubImage3D
glGetCompressedTexImage
  