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/render-ctl.sml
ViewVC logotype

View of /trunk/sml3d/src/sml3d/gl32/render-ctl.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1473 - (download) (annotate)
Fri Sep 5 14:00:50 2014 UTC (3 years, 11 months ago) by jhr
File size: 3191 byte(s)
  Working on conditional rendering
(* render-ctl.sml
 *
 * COPYRIGHT (c) 2014 The SML3d Project (http://sml3d.cs.uchicago.edu)
 * All rights reserved.
 *)

structure GL32_RenderCtl =
  struct

    structure QueryObj = GLObjectFn (
      struct
	val kind = "query object"
	val alloc = GLFuncs1x.glGenQueries
	val delete = GLFuncs1x.glDeleteQueries
      end)

  (* asynchronous query object; the first type parameter constrains the kind
   * of queries (e.g., primitive or occlusion) and the second constrains the
   * type of results.
   *)
    type ('kind, 'ty) query = QueryObj.t

  (* phantom types to distinguish the various types of query objects *)
    datatype primitive = PRIM
    datatype occlusion = OCC

  (* are two queries the same? *)
    val same : ('k, 't) query * ('k, 't) query -> bool = QueryObj.same

  (* the various query targets *)
    type ('k, 't) query_target = glenum
    val primitivesQuery : (primitive, IntInf.int) query_target = GLConsts.GL_PRIMITIVES_GENERATED
    val samplesPassedQuery : (occlusion, IntInf.int) query_target = GLConsts.GL_SAMPLES_PASSED
    val feedbackQuery : (primitive, IntInf.int) query_target = GLConsts.GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN

(*
GLFuncs15.glGetQueryiv
*)
  (* information about query targets *)
    val current : ('k, 't) query_target -> ('k, 't) query option
    val counterBits : ('k, 't) query_target -> int

  (* generate a new query object *)
    val new : ('k, 't) query_target -> ('k, 't) query

  (* delete a query object *)
    val delete : ('k, 't) query -> unit

  (* is a query object valid (i.e., it has not been deleted) *)
    val isValid : ('k, 't) query -> bool

  (* are query results immediately available? *)
    val resultsAvailable : ('k, 't) query -> bool

  (* get the results of a query *)
    val getIntResult : ('k, IntInf.int) query -> IntInf.int

  (* use a query object *)
    val withQuery : ('k, 't) query -> (unit -> unit) -> unit
    val beginQuery : ('k, 't) query -> unit
    val endQuery : ('k, 't) query_target -> unit

  (* conditional rendering *)
    type mode = glenum
    val QUERY_NO_WAIT : mode = GLConsts.GL_QUERY_NO_WAIT
    val QUERY_WAIT : mode = GLConsts.GL_QUERY_WAIT
    val QUERY_BY_REGION_NO_WAIT : mode = GLConsts.GL_QUERY_BY_REGION_NO_WAIT
    val QUERY_BY_REGION_WAIT : mode = GLConsts.GL_QUERY_BY_REGION_WAIT

    fun withConditionalRender (qObj, mode) act =
	  QueryObj.withValue (qObj, fn qId => (
	    GLFuncs3x.glBeginConditionalRender(qId, mode);
	    f () handle ex => (; raise ex);
	    GLFuncs3x.glEndConditionalRender(qId, mode)))
    fun beginConditionalRender (qObj, mode) =
	  QueryObj.withValue (qObj, fn qId => GLFuncs3x.glBeginConditionalRender(qId, mode))
    fun endConditionalRender (qObj, mode) =
	  QueryObj.withValue (qObj, fn qId => GLFuncs3x.glEndConditionalRender(qId, mode))

  (* transform feedback *)
    eqtype feedback_mode
    val POINTS : feedback_mode = GLConsts.GL_POINTS
    val LINES : feedback_mode = GLConsts.GL_LINES
    val TRIANGLES : feedback_mode = GLConsts.GL_TRIANGLES

    val withTransformFeedback : feedback_mode -> (unit -> unit) -> unit
    val beginTransformFeedback : feedback_mode -> unit
    val endTransformFeedback : unit -> unit

  end

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