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

SCM Repository

[sml3d] View of /trunk/sml3d/src/openal/al.sml
ViewVC logotype

View of /trunk/sml3d/src/openal/al.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1435 - (download) (annotate)
Tue Apr 29 15:43:26 2014 UTC (4 years, 4 months ago) by jhr
File size: 2034 byte(s)
  added some state query functions
(* al.sml
 *
 * COPYRIGHT (c) 2014 John Reppy (http://www.cs.uchicago.edu/~jhr)
 * All rights reserved.
 *)

structure AL :> AL =
  struct
    local
      open ALTypes
      open ALConsts
      open ALFuncs
    in

  (* common types *)
    type float = Real32.real
    type vec3f = float * float * float

  (* basic OpenAL types *)
    type device = Device.t
    type context = Context.t
    type source = Source.t
    type buffer = Buffer.t

  (*
   * State retrieval
   *)
    local
      fun get name = CString.toString(alGetString name)
    in
    fun vendorString () = get AL_VENDOR
    fun rendererString () = get AL_RENDERER
    fun versionString () = get AL_VERSION
    fun extensionsString () = get AL_EXTENSIONS
    fun extensions () = String.tokens Char.isSpace (extensionsString())
    end

  (*
   * Global Parameters
   *)
    val dopplerFactor = alDopplerFactor
    fun getDopplerFactor () = alGetFloat AL_DOPPLER_FACTOR
    val speedOfSound = alSpeedOfSound
    fun getSpeedOfSound () = alGetFloat AL_SPEED_OF_SOUND

  (* distance model *)
    type distance_model = al_enum
    val INVERSE_DISTANCE		: distance_model = AL_INVERSE_DISTANCE
    val INVERSE_DISTANCE_CLAMPED	: distance_model = AL_INVERSE_DISTANCE_CLAMPED
    val LINEAR_DISTANCE			: distance_model = AL_LINEAR_DISTANCE
    val LINEAR_DISTANCE_CLAMPED		: distance_model = AL_LINEAR_DISTANCE_CLAMPED
    val EXPONENT_DISTANCE		: distance_model = AL_EXPONENT_DISTANCE
    val EXPONENT_DISTANCE_CLAMPED	: distance_model = AL_EXPONENT_DISTANCE_CLAMPED
    fun distanceModel NONE = alDistanceModel AL_NONE
      | distanceModel (SOME m) = alDistanceModel m
    fun getDistanceModel () = let
	  val m = alGetInteger AL_DISTANCE_MODEL
	  in
	    if (m = AL_NONE) then NONE
	    else SOME m
	  end

    structure Error = Error
    structure Format = Format
    structure Buffer = Buffer
    structure Source = Source
    structure Listener = Listener
    structure Context = Context
    structure Device = Device
    structure IO = IO

    end (* local *)
  end


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