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

SCM Repository

[sml3d] View of /trunk/sml3d/src/sml3d/gl32/shader-sig.sml
ViewVC logotype

View of /trunk/sml3d/src/sml3d/gl32/shader-sig.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1472 - (download) (annotate)
Fri Sep 5 13:27:18 2014 UTC (3 years, 3 months ago) by jhr
File size: 4213 byte(s)
  working on shader support
(* shader-sig.sml
 *
 * COPYRIGHT (c) 2014 The SML3d Project (http://sml3d.cs.uchicago.edu)
 * All rights reserved.
 *
 * This interface covers the Shader and Programs part of the OpenGL 3.2 API.  See
 * Sections 2.11, 2.12, 3.9, and 6.1.10 of the OpenGL 3.2 Core Specification.
 *)

signature GL32_SHADER =
  sig

  (* get the version of GLSL supported by the current GL context.  The result consists
   * of the version number in the format [major, minor, release] (the release component
   * is optional) and a string containing vendor-specific information.
   *)
    val version : unit -> (int list * string)

  (***** Shaders *****
   *
   * Phantom type constants to distinguish between the different kinds of shaders.
   * Note that we include all of the kinds of shaders supported by the latest version
   * (OpenGL 4.5), for forward compatibility.
   *)
    type vertex
    type tess_ctl
    type tess_eval
    type geometry
    type fragment
    type compute

    type 'a shader

  (* this exception is raised when an operation is supplied an invalid (i.e., deleted)
   * shader.
   *)
    exception InvalidShader

  (* are two shaders the same? *)
    val sameShader : 'a shader * 'a shader -> bool

  (* is a shader valid?  This returns false if the shader has been deleted *)
    val isValidShader : 'a shader -> bool

  (* create shader objects *)
    val createVertexShader : unit -> vertex shader
    val createGeometryShader : unit -> geometry shader
    val createFragmentShader : unit -> fragment shader

  (* delete a shader *)
    val deleteShader : 'a shader -> unit

  (* give the source code for a shader *)
    val shaderSource : ('a shader * string list) -> unit

(* QUESTION: perhaps we should just combine compileShader and compileStatus into one operation? *)
  (* compile a shader; returns true if the compilation was successful *)
    val compileShader : 'a shader -> bool

  (* compile a shader without checking for success (use compileStatus for that purpose) *)
    val compileShaderNoCheck : 'a shader -> unit

  (* return the status of the last compile operation on a shader program *)
    val compileStatus : 'a shader -> bool

  (* return the information log for a shader *)
    val shaderLog : 'a shader -> string

  (* return the source of a shader *)
    val getShaderSource : 'a shader -> string


  (***** Programs *****)
    type program

  (* this exception is raised when an operation is supplied an invalid (i.e., deleted)
   * program.
   *)
    exception InvalidProgram

  (* are two programs the same *)
    val sameProgram : program * program -> bool

  (* is a program valid?  This returns false if the program has been deleted *)
    val isValidProgram : program -> bool

  (* create a new program object *)
    val createProgram : unit -> program

  (* delete a program; if the deleted program is the current program then the
   * current program is set to NONE.
   *)
    val deleteProgram : program -> unit

  (* attach/detach a shader to a program *)
    val attachShader : program * 'a shader -> unit
    val detachShader : program * 'a shader -> unit

  (* link a program *)
    val linkProgram : program -> unit

  (* return the status of the last link operation on a program *)
    val linkStatus : program -> bool

  (* return the information log for a program *)
    val programLog : program -> string

  (* install the program as part of the current render state *)
    val useProgram : program option -> unit

  (* return the current program (or NONE if there is none). *)
    val currentProgram : unit -> program option

  (* validate the program against the current render state.
   * NOTE: this operation is expensive and should only be used for debugging.
   *)
    val validateProgram : program -> bool

    datatype gl_shader
      = VERTEX of vertex shader
      | TESS_CONTROL of tess_ctl shader
      | TESS_EVALUATION of tess_eval shader
      | GEOMETRY of geometry shader
      | FRAGMENT of fragment shader
      | COMPUTE of compute shader

  (* return the list of shaders attached to a program. *)
    val getAttachedShaders : program -> gl_shader list

(* TODO: more program queries *)

(* TODO: uniform and attribute IDs *)

  end

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