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

SCM Repository

[sml3d] View of /trunk/sml3d/src/sml3d/gl3/vertex.sml
ViewVC logotype

View of /trunk/sml3d/src/sml3d/gl3/vertex.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1412 - (download) (annotate)
Mon Apr 14 21:01:06 2014 UTC (4 years, 10 months ago) by jhr
File size: 8427 byte(s)
  working on vertex support
(* vertex.sml
 *
 * COPYRIGHT (c) 2014 The SML3d Project (http://sml3d.cs.uchicago.edu)
 * All rights reserved.
 *
 * TODO: support for GL_INT_2_10_10_10_REV and GL_UNSIGNED_INT_2_10_10_10_REV
 *)

structure Vertex =
  struct

  (* attribute locations *)
    eqtype attrib

  (* attribute locations can be specified as numeric values (corresponding to "layout"
   * location specifications in shader programs).  These functions convert between the
   * abstract type and the concrete numeric representation.
   *)
    val fromWord : word -> attrib
    val toWord : attrib -> word

    val maxVertexAttribs : unit -> int

  (***** Vertex specification *****)

  (* specifying individual attributes [glVertexAttrib] *)
    val attrib1s   : attrib * SML3dTypes.short -> unit
    val attrib1f   : attrib * SML3dTypes.float -> unit
    val attrib1d   : attrib * SML3dTypes.double -> unit
    val attribI1i  : attrib * SML3dTypes.int -> unit
    val attribI1ui : attrib * SML3dTypes.uint -> unit
    val attrib2s   : attrib * SML3dTypes.short * SML3dTypes.short -> unit
    val attrib2f   : attrib * SML3dTypes.float * SML3dTypes.float -> unit
    val attrib2d   : attrib * SML3dTypes.double * SML3dTypes.double -> unit
    val attribI2i  : attrib * SML3dTypes.int * SML3dTypes.int -> unit
    val attribI2ui : attrib * SML3dTypes.uint * SML3dTypes.uint -> unit
    val attrib3s   : attrib * SML3dTypes.short * SML3dTypes.short * SML3dTypes.short -> unit
    val attrib3f   : attrib * SML3dTypes.float * SML3dTypes.float * SML3dTypes.float -> unit
    val attrib3d   : attrib * SML3dTypes.double * SML3dTypes.double * SML3dTypes.double -> unit
    val attribI3i  : attrib * SML3dTypes.int * SML3dTypes.int * SML3dTypes.int -> unit
    val attribI3ui : attrib * SML3dTypes.uint * SML3dTypes.uint * SML3dTypes.uint -> unit
    val attrib4s   : attrib * SML3dTypes.short * SML3dTypes.short * SML3dTypes.short * SML3dTypes.short -> unit
    val attrib4f   : attrib * SML3dTypes.float * SML3dTypes.float * SML3dTypes.float * SML3dTypes.float -> unit
    val attrib4d   : attrib * SML3dTypes.double * SML3dTypes.double * SML3dTypes.double * SML3dTypes.double -> unit
    val attribN4ub : attrib * SML3dTypes.ubyte * SML3dTypes.ubyte * SML3dTypes.ubyte * SML3dTypes.ubyte -> unit
    val attribI4i  : attrib * SML3dTypes.int * SML3dTypes.int * SML3dTypes.int * SML3dTypes.int -> unit
    val attribI4ui : attrib * SML3dTypes.uint * SML3dTypes.uint * SML3dTypes.uint * SML3dTypes.uint -> unit

(* packed attribute values were introduced in Open GL 3.3
    eqtype packing
    val INT_10_10_10_2 : packing
    val UNSIGNED_INT_10_10_10_2 : packing

    val attribP1ui : attrib * packing * bool * uint -> unit
    val attribP2ui : attrib * packing * bool * uint -> unit
    val attribP3ui : attrib * packing * bool * uint -> unit
    val attribP4ui : attrib * packing * bool * uint -> unit
*)

  (***** Vertex arrays *****)

    val enableArray : attrib * bool -> unit

  (* attribute arity phantom types *)
    datatype one = ONE
    datatype two = TWO
    datatype three = THREE
    datatype four = FOUR
    datatype bgra = BGRA

    type ('arity, 'ty) attrib_fmt = FMT of (GLint.int * GLenum.word)
    type ('arity, 'ty) int_attrib_fmt = IFMT of (GLint.int * GLenum.word)

  (* attribute array formats *)
    val array1b  : (one, SML3dTypes.byte) int_attrib_fmt = IFMT(1, GLConsts.GL_BYTE)
    val array1ub : (one, SML3dTypes.ubyte) int_attrib_fmt = IFMT(1, GLConsts.GL_UNSIGNED_BYTE)
    val array1s  : (one, SML3dTypes.short) int_attrib_fmt = IFMT(1, GLConsts.GL_SHORT)
    val array1us : (one, SML3dTypes.ushort) int_attrib_fmt = IFMT(1, GLConsts.GL_UNSIGNED_SHORT)
    val array1i  : (one, SML3dTypes.int) int_attrib_fmt = IFMT(1, GLConsts.GL_INT)
    val array1ui : (one, SML3dTypes.uint) int_attrib_fmt = IFMT(1, GLConsts.GL_UNSIGNED_INT)
    val array1h  : (one, SML3dTypes.half) attrib_fmt = FMT(1, GLConsts.GL_HALF_FLOAT)
    val array1f  : (one, SML3dTypes.float) attrib_fmt = FMT(1, GLConsts.GL_FLOAT)
    val array1d  : (one, SML3dTypes.double) attrib_fmt = FMT(1, GLConsts.GL_DOUBLE)

    val array2b  : (two, SML3dTypes.byte) int_attrib_fmt = IFMT(2, GLConsts.GL_BYTE)
    val array2ub : (two, SML3dTypes.ubyte) int_attrib_fmt = IFMT(2, GLConsts.GL_UNSIGNED_BYTE)
    val array2s  : (two, SML3dTypes.short) int_attrib_fmt = IFMT(2, GLConsts.GL_SHORT)
    val array2us : (two, SML3dTypes.ushort) int_attrib_fmt = IFMT(2, GLConsts.GL_UNSIGNED_SHORT)
    val array2i  : (two, SML3dTypes.int) int_attrib_fmt = IFMT(2, GLConsts.GL_INT)
    val array2ui : (two, SML3dTypes.uint) int_attrib_fmt = IFMT(2, GLConsts.GL_UNSIGNED_INT)
    val array2h  : (two, SML3dTypes.half) attrib_fmt = FMT(2, GLConsts.GL_HALF_FLOAT)
    val array2f  : (two, SML3dTypes.float) attrib_fmt = FMT(2, GLConsts.GL_FLOAT)
    val array2d  : (two, SML3dTypes.double) attrib_fmt = FMT(2, GLConsts.GL_DOUBLE)

    val array3b  : (three, SML3dTypes.byte) int_attrib_fmt = IFMT(3, GLConsts.GL_BYTE)
    val array3ub : (three, SML3dTypes.ubyte) int_attrib_fmt = IFMT(3, GLConsts.GL_UNSIGNED_BYTE)
    val array3s  : (three, SML3dTypes.short) int_attrib_fmt = IFMT(3, GLConsts.GL_SHORT)
    val array3us : (three, SML3dTypes.ushort) int_attrib_fmt = IFMT(3, GLConsts.GL_UNSIGNED_SHORT)
    val array3i  : (three, SML3dTypes.int) int_attrib_fmt = IFMT(3, GLConsts.GL_INT)
    val array3ui : (three, SML3dTypes.uint) int_attrib_fmt = IFMT(3, GLConsts.GL_UNSIGNED_INT)
    val array3h  : (three, SML3dTypes.half) attrib_fmt = FMT(3, GLConsts.GL_HALF_FLOAT)
    val array3f  : (three, SML3dTypes.float) attrib_fmt = FMT(3, GLConsts.GL_FLOAT)
    val array3d  : (three, SML3dTypes.double) attrib_fmt = FMT(3, GLConsts.GL_DOUBLE)

    val array4b  : (four, SML3dTypes.byte) int_attrib_fmt = IFMT(4, GLConsts.GL_BYTE)
    val array4ub : (four, SML3dTypes.ubyte) int_attrib_fmt = IFMT(4, GLConsts.GL_UNSIGNED_BYTE)
    val array4s  : (four, SML3dTypes.short) int_attrib_fmt = IFMT(4, GLConsts.GL_SHORT)
    val array4us : (four, SML3dTypes.ushort) int_attrib_fmt = IFMT(4, GLConsts.GL_UNSIGNED_SHORT)
    val array4i  : (four, SML3dTypes.int) int_attrib_fmt = IFMT(4, GLConsts.GL_INT)
    val array4ui : (four, SML3dTypes.uint) int_attrib_fmt = IFMT(4, GLConsts.GL_UNSIGNED_INT)
    val array4h  : (four, SML3dTypes.half) attrib_fmt = FMT(4, GLConsts.GL_HALF_FLOAT)
    val array4f  : (four, SML3dTypes.float) attrib_fmt = FMT(4, GLConsts.GL_FLOAT)
    val array4d  : (four, SML3dTypes.double) attrib_fmt = FMT(4, GLConsts.GL_DOUBLE)

  (* arrays with reverse-order components *)
    val arrayBGRAb  : (bgra, SML3dTypes.byte) int_attrib_fmt = IFMT(GLenum.toIntX GLConsts.GL_BGRA, GLConsts.GL_BYTE)
    val arrayBGRAub : (bgra, SML3dTypes.ubyte) int_attrib_fmt = IFMT(GLenum.toIntX GLConsts.GL_BGRA, GLConsts.GL_UNSIGNED_BYTE)
    val arrayBGRAs  : (bgra, SML3dTypes.short) int_attrib_fmt = IFMT(GLenum.toIntX GLConsts.GL_BGRA, GLConsts.GL_SHORT)
    val arrayBGRAus : (bgra, SML3dTypes.ushort) int_attrib_fmt = IFMT(GLenum.toIntX GLConsts.GL_BGRA, GLConsts.GL_UNSIGNED_SHORT)
    val arrayBGRAi  : (bgra, SML3dTypes.int) int_attrib_fmt = IFMT(GLenum.toIntX GLConsts.GL_BGRA, GLConsts.GL_INT)
    val arrayBGRAui : (bgra, SML3dTypes.uint) int_attrib_fmt = IFMT(GLenum.toIntX GLConsts.GL_BGRA, GLConsts.GL_UNSIGNED_INT)
    val arrayBGRAh  : (bgra, SML3dTypes.half) attrib_fmt = IFMT(GLenum.toIntX GLConsts.GL_BGRA, GLConsts.GL_HALF_FLOAT)
    val arrayBGRAf  : (bgra, SML3dTypes.float) attrib_fmt = FMT(GLenum.toIntX GLConsts.GL_BGRA, GLConsts.GL_FLOAT)
    val arrayBGRAd  : (bgra, SML3dTypes.double) attrib_fmt = FMT(GLenum.toIntX GLConsts.GL_BGRA, GLConsts.GL_DOUBLE)

  (* specifying floating-point attributes.  The bool argument specifies whether integer arguments
   * should be mapped to a normalized range ([-1..1] for signed values and [0..1] for unsigned).
   *)
    val attribFltArray : attrib * ('arity, 'ty) attrib_fmt -> unit
    val attribArray : attrib * bool * ('arity, 'ty) int_attrib_fmt -> unit
    val attribIntArray : attrib * ('arity, 'ty) int_attrib_fmt -> unit

  (* like the previous three functions, but with stride and offset info too *)
    val attribFltArray' : attrib * ('arity, 'ty) attrib_fmt * GLsizei.int * C_Ptrdiff.t -> unit
    val attribArray' : attrib * bool * ('arity, 'ty) int_attrib_fmt * GLsizei.int * C_Ptrdiff.t -> unit
    val attribIntArray' : attrib * ('arity, 'ty) int_attrib_fmt * GLsizei.int * C_Ptrdiff.t -> unit

  end

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