Module FunGL


module FunGL: sig .. end
An experimental attempt at a functional interface to OpenGL.


This module tries to be a functional wrapper around OpenGL, so you don't have to think about the side effects and restoring the previous gl state when using these functions. You can set parameters for a local effect.

Types


type vertex2 = float * float 
(x,y)
type vertex3 = float * float * float 
(x,y,z)
type vertex4 = float * float * float * float 
(x,y,z,w)
type vector = float * float * float 
type rgb = float * float * float 
type rgba = float * float * float * float 
type uv = float * float 
type matrix4x4 = float array 

Replacement Functions


val draw_translated : vector -> (unit -> unit) -> unit
Deprecated.functional replacement for GL.glTranslate (glTranslate is now deprecated)
val draw_rotated : float -> vector -> (unit -> unit) -> unit
Deprecated.functional replacement for GL.glRotate (glRotate is now deprecated)
val draw_scaled : vector -> (unit -> unit) -> unit
Deprecated.functional replacement for GL.glScale (glScale is now deprecated)
val draw_as_identity : (unit -> unit) -> unit
Deprecated.functional replacement for GL.glLoadIdentity (glLoadIdentity is now deprecated)
val draw_with_matrix : matrix4x4 -> (unit -> unit) -> unit
Deprecated.functional replacement for GL.glMultMatrix/Flat (glMultMatrix/Flat is now deprecated)
val draw_with_rgb : rgb -> (unit -> unit) -> unit
Deprecated.functional replacement for GL.glColor3 (glColor3 is now deprecated)
val draw_with_rgba : rgba -> (unit -> unit) -> unit
Deprecated.functional replacement for GL.glColor4 (glColor4 is now deprecated)
val draw_with_material : face:GL.face_mode -> mode:GL.Material.material_mode -> (unit -> unit) -> unit
Deprecated.functional replacement for GL.glMaterial (glMaterial is now deprecated)
val draw_with_lightModel : light_model:GL.light_model -> (unit -> unit) -> unit
Deprecated.functional replacement for GL.glLightModel (glLightModel is now deprecated)
val draw_with_shadeModel : shade_mode:GL.shade_mode -> (unit -> unit) -> unit
Deprecated.functional replacement for GL.glShadeModel (glShadeModel is now deprecated)
val draw_with_frontFace : orientation:GL.orientation -> (unit -> unit) -> unit
use this function as replacement of GL.glFrontFace
val draw_with_cullFace : mode:GL.face_mode -> (unit -> unit) -> unit
use this function as replacement of GL.glCullFace
val draw_enabled : cap:GL.gl_capability -> (unit -> unit) -> unit
use this function as replacement of GL.glEnable
val with_enablements : caps:GL.gl_capability list -> (unit -> unit) -> unit
same than draw_enabled but with several capabilities
val draw_disabled : cap:GL.gl_capability -> (unit -> unit) -> unit
use this function as replacement of GL.glDisable
val draw_with_viewport : viewport:int * int * int * int -> (unit -> unit) -> unit
use this function instead of GL.glViewport when you use a local viewport
val draw_with_polygonMode : face:GL.face_mode -> mode:GL.polygon_mode -> (unit -> unit) -> unit
use this function as replacement of GL.glPolygonMode
val draw_with_polygonMode2 : front:GL.polygon_mode -> back:GL.polygon_mode -> (unit -> unit) -> unit
use this function as replacement of GL.glPolygonMode
val do_with_matrixMode : mode:GL.matrix_mode -> (unit -> unit) -> unit
Deprecated.functional replacement for GL.glMatrixMode (glMatrixMode is now deprecated)
val draw_with_lineWidth : width:float -> (unit -> unit) -> unit
use this function as replacement of GL.glLineWidth, in OpenGL >= 3.0, this function does not support values greater than 1.0 anymore.
val draw_with_pointSize : size:float -> (unit -> unit) -> unit
use this function as replacement of GL.glPointSize
val draw_using_program : program:GL.shader_program -> (unit -> unit) -> unit

Drawing



type qualified_vertices =
| Vertices2 of vertex2 list
| Vertices3 of vertex3 list
| Vertices4 of vertex4 list
| Normal_Vertices2 of (vector * vertex2) list
| Normal_Vertices3 of (vector * vertex3) list
| Normal_Vertices4 of (vector * vertex4) list
| RGB_Vertices2 of (rgb * vertex2) list
| RGB_Vertices3 of (rgb * vertex3) list
| RGB_Vertices4 of (rgb * vertex4) list
| RGBA_Vertices2 of (rgba * vertex2) list
| RGBA_Vertices3 of (rgba * vertex3) list
| RGBA_Vertices4 of (rgba * vertex4) list
| Normal_RGB_Vertices2 of (vector * rgb * vertex2) list
| Normal_RGB_Vertices3 of (vector * rgb * vertex3) list
| Normal_RGB_Vertices4 of (vector * rgb * vertex4) list
| Normal_RGBA_Vertices2 of (vector * rgba * vertex2) list
| Normal_RGBA_Vertices3 of (vector * rgba * vertex3) list
| Normal_RGBA_Vertices4 of (vector * rgba * vertex4) list
| UV_Vertices2 of (uv * vertex2) list
| UV_Vertices3 of (uv * vertex3) list
| UV_Vertices4 of (uv * vertex4) list
| UV_Normal_Vertices2 of (uv * vector * vertex2) list
| UV_Normal_Vertices3 of (uv * vector * vertex3) list
| UV_Normal_Vertices4 of (uv * vector * vertex4) list
| UV_RGB_Vertices2 of (uv * rgb * vertex2) list
| UV_RGB_Vertices3 of (uv * rgb * vertex3) list
| UV_RGB_Vertices4 of (uv * rgb * vertex4) list
| UV_RGBA_Vertices2 of (uv * rgba * vertex2) list
| UV_RGBA_Vertices3 of (uv * rgba * vertex3) list
| UV_RGBA_Vertices4 of (uv * rgba * vertex4) list
| UV_Normal_RGB_Vertices2 of (uv * vector * rgb * vertex2) list
| UV_Normal_RGB_Vertices3 of (uv * vector * rgb * vertex3) list
| UV_Normal_RGB_Vertices4 of (uv * vector * rgb * vertex4) list
| UV_Normal_RGBA_Vertices2 of (uv * vector * rgba * vertex2) list
| UV_Normal_RGBA_Vertices3 of (uv * vector * rgba * vertex3) list
| UV_Normal_RGBA_Vertices4 of (uv * vector * rgba * vertex4) list
val render_primitive : GL.primitive -> qualified_vertices -> unit
Deprecated.render the given list of qualified vertices as the required primitive. This function uses the immediate mode which is deprecated, so use Ogl_draw.make_mesh and Ogl_draw.draw_mesh instead.