Home My Page Projects Code Snippets Project Openings 3D graphics for Standard ML
Summary Activity SCM

SCM Repository

[sml3d] View of /trunk/sml3d/src/opengl/gl.sml
ViewVC logotype

View of /trunk/sml3d/src/opengl/gl.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 310 - (download) (annotate)
Wed Oct 1 18:47:41 2008 UTC (10 years, 11 months ago) by jhr
File size: 18710 byte(s)
  Adding IMAGE signature and Image module
(* gl.sml
 *
 * COPYRIGHT (c) 2006 John Reppy (http://www.cs.uchicago.edu/~jhr)
 * All rights reserved.
 *)

structure GL :> GL =
  struct

  (* include common types *)
    open SML3dTypes SML3dTypeUtil
    open GLConsts
    open GLFuncs1_0 GLFuncs1_1 GLFuncs1_2 GLFuncs1_3 GLFuncs1_4
    open GLUtil

  (* convert records to vectors *)
    fun vectorf3 {x, y, z} : float vector = Vector.fromList [x, y, z]
    fun vectorf4 {x, y, z, w} : float vector = Vector.fromList [x, y, z, w]
    fun vectorc4 {r, g, b, a} : float vector = Vector.fromList [r, g, b, a]

  (* the GL API uses 0, 1 for booleans *)
    fun enum2Bool (i : glenum) = (i <> 0w0)
    fun bool2Enum false = (0w0 : GLenum.word) (* GL_FALSE *)
      | bool2Enum true = 0w1 (* GL_TRUE *)

    fun enum2int (i : glenum) = Word32.toIntX i
    fun int2Enum i = Word32.fromInt i

  (* faces *)
    type face = glenum
    val FRONT_FACE = GL_FRONT
    val BACK_FACE = GL_BACK
    val BOTH_FACES = GL_FRONT_AND_BACK

  (* MaterialParameter *)
    type material_param = glenum
    val AMBIENT = GL_AMBIENT
    val DIFFUSE = GL_DIFFUSE
    val SPECULAR = GL_SPECULAR
    val EMISSION = GL_EMISSION
    val SHININESS = GL_SHININESS		(* not exported *)
    val AMBIENT_AND_DIFFUSE = GL_AMBIENT_AND_DIFFUSE

  (* enable/disable capabilities *)
(* NOTE: this is just a small subset of the capabilities supported by
 * OpenGL.  Do a "man glEnable" for the full list.
 *)
    type capability = glenum
    val ALPHA_TEST = GL_ALPHA_TEST
    val AUTO_NORMAL = GL_AUTO_NORMAL
    val BLEND = GL_BLEND
    val COLOR_MATERIAL = GL_COLOR_MATERIAL
    val CULL_FACE = GL_CULL_FACE
    val DEPTH_TEST = GL_DEPTH_TEST
    val FOG = GL_FOG
    val LIGHTING = GL_LIGHTING
    val LINE_SMOOTH = GL_LINE_SMOOTH
    val POINT_SMOOTH = GL_POINT_SMOOTH
    val POLYGON_SMOOTH = GL_POLYGON_SMOOTH
    val RESCALE_NORMAL = GL_RESCALE_NORMAL
    val STENCIL_TEST = GL_STENCIL_TEST
    val SCISSOR_TEST = GL_SCISSOR_TEST
    val enable = glEnable
    val disable = glDisable

  (* rendering hint values *)
    type hint = glenum
    val FASTEST : hint = GL_FASTEST
    val NICEST : hint = GL_NICEST
    val DONT_CARE : hint = GL_DONT_CARE
    fun hintFn target hint = glHint (target, hint)

  (* matrix-mode operations *)
    type matrix_mode = glenum
    val MODELVIEW_MATRIX : matrix_mode = GL_MODELVIEW
    val PROJECTION_MATRIX : matrix_mode = GL_PROJECTION
    val TEXTURE_MATRIX : matrix_mode = GL_TEXTURE
    val COLOR_MATRIX : matrix_mode = GL_COLOR	(* requires GL_ARB_imaging *)
    val matrixMode = glMatrixMode
    fun getMatrixMode () = Word.fromInt (getInteger1 GL_MATRIX_MODE)

    fun viewport {x, y, wid, ht} = glViewport (x, y, wid, ht)
    fun depthRange {zNear, zFar} = glDepthRange (zNear, zFar)

    val pushMatrix = glPushMatrix
    val popMatrix = glPopMatrix
    val loadIdentity = glLoadIdentity
    val loadMatrixf = glLoadMatrixf o Matrix4f.toVector
    val loadMatrixd = glLoadMatrixd o Matrix4d.toVector
    val multMatrixf = glMultMatrixf o Matrix4f.toVector
    val multMatrixd = glMultMatrixd o Matrix4d.toVector

    fun ortho {left, right, bottom, top, zNear, zFar} =
	  glOrtho (left, right, bottom, top, zNear, zFar)
    fun frustum {left, right, bottom, top, zNear, zFar} =
	  glFrustum (left, right, bottom, top, zNear, zFar)

  (* standard transformations *)
    val rotated = glRotated
    val rotatef = glRotatef
    fun rotatedv (angle, {x, y, z}) = glRotated(angle, x, y, z)
    fun rotatefv (angle, {x, y, z}) = glRotatef(angle, x, y, z)
    val scaled = glScaled
    val scalef = glScalef
    val scaledv = glScaled o unpackv3
    val scalefv = glScalef o unpackv3
    fun uScaled s = glScaled(s, s, s)
    fun uScalef s = glScalef(s, s, s)
    val translated = glTranslated
    val translatef = glTranslatef
    val translatedv = glTranslated o unpackv3
    val translatefv = glTranslatef o unpackv3

  (* buffer operations *)
    datatype buffer_bit
      = COLOR_BUFFER_BIT
      | DEPTH_BUFFER_BIT
      | ACCUM_BUFFER_BIT
      | STENCIL_BUFFER_BIT
    fun clear l = let
	  fun toGL COLOR_BUFFER_BIT = GL_COLOR_BUFFER_BIT
	    | toGL DEPTH_BUFFER_BIT = GL_DEPTH_BUFFER_BIT
	    | toGL ACCUM_BUFFER_BIT = GL_ACCUM_BUFFER_BIT
	    | toGL STENCIL_BUFFER_BIT = GL_STENCIL_BUFFER_BIT
	  in
	    glClear (List.foldl (fn (b, m) => Word.orb(m, toGL b)) 0w0 l)
	  end
    fun clearColor {r, g, b, a} = glClearColor (r, g, b, a)
    val clearDepth = glClearDepth
    fun clearAccum {r, g, b, a} = glClearAccum (r, g, b, a)
    val clearStencil = glClearStencil
(*
    datatype draw_buffer
      = NO_BUFFER
      | FRONT | FRONT_LEFT | FRONT_RIGHT
      | BACK | BACK_LEFT | BACK_RIGHT
      | FRONT_AND_BACK | LEFT | RIGHT
      | AUX of int
    val drawBuffer : draw_buffer -> unit
    val getDrawBuffer : unit -> draw_buffer
*)
    fun depthMask on = glDepthMask (if on then GLConsts.GL_TRUE else GLConsts.GL_FALSE)

  (* fragment tests *)
(* FIXME: we probably should use an abstract type with constants here *)
    datatype test = NEVER | LESS | EQUAL | LEQUAL | GREATER | NOTEQUAL | GEQUAL | ALWAYS
(*
    datatype stencil_op = KEEP | ZERO | REPLACE | INCR | DECR | INVERT
*)
    local
      fun testToEnum NEVER = GL_NEVER
	| testToEnum LESS = GL_LESS
	| testToEnum LEQUAL = GL_LEQUAL
	| testToEnum EQUAL = GL_EQUAL
	| testToEnum GREATER = GL_GREATER
	| testToEnum NOTEQUAL = GL_NOTEQUAL
	| testToEnum GEQUAL = GL_GEQUAL
	| testToEnum ALWAYS = GL_ALWAYS
      fun enumToTest tst =
	    if (tst = GL_NEVER) then NEVER
	    else if (tst = GL_LESS) then LESS
	    else if (tst = GL_LEQUAL) then LEQUAL
	    else if (tst = GL_EQUAL) then EQUAL
	    else if (tst = GL_GREATER) then GREATER
	    else if (tst = GL_NOTEQUAL) then NOTEQUAL
	    else if (tst = GL_GEQUAL) then GEQUAL
	    else if (tst = GL_ALWAYS) then ALWAYS
	    else raise Fail "bogus test"
(*
      fun opToEnum KEEP = GL_KEEP
	| opToEnum ZERO = GL_ZERO
	| opToEnum REPLACE = GL_REPLACE
	| opToEnum INCR = GL_INCR
	| opToEnum DECR = GL_DECR
	| opToEnum INVERT = GL_INVERT
      fun enumToOp tst =
	    if (tst = GL_KEEP) then KEEP
	    else if (tst = GL_ZERO) then ZERO
	    else if (tst = GL_REPLACE) then REPLACE
	    else if (tst = GL_INCR) then INCR
	    else if (tst = GL_DECR) then DECR
	    else if (tst = GL_INVERT) then INVERT
	    else raise Fail "bogus stencil op"
*)
    in
    fun depthFunc tst = glDepthFunc (testToEnum tst)
    fun getDepthFunc () = enumToTest (getEnum GL_DEPTH_FUNC)
(*
    fun stencilFunc (tst, refVal, mask) = glStencilFunc (testToEnum tst, refVal, mask)
    fun stencilOp {fail, zfail, zpass} = glStencilOp (opToEnum fail, opToEnum zfail, opToEnum zpass)
    fun getStencilFunc () = getEnum GL_STENCIL_FUNC
    fun getStencilRef () = getWord1 GL_STENCIL_REF
    fun getStencilMask () = getWord1 GL_STENCIL_VALUE_MASK
    fun getStencilBits () = getInt1 GL_STENCIL_BITS
    fun getStencilFail () = getEnum GL_STENCIL_FAIL
    fun getStencilZPass () = getEnum GL_STENCIL_PASS_DEPTH_PASS
    fun getStencilZFail () = getEnum GL_STENCIL_PASS_DEPTH_FAIL
    fun getStencilMask () = getWord1 GL_STENCIL_WRITEMASK
    fun stencilTestEnabled () = getBoolean1 GL_STENCIL_TEST
    fun getStencilClearValue () = getWord1 GL_STENCIL_CLEAR_VALUE
*)
    fun alphaFunc (tst, refVal) = glAlphaFunc (testToEnum tst, refVal)
    fun getAlphaFunc () = enumToTest (getEnum GL_ALPHA_TEST_FUNC)
    fun getAlphaRef () = getFloat1 GL_ALPHA_TEST_REF
    end

  (* lighting controls *)
    fun smoothShading smooth = let
          val GL_FLAT = 0wx1D00
          val GL_SMOOTH = 0wx1D01
	  in
	    glShadeModel (if smooth then GL_SMOOTH else GL_FLAT)
	  end
    fun ambientLight c = let
	  val GL_LIGHT_MODEL_AMBIENT = 0wx0B53
	  in
	    glLightModelfv (GL_LIGHT_MODEL_AMBIENT, vectorc4 c)
	  end
    fun shininess (face, param) = glMaterialf (face, GL_SHININESS, param)
    fun material (face, param, c) = glMaterialfv (face, param, vectorc4 c)

   (* lights *)
    type light = glenum
    val light0 = GL_LIGHT0 + 0w0
    val light1 = GL_LIGHT0 + 0w1
    val light2 = GL_LIGHT0 + 0w2
    val light3 = GL_LIGHT0 + 0w3
    val light4 = GL_LIGHT0 + 0w4
    val light5 = GL_LIGHT0 + 0w5
    val light6 = GL_LIGHT0 + 0w6
    val light7 = GL_LIGHT0 + 0w7
(* FIXME: should check against GL_MAX_NUM_LIGHTS *)
    fun light i = if (i < 0)
	  then raise Fail "bogus light"
	  else (GL_LIGHT0 + Word.fromInt i)
  (* turn a light on/off *)
    val enableLight = glEnable
    val disableLight = glDisable
  (* configure a light *)
    fun lightPosition (l, pos) = glLightfv (l, GL_POSITION, vectorf4 pos)
    fun lightSpotDirection (l, dir) = glLightfv (l, GL_SPOT_DIRECTION, vectorf3 dir)
    fun lightSpotCutoff (l, cutoff) = glLightf (l, GL_SPOT_CUTOFF, cutoff)
    fun lightSpotExponent (l, exp) = glLightf (l, GL_SPOT_EXPONENT, exp)
    fun lightConstantAttenuation (l, aten) = glLightf (l, GL_CONSTANT_ATTENUATION, aten)
    fun lightLinearAttenuation (l, aten) = glLightf (l, GL_LINEAR_ATTENUATION, aten)
    fun lightQuadraticAttenuation (l, aten) = glLightf (l, GL_QUADRATIC_ATTENUATION, aten)
  (* higher-level light configuration *)
    fun directionLight (l, dir) = (
	  glLightfv (l, GL_POSITION, vectorf4(Vec3f.vector dir));
	  glLighti (l, GL_SPOT_CUTOFF, 180))
    fun pointLight (l, pos) = (
	  glLightfv (l, GL_POSITION, vectorf4(Vec3f.point pos));
	  glLighti (l, GL_SPOT_CUTOFF, 180))
    fun spotLight (l, {pos, dir, cutoff, exp}) = (
	  glLightfv (l, GL_POSITION, vectorf4(Vec3f.point pos));
	  glLightfv (l, GL_SPOT_DIRECTION, vectorf3 dir);
	  glLightf (l, GL_SPOT_CUTOFF, cutoff);
	  glLightf (l, GL_SPOT_EXPONENT, exp))
  (* light radiance *)
    fun lightAmbient (l, c) = glLightfv (l, GL_AMBIENT, vectorc4 c)
    fun lightDiffuse (l, c) = glLightfv (l, GL_DIFFUSE, vectorc4 c)
    fun lightSpecular (l, c) = glLightfv (l, GL_SPECULAR, vectorc4 c)

  (* lighting model *)
    fun lightModelAmbient c = glLightModelfv (GL_LIGHT_MODEL_AMBIENT, vectorc4 c)
    datatype color_control = SINGLE_COLOR | SEPARATE_SPECULAR_COLOR
    fun lightModelColorControl SINGLE_COLOR =
	  glLightModel (GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR)
      | lightModelColorControl SEPARATE_SPECULAR_COLOR =
	  glLightModel (GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR)
    fun lightModelLocalViewer b =  glLightModel (GL_LIGHT_MODEL_LOCAL_VIEWER, bool2Enum b)
    fun lightModelTwoSide b = glLightModel (GL_LIGHT_MODEL_TWO_SIDE, bool2Enum b)

   (***** blending *****)
    type blend_func = glenum
    val ZERO = GL_ZERO
    val ONE = GL_ONE
    val SRC_COLOR = GL_SRC_COLOR			(* dst only *)
    val ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR	(* dst only *)
    val SRC_ALPHA = GL_SRC_ALPHA
    val ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA
    val DST_ALPHA = GL_DST_ALPHA
    val ONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA
    val DST_COLOR = GL_DST_COLOR			(* src only *)
    val ONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR	(* src only *)
    val SRC_ALPHA_SATURATE = GL_SRC_ALPHA_SATURATE	(* src only *)

    type blend_equation = glenum
    val MIN = GL_MIN
    val MAX = GL_MAX
    val FUNC_ADD = GL_FUNC_ADD
    val FUNC_SUBTRACT = GL_FUNC_SUBTRACT
    val FUNC_REVERSE_SUBTRACT = GL_FUNC_REVERSE_SUBTRACT

    fun blendColor c = glBlendColor (unpackc4 c)
(* FIXME: should combine blendEquation and blendFunc into a single operation *)
    val blendEquation = glBlendEquation
    fun blendFunc {src, dst} = glBlendFunc (src, dst)

  (***** fog *****)
    type fog_mode = glenum
    val FOG_LINEAR	: fog_mode = GL_LINEAR
    val FOG_EXP		: fog_mode = GL_EXP
    val FOG_EXP2	: fog_mode = GL_EXP2

    fun fogDensity d = glFogf (GL_FOG_DENSITY, d)
    fun fogMode mode = glFog (GL_FOG_MODE, mode)
    fun fogColor c = glFogfv (GL_FOG_COLOR, vectorc4 c)
    fun fogStart f = glFogf (GL_FOG_START, f)
    fun fogEnd f = glFogf (GL_FOG_END, f)
    val fogHint = hintFn GL_FOG_HINT


  (***** Texture and multitexture support *****)
    open Texture

  (* misc. state changes *)
    val cullFace = glCullFace
    val pointSize = glPointSize

  (* Polygon render modes *)
    type polygon_mode = glenum
    val POINT	= GL_POINT
    val LINE	= GL_LINE
    val FILL	= GL_FILL
    val polygonMode = glPolygonMode

  (* begin/end rendering *)
    type primitive = glenum
    val POINTS = GL_POINTS
    val LINES = GL_LINES
    val LINE_LOOP = GL_LINE_LOOP
    val LINE_STRIP = GL_LINE_STRIP
    val TRIANGLES = GL_TRIANGLES
    val TRIANGLE_STRIP = GL_TRIANGLE_STRIP
    val TRIANGLE_FAN = GL_TRIANGLE_FAN
    val QUADS = GL_QUADS
    val QUAD_STRIP = GL_QUAD_STRIP
    val POLYGON = GL_POLYGON

    val beginPrim  = glBegin
    val endPrim = glEnd
    fun renderPrim (mode, f : unit -> unit) = (
	  beginPrim mode;
	  f () handle ex => (endPrim(); raise ex);
	  endPrim ())
    val finish = glFinish
    val flush = glFlush

  (* rendering hints *)
    val pointSmoothHint = hintFn GL_POINT_SMOOTH_HINT
    val lineSmoothHint = hintFn GL_LINE_SMOOTH_HINT
    val polygonSmoothHint = hintFn GL_POLYGON_SMOOTH_HINT
    val perspectiveCorrectionHint = hintFn GL_PERSPECTIVE_CORRECTION_HINT

  (* rendering commands *)
    val vertex2f = glVertex2f
    fun vertex2fv v = vertex2f(unpackv2 v)
    val vertex2d = glVertex2d
    fun vertex2dv v = vertex2d(unpackv2 v)
    val vertex3f = glVertex3f
    fun vertex3fv v = vertex3f(unpackv3 v)
    val vertex3d = glVertex3d
    fun vertex3dv v = vertex3d(unpackv3 v)
    val vertex4f = glVertex4f
    fun vertex4fv v = vertex4f(unpackv4 v)
    val vertex4d = glVertex4d
    fun vertex4dv v = vertex4d(unpackv4 v)

    val normal3f = glNormal3f
    fun normal3fv v = normal3f(unpackv3 v)
    val normal3d = glNormal3d
    fun normal3dv v = normal3d(unpackv3 v)

    val color3ub = glColor3ub
    fun color3ubv c = color3ub(unpackc3 c)
    val color3f = glColor3f
    fun color3fv c = color3f(unpackc3 c) 
    val color4ub = glColor4ub
    fun color4ubv c = color4ub(unpackc4 c)
    val color4f = glColor4f
    fun color4fv c = color4f(unpackc4 c) 

    val secondaryColor3ub = glSecondaryColor3ub
    fun secondaryColor3ubv c = secondaryColor3ub(unpackc3 c)
    val secondaryColor3f = glSecondaryColor3f
    fun secondaryColor3fv c = secondaryColor3f(unpackc3 c)

    val fogCoordf = glFogCoordf
    val fogCoordd = glFogCoordd

    val texCoord1f = glTexCoord1f
    val texCoord1d = glTexCoord1d
    val texCoord2f = glTexCoord2f
    fun texCoord2fv t = texCoord2f(unpackt2 t)
    val texCoord2d = glTexCoord2d
    fun texCoord2dv t = texCoord2d(unpackt2 t)
    val texCoord3f = glTexCoord3f
    fun texCoord3fv t = texCoord3f(unpackt3 t)
    val texCoord3d = glTexCoord3d
    fun texCoord3dv t = texCoord3d(unpackt3 t)
    val texCoord4f = glTexCoord4f
    fun texCoord4fv t = texCoord4f(unpackt4 t)
    val texCoord4d = glTexCoord4d
    fun texCoord4dv t = texCoord4d(unpackt4 t)

    val multiTexCoord1f = glMultiTexCoord1f
    val multiTexCoord1d = glMultiTexCoord1d
    val multiTexCoord2f = glMultiTexCoord2f
    fun multiTexCoord2fv (tex, coord : tex2f) = multiTexCoord2f(tex, #s coord, #t coord)
    val multiTexCoord2d = glMultiTexCoord2d
    fun multiTexCoord2dv (tex, coord : tex2d) = multiTexCoord2d(tex, #s coord, #t coord)
    val multiTexCoord3f = glMultiTexCoord3f
    fun multiTexCoord3fv (tex, coord : tex3f) = multiTexCoord3f(tex, #s coord, #t coord, #r coord)
    val multiTexCoord3d = glMultiTexCoord3d
    fun multiTexCoord3dv (tex, coord : tex3d) = multiTexCoord3d(tex, #s coord, #t coord, #r coord)
    val multiTexCoord4f = glMultiTexCoord4f
    fun multiTexCoord4fv (tex, coord : tex4f) = multiTexCoord4f(tex, #s coord, #t coord, #r coord, #q coord)
    val multiTexCoord4d = glMultiTexCoord4d
    fun multiTexCoord4dv (tex, coord : tex4d) = multiTexCoord4d(tex, #s coord, #t coord, #r coord, #q coord)

    val arrayElement = glArrayElement


  (* display lists *)
(* FIXME: display lists should be finalized *)
    type display_list = Word32.word
    fun newList {list, exec=true} = glNewList (list, GL_COMPILE_AND_EXECUTE)
      | newList {list, ...} = glNewList (list, GL_COMPILE)
    val endList = glEndList
    fun genList () = let
	  val l = glGenLists 1
	  in
	    if l <> 0w0 then l else raise Fail "genList error"
	  end
    fun genLists n = if (n <= 0) then raise Size
	  else let
	    val l = glGenLists n
	    in
	      if l <> 0w0 then List.tabulate(n, fn i => l + Word32.fromInt i) else []
	    end
    val callList = glCallList


  (***** raster operations *****)
    val rasterPos2s = glRasterPos2s
    fun rasterPos2sv pos = rasterPos2s (unpackv2 pos)
    val rasterPos2i = glRasterPos2i
    fun rasterPos2iv pos = rasterPos2i (unpackv2 pos)
    val rasterPos2f = glRasterPos2f
    fun rasterPos2fv pos = rasterPos2f (unpackv2 pos)
    val rasterPos2d = glRasterPos2d
    fun rasterPos2dv pos = rasterPos2d (unpackv2 pos)
    val rasterPos3s = glRasterPos3s
    fun rasterPos3sv pos = rasterPos3s (unpackv3 pos)
    val rasterPos3i = glRasterPos3i
    fun rasterPos3iv pos = rasterPos3i (unpackv3 pos)
    val rasterPos3f = glRasterPos3f
    fun rasterPos3fv pos = rasterPos3f (unpackv3 pos)
    val rasterPos3d = glRasterPos3d
    fun rasterPos3dv pos = rasterPos3d (unpackv3 pos)
    val rasterPos4s = glRasterPos4s
    fun rasterPos4sv pos = rasterPos4s (unpackv4 pos)
    val rasterPos4i = glRasterPos4i
    fun rasterPos4iv pos = rasterPos4i (unpackv4 pos)
    val rasterPos4f = glRasterPos4f
    fun rasterPos4fv pos = rasterPos4f (unpackv4 pos)
    val rasterPos4d = glRasterPos4d
    fun rasterPos4dv pos = rasterPos4d (unpackv4 pos)

    val getCurrentRasterColorf = packc4 o (getFloat4 GL_CURRENT_RASTER_COLOR)
    fun getCurrentRasterDistance () = getFloat1 GL_CURRENT_RASTER_DISTANCE
    val getCurrentRasterPositioni = packv4 o (getInteger4 GL_CURRENT_RASTER_POSITION)
    val getCurrentRasterPositionf = packv4 o (getFloat4 GL_CURRENT_RASTER_POSITION)
    fun isCurrentRasterPositionValid () = getBoolean1 GL_CURRENT_RASTER_POSITION_VALID
    val getCurrentRasterTextureCoords = packt4 o (getFloat4 GL_CURRENT_RASTER_TEXTURE_COORDS)

  (* drawing pixel data at the current raster position *)
    fun drawPixels (format, image) = let
	  val wid = InternalImage.width2D image
	  val ht = InternalImage.height2D image
	  val {fmt, ty} = InternalImage.explodeFormat format
	  in
	    DataBuffer.withPtr (Image.data2D image,
	      fn {data, szb, elemSzb} => glDrawPixels (wid, ht, fmt, ty, data))
	  end

  (***** Information about the renderer etc. *****)
    fun getVendorString () = getString GL_VENDOR
    fun getRendererString () = getString GL_RENDERER
    fun getVersionString () = getString GL_VERSION
    fun getExtensionsString () = getString GL_EXTENSIONS
    fun getExtensions () = String.tokens Char.isSpace (getExtensionsString())

  end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0