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

SCM Repository

[sml3d] View of /src/common/sml3d-type-util-sig.sml
ViewVC logotype

View of /src/common/sml3d-type-util-sig.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 19 - (download) (annotate)
Mon Feb 18 17:47:01 2008 UTC (11 years, 11 months ago) by jhr
File size: 2155 byte(s)
  Move common types into their own directory.
(* sml3d-type-util-sig.sml
 *
 * COPYRIGHT (c) 2008 John Reppy (http://www.cs.uchicago.edu/~jhr)
 * All rights reserved.
 *)

signature SML3D_TYPE_UTIL =
  sig

  (* vector types (as per SML3d_TYPES) *)
    type 'a vec2 = {x : 'a, y : 'a}
    type 'a vec3 = {x : 'a, y : 'a, z : 'a}
    type 'a vec4 = {x : 'a, y : 'a, z : 'a, w : 'a}
    type 'a tex2 = {s : 'a, t : 'a}
    type 'a tex3 = {s : 'a, t : 'a, r : 'a}
    type 'a tex4 = {s : 'a, t : 'a, r : 'a, q : 'a}
    type 'a rgb  = {r : 'a, g : 'a, b : 'a}
    type 'a rgba = {r : 'a, g : 'a, b : 'a, a : 'a}

  (* pack tuples as records *)
    val packv2 : ('a * 'a)		-> 'a vec2
    val packv3 : ('a * 'a * 'a)		-> 'a vec3
    val packv4 : ('a * 'a * 'a * 'a)	-> 'a vec4

    val packt2 : ('a * 'a)		-> 'a tex2
    val packt3 : ('a * 'a * 'a)		-> 'a tex3
    val packt4 : ('a * 'a * 'a * 'a)	-> 'a tex4

    val packc3 : ('a * 'a * 'a)		-> 'a rgb
    val packc4 : ('a * 'a * 'a * 'a)	-> 'a rgba

  (* unpack records as tuples *)
    val unpackv2 : 'a vec2 -> ('a * 'a)
    val unpackv3 : 'a vec3 -> ('a * 'a * 'a)
    val unpackv4 : 'a vec4 -> ('a * 'a * 'a * 'a)

    val unpackt2 : 'a tex2 -> ('a * 'a)
    val unpackt3 : 'a tex3 -> ('a * 'a * 'a)
    val unpackt4 : 'a tex4 -> ('a * 'a * 'a * 'a)

    val unpackc3 : 'a rgb  -> ('a * 'a * 'a)
    val unpackc4 : 'a rgba -> ('a * 'a * 'a * 'a)

  (* iterators *)
    fun mapv2 : ('a -> 'b) -> 'a vec2 -> 'b vec2
    fun mapv3 : ('a -> 'b) -> 'a vec3 -> 'b vec3
    fun mapv4 : ('a -> 'b) -> 'a vec4 -> 'b vec4

    fun mapt2 : ('a -> 'b) -> 'a tex2 -> 'b tex2
    fun mapt3 : ('a -> 'b) -> 'a tex3 -> 'b tex3
    fun mapt4 : ('a -> 'b) -> 'a tex4 -> 'b tex4

    fun mapc3 : ('a -> 'b) -> 'a rgb -> 'b rgb
    fun mapc4 : ('a -> 'b) -> 'a rgba -> 'b rgba

    fun appv2 : ('a -> unit) -> 'a vec2 -> unit
    fun appv3 : ('a -> unit) -> 'a vec3 -> unit
    fun appv4 : ('a -> unit) -> 'a vec4 -> unit

    fun appt2 : ('a -> unit) -> 'a tex2 -> unit
    fun appt3 : ('a -> unit) -> 'a tex3 -> unit
    fun appt4 : ('a -> unit) -> 'a tex4 -> unit

    fun appc3 : ('a -> unit) -> 'a rgb -> unit
    fun appc4 : ('a -> unit) -> 'a rgba -> unit

  end

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