Module OgamlGraphics.Context

Encapsulates data about an OpenGL internal context

This module encapsulates a copy of the internal GL context. This allows efficient optimizations of state changes.
To get an instance of a Context.t, create a GL context (via a window) and use Window.context

exception Invalid_context of string
Raised when trying to perform an invalid state change (for example, binding a texture to an invalid texture unit)
type capabilities = {max_3D_texture_size : int; max_array_texture_layers : int; max_color_texture_samples : int; max_cube_map_texture_size : int; max_depth_texture_samples : int; max_elements_indices : int; max_elements_vertices : int; max_integer_samples : int; max_renderbuffer_size : int; max_texture_buffer_size : int; max_texture_image_units : int; max_texture_size : int; max_color_attachments : int}
Rendering capabilities of a context

Record fields

max_3D_texture_size : int
Maximal 3D texture size
max_array_texture_layers : int
Maximal number of layers in a texture array
max_color_texture_samples : int
Maximal number of samples in a multisampled color texture
max_cube_map_texture_size : int
Maximal cubemap texture size
max_depth_texture_samples : int
Maximal number of samples in a multisampled depth texture
max_elements_indices : int
Maximal number of indices in an element buffer
max_elements_vertices : int
Maximal number of vertices in an element buffer
max_integer_samples : int
Maximal number of samples in a multisampled integer texture
max_renderbuffer_size : int
Maximal size of a renderbuffer
max_texture_buffer_size : int
Maximal size of a texture buffer
max_texture_image_units : int
Number of available texture units
max_texture_size : int
Maximal size of a texture
max_color_attachments : int
Maximal number of color attachments in a framebuffer
type t
Type of a GL context
val capabilities : t -> capabilities
Returns the rendering capabilities of a context
val version : t -> (int * int)
Returns the GL version supported by this context in (major, minor) format
val is_version_supported : t -> (int * int) -> bool
Returns true iff the given GL version in (major, minor) format is supported by the given context
val glsl_version : t -> int
Returns the GLSL version supported by this context
val is_glsl_version_supported : t -> int -> bool
Returns true iff the given GLSL version is supported by this context
val assert_no_error : t -> unit
Asserts that no openGL error occured internally. Used for debugging and testing.
val flush : t -> unit
Flushes the GL buffer
val finish : t -> unit
Finishes all pending actions