module Prim:sig
..end
A primitive defines a vertex stream (set of attributes) sent to
the GPU and how this stream must be interpreted as geometrical
primitives. A primitive defines the Lit.Prim.kind
of primitive for
the geometry shader (if any) and its set of attributes define the
values of the input variables of the vertex shader.
A primitive value gathers a set of attributes, an optional index buffer
to specify the stream of vertices and a primitive Lit.Prim.kind
. Primitives
are immutable but the underlying buffers are not.
typekind =
[ `Line_loop
| `Line_strip
| `Line_strip_adjacency
| `Lines
| `Lines_adjacency
| `Points
| `Triangle_fan
| `Triangle_strip
| `Triangle_strip_adjacency
| `Triangles
| `Triangles_adjacency ]
val pp_kind : Format.formatter -> kind -> unit
pp_kind ppf kind
prints an unspecified representation of kind
on ppf
.typet =
Lit.prim
val create : ?tr:Gg.M4.t ->
?name:string ->
?first:int ->
?count:int -> ?index:Lit.Buf.t -> kind -> Lit.attr list -> Lit.prim
create name tr first count index kind attrs
is a primitive
such that:
tr
is a is a transform that is right-multiplied to the render
operation matrix (e.g. for normalizing disparate model
coordinate scales); TODO defaults to id
.name
is an optional client name for identifiying the primitive;
auto generated by default.first
is the scalar index of the first vertex index in index
,
ignored if index
is unspecified; defaults to 0
.count
is the number of vertices that are part of the vertex
stream. count
must be specified if index
is unspecified. In that
case count
attribute elements in each attribute are read to define
the vertex stream.index
if specified must be a buffer of unsigned integers
used to index the attribute elements to specify the vertex stream.
If count
is specified then always count
indices will be read
from index
starting at first
. If count
is unspecified then
all indices starting at first
until the end of buffer will be read
(hence the primitive's size may change dynamically).kind
the kind of primitive to render.attrs
, the primitive's attributes.Invalid_argument
if:
count
and index
are unspecifiedindex
scalar type is not an unsigned integer.attrs
val kind : Lit.prim -> kind
kind p
is the kind of p
.val name : Lit.prim -> string
name p
is the name of p
.val index : Lit.prim -> Lit.Buf.t option
val first : Lit.prim -> int
val count : Lit.prim -> int option
val count_now : Lit.prim -> int
count_now p
is the number of vertices in the vertex stream.
If count
was specified at creation time, this is always that
number. Otherwise, let b
be Lit.Prim.index
p
and first
be Lit.Prim.first
p
:
Lit.Buf.gpu_upload
b
is true
, Lit.Buf.cpu_count
b - first
is returned.Lit.Buf.gpu_count
b - first
is returned.val tr : Lit.prim -> Gg.M4.t
tr p
is pre-transform matrix of p
.val pp : Format.formatter -> Lit.prim -> unit
pp ppf p
prints an unspecified representation of p
on ppf
.val attrs : Lit.prim -> Lit.attr list
attrs p
is the attributes of p
.val iter : (Lit.attr -> unit) -> Lit.prim -> unit
iter p f
iterates f
over the attributes of p
.val fold : ('a -> Lit.attr -> 'a) -> 'a -> Lit.prim -> 'a
fold f acc p
folds f
over the attributes of p
starting with
acc
.val mem : Lit.prim -> string -> bool
mem p n
is true
there is an attribute with name n
in p
.val find : Lit.prim -> string -> Lit.attr option
find p n
is the attribute named n
of p
(if any).val get : Lit.prim -> string -> Lit.attr
get p n
is the attribute named n
of p
.Invalid_argument
if there is no attribute named n
in p.