module Prog:sig..end
A GPU program is a set of linked shaders. Each shader defines
a transformation that is applied on the rendering pipeline that
transforms the vertex stream to fragments. Programs can be
shared among effects.
Depending on the GPU driver a renderer should be able to report precise source file locations on compilation errors.
If shader sources are loaded from external sources, specify
their provenance with the loc argument of Lit.Prog.insert and
Lit.Prog.shader.
If they are written directly in the OCaml source code files,
compile them with -g. For errors to be reported without
offset miscalculations you need to open the source string on the
line of the call to Lit.Prog.insert or Lit.Prog.shader. For example:
Prog.shader `Vertex " <--- This is important ... "
otherwise the reported lines may be off.
typeloc =[ `Loc of string * int | `Unknown ]
val pp_loc : Format.formatter -> loc -> unitpp_loc ppf loc prints an unspecified representation of loc
on ppf.
Inserts can be used for source level, verbatim, textual inclusion (they
want to be called includes but that's an OCaml keyword).
They are a very primitive form of code reuse.
type insert
val insert : ?loc:loc -> string -> insertinsert ~loc:(`Loc (f, l)) src is the insert made of src
located in file f at line l. If loc is unspecified
the location of the function call is used provided the program
is compiled with -g.typelang =[ `GLSL of int | `GLSL_ES of int ]
150 for
1.50.typeshader_stage =[ `Compute
| `Fragment
| `Geometry
| `Tess_control
| `Tess_evaluation
| `Vertex ]
Lit.Renderer.Cap.shader_stages.val pp_shader_stage : Format.formatter -> shader_stage -> unitpp_shader_stage ppf stage prints an unspecified representatino of
stage on ppf.type shader
val shader : ?lang:lang ->
?loc:loc ->
?inserts:insert list ->
shader_stage -> string -> shadershader ~loc:(`Loc (f, l)) ~inserts stage src is the shader for
stage stage made by pre-concatening the inserts inserts to
src located in file f at line l. If loc is unspecified
the location of the function call is used provided the program
is compiled with -g.val stage : shader -> shader_stagestage s is the shader stage of s.val loc : shader -> locloc s is the location of shader s.val lang : shader -> lang optionlang s is the shading language for shader s.typesource =string * (int * string) list
val source : ?lang:lang -> shader -> sourcesource ?lang s is the source of shader s as will
be given to the GPU.typet =Lit.prog
val create : ?name:string -> ?uset:Lit.Uniform.set -> shader list -> Lit.progcreate uset shaders is the program made up of shaders, a list
in which each shader_kind should appear at most once. uset
define default uniform values (defaults to Lit.Uniform.empty).val name : Lit.prog -> stringname p is the program name.val uniforms : Lit.prog -> Lit.Uniform.setuniforms p are the default uniforms of p.val shaders : Lit.prog -> shader listshaders p is the shaders of p.