Module OgamlGraphics.Window

High-level window wrapper for rendering and event management

This module provides a high-level wrapper around the low-level window interface of OgamlCore and also provides drawing functions.
Windows encapsulate a copy of the GL context that can be retrieved to obtain information about the GL context.


Window creation

type t
The type of a window
val create : ?width:int -> ?height:int -> ?title:string -> ?settings:OgamlCore.ContextSettings.t -> unit -> t
Creates a window of size width x height . This window will create its openGL context following the specified settings.
width defaults to 800
height defaults to 600
title defaults to ""
settings defaults to the default context settings

See : OgamlCore.ContextSettings
val settings : t -> OgamlCore.ContextSettings.t
Returns the settings used at the creation of the window
val context : t -> Context.t
Returns the internal GL context of the window
See : OgamlGraphics.Context
val set_title : t -> string -> unit
Changes the title of the window.
val set_framerate_limit : t -> int option -> unit
Sets a framerate limit
val close : t -> unit
Closes a window, but does not free the memory. This should prevent segfaults when calling functions on this window.
val destroy : t -> unit
Frees the window and the memory
val resize : t -> OgamlMath.Vector2i.t -> unit
Resizes the window.
See : OgamlMath.Vector2i
val toggle_fullscreen : t -> unit
Toggles the full screen mode of a window.
val rect : t -> OgamlMath.IntRect.t
Returns the rectangle associated to a window, in screen coordinates
See : OgamlMath.IntRect

Information About Windows

val size : t -> OgamlMath.Vector2i.t
Returns in pixel the width and height of the window (it only takes into account the size of the content where you can draw, *ie* the useful information).
See : OgamlMath.Vector2i
val is_open : t -> bool
Tells whether the window is currently open
val has_focus : t -> bool
Return true iff the window has the focus

Event Handling

val poll_event : t -> OgamlCore.Event.t option
Returns the next event on the event stack, or None if the stack is empty.
See : OgamlCore.Event

Displaying and Drawing

val display : t -> unit
Displays the window after the GL calls
val clear : ?color:Color.t option -> ?depth:bool -> ?stencil:bool -> t -> unit
Clears the window. Clears the color buffer with opaque black by default. Clears the depth buffer and the stencil buffer by default.
val show_cursor : t -> bool -> unit
Show or hide the cursor
val bind : t -> DrawParameter.t -> unit
Binds the window for drawing. This function is for internal use only.