Module Sfml


module Sfml: sig .. end
The SFMLML library


Window and event operations

type pointer 

Events


type keycode =
| AlphaNum of char (*Alphanumerical keys (a-z and 0-9)*)
| NumPad of int (*Numerical pad*)
| FKey of int (*F1 to F12 keys*)
| KeyEscape
| KeyLControl
| KeyLShift
| KeyLAlt
| KeyLSystem
| KeyRControl
| KeyRShift
| KeyRAlt
| KeyRSystem
| KeyMenu
| KeyLBracket
| KeyRBracket
| KeySemiColon
| KeyComma
| KeyPeriod
| KeyQuote
| KeySlash
| KeyBackSlash
| KeyTilde
| KeyEqual
| KeyDash
| KeySpace
| KeyReturn
| KeyBack
| KeyTab
| KeyPageUp
| KeyPageDown
| KeyEnd
| KeyHome
| KeyInsert
| KeyDelete
| KeyAdd
| KeySubtract
| KeyMultiply
| KeyDivide
| KeyLeft
| KeyRight
| KeyUp
| KeyDown
| KeyPause
Keycode type is a representation of each key in a keyboard

type mouseButton =
| ButtonLeft
| ButtonRight
| ButtonMiddle
| ButtonX1
| ButtonX2
Mouses buttons and joystick axis

type joyAxis =
| JoyAxisX
| JoyAxisY
| JoyAxisZ
| JoyAxisR
| JoyAxisU
| JoyAxisV
| JoyAxisPOV

type eventType =
| EvtClosed
| EvtResized (*Window closed or resized*)
| EvtLostFocus
| EvtGainedFocus (*Window focus events*)
| EvtTextEntered
| EvtKeyPressed
| EvtKeyReleased
| EvtMouseWheelMoved
| EvtMouseButtonPressed
| EvtMouseButtonReleased
| EvtMouseMoved
| EvtJoyButtonPressed
| EvtJoyButtonReleased
| EvtJoyMoved
Event types

type event =
| KeyEvent of eventType * keycode * bool * bool * bool (*A keyboard event. The 3 last parameters give access to the state of Alt, Ctrl and Shift Keys*)
| TextEvent of eventType * int
| MouseMoveEvent of eventType * int * int
| MouseButtonEvent of eventType * mouseButton
| MouseWheelEvent of eventType * int
| JoyMoveEvent of eventType * int * joyAxis * float
| JoyButtonEvent of eventType * int * int
| SizeEvent of eventType * int * int
| Other of eventType
| NullEvent (*No event*)
Events

Inputs

class input : pointer -> object .. end
Input provides high-level access to the state (pressed or not) of keys and mouse buttons

Videomode


type videoMode = {
   screenWidth : int;
   screenHeight : int;
   bitsPerPixel : int;
}
Videomode : change resolution settings
val getDesktopVideoMode : unit -> videoMode
Returns the video mode used by user
val getVideoModesCount : unit -> int
Returns the number of video modes available
val getVideoMode : int -> videoMode
Returns a specific videomode : 0 is the best videomode accepted, 1 a bit less ...

Note : getVideoMode 0 is equivalent to getDesktopVideoMode

val isVideoModeValid : videoMode -> bool
Checks if a videomode is valid. eg : 1914*1918 may not be valid
val videoModeFrom : int -> int -> int -> videoMode
Returns a videomode from 3 int

Windows


type windowStyle =
| NoTitleBar
| FixedBar
| Resize
| FixedBarClose
| ResizeClose
| Fullscreen
Window Style. eg : FixedBar is a window without close button and with a fixed size
class virtual abstractWindow : unit -> object .. end
An abstract class for windows : all windows inherit of this class
class window : videoMode * string * windowStyle -> object .. end
A simple (useless ?) window without any graphics activated

Graphics operations


Colors


type color = {
   v_r : int;
   v_g : int;
   v_b : int;
   v_a : int;
}
Color : provides color support.
val color_add : color -> color -> color
Add two colors
val color_modulate : color -> color -> color
Modulate two colors
val color_fromRGBA : int -> int -> int -> int -> color
Return Color from int RGBA values
val color_fromRGB : int -> int -> int -> color
Return Color from int RGB values
val black : color
Some predefined colors
val white : color
val red : color
val green : color
val blue : color
val yellow : color
val mangenta : color
val cyan : color

BlendMode


type blendMode =
| BlendAlpha
| BlendAdd
| BlendMultiply
| BlendNone
Blend mode : enumerate the blend modes for drawable objects

Fonts

type font 
Font : is the low-level class for loading and manipulating character fonts
val font_create : unit -> font
Create an empty font
val font_createfromfile : string -> int -> font
Open a TTF Font
val default_font : font
Default built-in font : Arial

Images


type image_path =
| EmptyImage (*Create an empty image*)
| File of string (*Open an image from a file*)
| Color of (color * int * int) (*Open a single color image*)
| PixelTab of (int array * int * int) (*Open an image from apixel tab*)
| PointerData of pointer (*For internal use only*)
Type built to create an image
class image : image_path -> object .. end
Images support

Float Rect and int rect


type floatRect = {
   fLeft : float;
   fTop : float;
   fRight : float;
   fBottom : float;
}
Simple type

type intRect = {
   iLeft : int;
   iTop : int;
   iRight : int;
   iBottom : int;
}
val floatRect_offset : floatRect -> float -> float -> floatRect
Set an offset on the rects
val intRect_offset : intRect -> int -> int -> intRect
val floatRect_contains : floatRect -> float -> float -> bool
Check if a rectangle contains a given point
val intRect_contains : intRect -> int -> int -> bool
val intRect_insersects : intRect -> intRect -> bool
Check if two rectangle intersects
val floatRect_insersects : floatRect -> floatRect -> bool

Drawables

class virtual drawable : unit -> object .. end
Abstract class for all the drawable objects
class sprite : unit -> object .. end
Sprites : class for drawing images

type stringStyle = {
   bold : bool;
   italic : bool;
   underlined : bool;
}
Set the appearance of a string
class sfString : unit -> object .. end
Strings

Views

class view : floatRect -> object .. end
Provides a support for views

Render Window

class renderWindow : videoMode * string * windowStyle -> object .. end
Render Windows : window + drawing support

System : system utilities


Clock

class clock : unit -> object .. end
A simple timer
val sleep : float -> unit

Randomizer

class randomizer : unit -> object .. end
Randomizer : generate random numbers