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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1413, Mon Apr 14 22:48:52 2014 UTC revision 1414, Mon Apr 14 22:49:17 2014 UTC
# Line 10  Line 10 
10    struct    struct
11    
12    (* attribute locations *)    (* attribute locations *)
13      eqtype attrib      type attrib = GLuint.word
14    
15    (* attribute locations can be specified as numeric values (corresponding to "layout"    (* attribute locations can be specified as numeric values (corresponding to "layout"
16     * location specifications in shader programs).  These functions convert between the     * location specifications in shader programs).  These functions convert between the
17     * abstract type and the concrete numeric representation.     * abstract type and the concrete numeric representation.
18     *)     *)
19      val fromWord : word -> attrib      fun fromWord w = w
20      val toWord : attrib -> word      fun toWord w = w
21    
22      val maxVertexAttribs : unit -> int      fun maxVertexAttribs () = StateUtil.getInteger1 GLConsts.GL_MAX_VERTEX_ATTRIBS
23    
24    (***** Vertex specification *****)    (***** Vertex specification *****)
25    
26    (* specifying individual attributes [glVertexAttrib] *)    (* specifying individual attributes [glVertexAttrib] *)
27      val attrib1s   : attrib * SML3dTypes.short -> unit      val attrib1s   = GLFuncs2x.glVertexAttrib1s
28      val attrib1f   : attrib * SML3dTypes.float -> unit      val attrib1f   = GLFuncs2x.glVertexAttrib1f
29      val attrib1d   : attrib * SML3dTypes.double -> unit      val attrib1d   = GLFuncs2x.glVertexAttrib1d
30      val attribI1i  : attrib * SML3dTypes.int -> unit      val attribI1i  = GLFuncs30.glVertexAttribI1i
31      val attribI1ui : attrib * SML3dTypes.uint -> unit      val attribI1ui = GLFuncs30.glVertexAttribI1ui
32      val attrib2s   : attrib * SML3dTypes.short * SML3dTypes.short -> unit      val attrib2s   = GLFuncs2x.glVertexAttrib2s
33      val attrib2f   : attrib * SML3dTypes.float * SML3dTypes.float -> unit      val attrib2f   = GLFuncs2x.glVertexAttrib2f
34      val attrib2d   : attrib * SML3dTypes.double * SML3dTypes.double -> unit      val attrib2d   = GLFuncs2x.glVertexAttrib2d
35      val attribI2i  : attrib * SML3dTypes.int * SML3dTypes.int -> unit      val attribI2i  = GLFuncs30.glVertexAttribI2i
36      val attribI2ui : attrib * SML3dTypes.uint * SML3dTypes.uint -> unit      val attribI2ui = GLFuncs30.glVertexAttribI2ui
37      val attrib3s   : attrib * SML3dTypes.short * SML3dTypes.short * SML3dTypes.short -> unit      val attrib3s   = GLFuncs2x.glVertexAttrib3s
38      val attrib3f   : attrib * SML3dTypes.float * SML3dTypes.float * SML3dTypes.float -> unit      val attrib3f   = GLFuncs2x.glVertexAttrib3f
39      val attrib3d   : attrib * SML3dTypes.double * SML3dTypes.double * SML3dTypes.double -> unit      val attrib3d   = GLFuncs2x.glVertexAttrib3d
40      val attribI3i  : attrib * SML3dTypes.int * SML3dTypes.int * SML3dTypes.int -> unit      val attribI3i  = GLFuncs30.glVertexAttribI3i
41      val attribI3ui : attrib * SML3dTypes.uint * SML3dTypes.uint * SML3dTypes.uint -> unit      val attribI3ui = GLFuncs30.glVertexAttribI3ui
42      val attrib4s   : attrib * SML3dTypes.short * SML3dTypes.short * SML3dTypes.short * SML3dTypes.short -> unit      val attrib4s   = GLFuncs2x.glVertexAttrib4s
43      val attrib4f   : attrib * SML3dTypes.float * SML3dTypes.float * SML3dTypes.float * SML3dTypes.float -> unit      val attrib4f   = GLFuncs2x.glVertexAttrib4f
44      val attrib4d   : attrib * SML3dTypes.double * SML3dTypes.double * SML3dTypes.double * SML3dTypes.double -> unit      val attrib4d   = GLFuncs2x.glVertexAttrib4d
45      val attribN4ub : attrib * SML3dTypes.ubyte * SML3dTypes.ubyte * SML3dTypes.ubyte * SML3dTypes.ubyte -> unit      val attrib4Nub = GLFuncs2x.glVertexAttrib4Nub
46      val attribI4i  : attrib * SML3dTypes.int * SML3dTypes.int * SML3dTypes.int * SML3dTypes.int -> unit      val attribI4i  = GLFuncs30.glVertexAttribI4i
47      val attribI4ui : attrib * SML3dTypes.uint * SML3dTypes.uint * SML3dTypes.uint * SML3dTypes.uint -> unit      val attribI4ui = GLFuncs30.glVertexAttribI4ui
48    
49  (* packed attribute values were introduced in Open GL 3.3  (* packed attribute values were introduced in Open GL 3.3
50      eqtype packing      eqtype packing
# Line 59  Line 59 
59    
60    (***** Vertex arrays *****)    (***** Vertex arrays *****)
61    
     val enableArray : attrib * bool -> unit  
   
62    (* attribute arity phantom types *)    (* attribute arity phantom types *)
63      datatype one = ONE      datatype one = ONE
64      datatype two = TWO      datatype two = TWO
# Line 68  Line 66 
66      datatype four = FOUR      datatype four = FOUR
67      datatype bgra = BGRA      datatype bgra = BGRA
68    
69      type ('arity, 'ty) attrib_fmt = FMT of (GLint.int * GLenum.word)  (* packed attribute values were introduced in Open GL 3.3
70      type ('arity, 'ty) int_attrib_fmt = IFMT of (GLint.int * GLenum.word)      datatype int_2_10_10_10_rev = INT_2_10_10_10_REV
71        datatype uint_2_10_10_10_rev = UINT_2_10_10_10_REV
72    *)
73    
74        datatype ('arity, 'ty) attrib_fmt = FMT of (GLint.int * GLenum.word)
75        datatype ('arity, 'ty) int_attrib_fmt = IFMT of (GLint.int * GLenum.word)
76    
77    (* attribute array formats *)    (* attribute array formats *)
78      val array1b  : (one, SML3dTypes.byte) int_attrib_fmt = IFMT(1, GLConsts.GL_BYTE)      val array1b  : (one, SML3dTypes.byte) int_attrib_fmt = IFMT(1, GLConsts.GL_BYTE)
# Line 113  Line 116 
116      val array4d  : (four, SML3dTypes.double) attrib_fmt = FMT(4, GLConsts.GL_DOUBLE)      val array4d  : (four, SML3dTypes.double) attrib_fmt = FMT(4, GLConsts.GL_DOUBLE)
117    
118    (* arrays with reverse-order components *)    (* arrays with reverse-order components *)
     val arrayBGRAb  : (bgra, SML3dTypes.byte) int_attrib_fmt = IFMT(GLenum.toIntX GLConsts.GL_BGRA, GLConsts.GL_BYTE)  
119      val arrayBGRAub : (bgra, SML3dTypes.ubyte) int_attrib_fmt = IFMT(GLenum.toIntX GLConsts.GL_BGRA, GLConsts.GL_UNSIGNED_BYTE)      val arrayBGRAub : (bgra, SML3dTypes.ubyte) int_attrib_fmt = IFMT(GLenum.toIntX GLConsts.GL_BGRA, GLConsts.GL_UNSIGNED_BYTE)
120      val arrayBGRAs  : (bgra, SML3dTypes.short) int_attrib_fmt = IFMT(GLenum.toIntX GLConsts.GL_BGRA, GLConsts.GL_SHORT)  (* packed attribute values were introduced in Open GL 3.3
121      val arrayBGRAus : (bgra, SML3dTypes.ushort) int_attrib_fmt = IFMT(GLenum.toIntX GLConsts.GL_BGRA, GLConsts.GL_UNSIGNED_SHORT)      val arrayBGRApi : (bgra, int_2_10_10_10_rev) attrib_fmt = FMT(GLenum.toIntX GLConsts.GL_BGRA, GLConsts.GL_INT_2_10_10_10_REV)
122      val arrayBGRAi  : (bgra, SML3dTypes.int) int_attrib_fmt = IFMT(GLenum.toIntX GLConsts.GL_BGRA, GLConsts.GL_INT)      val arrayBGRApui : (bgra, uint_2_10_10_10_rev) attrib_fmt = FMT(GLenum.toIntX GLConsts.GL_BGRA, GLConsts.GL_UNSIGNED_INT_2_10_10_10_REV)
123      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)  
124    
125    (* specifying floating-point attributes.  The bool argument specifies whether integer arguments    (* specifying floating-point attributes.  The bool argument specifies whether integer arguments
126     * should be mapped to a normalized range ([-1..1] for signed values and [0..1] for unsigned).     * should be mapped to a normalized range ([-1..1] for signed values and [0..1] for unsigned).
127     *)     *)
128      val attribFltArray : attrib * ('arity, 'ty) attrib_fmt -> unit      fun attribFltArray (attrib, FMT(arity, ty)) =
129      val attribArray : attrib * bool * ('arity, 'ty) int_attrib_fmt -> unit            GLFuncs2x.glVertexAttribPointer (attrib, arity, ty, GLConsts.GL_FALSE, 0, 0)
130      val attribIntArray : attrib * ('arity, 'ty) int_attrib_fmt -> unit      fun attribArray (attrib, normalize, IFMT(arity, ty)) =
131              GLFuncs2x.glVertexAttribPointer (attrib, arity, ty, if normalize then GLConsts.GL_TRUE else GLConsts.GL_FALSE, 0, 0)
132        fun attribIntArray (attrib, IFMT(arity, ty)) =
133              GLFuncs30.glVertexAttribIPointer (attrib, arity, ty, 0, 0)
134    
135    (* like the previous three functions, but with stride and offset info too *)    (* like the previous three functions, but with stride and offset info too *)
136      val attribFltArray' : attrib * ('arity, 'ty) attrib_fmt * GLsizei.int * C_Ptrdiff.t -> unit      fun attribFltArray' (attrib, FMT(arity, ty), stride, offset) =
137      val attribArray' : attrib * bool * ('arity, 'ty) int_attrib_fmt * GLsizei.int * C_Ptrdiff.t -> unit            GLFuncs2x.glVertexAttribPointer (attrib, arity, ty, GLConsts.GL_FALSE, stride, offset)
138      val attribIntArray' : attrib * ('arity, 'ty) int_attrib_fmt * GLsizei.int * C_Ptrdiff.t -> unit      fun attribArray' (attrib, normalize, IFMT(arity, ty), stride, offset) =
139              GLFuncs2x.glVertexAttribPointer (attrib, arity, ty, if normalize then GLConsts.GL_TRUE else GLConsts.GL_FALSE, stride, offset)
140        fun attribIntArray' (attrib, IFMT(arity, ty), stride, offset) =
141              GLFuncs30.glVertexAttribIPointer (attrib, arity, ty, stride, offset)
142    
143        val enableArray = GLFuncs2x.glEnableVertexAttribArray
144        val disableArray = GLFuncs2x.glDisableVertexAttribArray
145    
146    end    end

Legend:
Removed from v.1413  
changed lines
  Added in v.1414

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