SFML-2.3.2.3: SFML bindings

Safe HaskellSafe-Inferred
LanguageHaskell98

SFML.Window.Window

Synopsis

Documentation

data WindowStyle Source

Constructors

SFNone

No border / title bar (this flag and all others are mutually exclusive)

SFTitlebar

Title bar + fixed border

SFResize

Titlebar + resizable border + maximize button

SFClose

Titlebar + close button

SFFullscreen

Fullscreen mode (this flag and all others are mutually exclusive)

SFDefaultStyle

Default window style

createWindow Source

Arguments

:: VideoMode

Video mode to use (defines the width, height and depth of the rendering area of the window)

-> String

Window title

-> [WindowStyle]

Window style

-> Maybe ContextSettings

Additional settings for the underlying OpenGL context

-> IO Window 

Construct a new window.

This function creates the window with the size and pixel depth defined in a mode. An optional style can be passed to customize the look and behaviour of the window (borders, title bar, resizable, closable, ...). If a style contains sfFullscreen, then a mode must be a valid video mode.

The fourth parameter is a pointer to a structure specifying advanced OpenGL context settings such as antialiasing, depth-buffer bits, etc.

windowFromHandle Source

Arguments

:: WindowHandle

Platform-specific handle of the control

-> Maybe ContextSettings

Additional settings for the underlying OpenGL context

-> IO Window 

Construct a window from an existing control.

Use this constructor if you want to create an OpenGL rendering area into an already existing control.

The second parameter is a pointer to a structure specifying advanced OpenGL context settings such as antialiasing, depth-buffer bits, etc.

destroy :: SFResource a => a -> IO () Source

Destroy the given SFML resource.

close :: SFWindow a => a -> IO () Source

Close the window.

After calling this function, the window object remains valid; you must call destroy to actually delete it.

isWindowOpen :: SFWindow a => a -> IO Bool Source

Tell whether or not a window is opened

This function returns whether or not the window exists.

Note that a hidden window (setWindowVisible False ) will return True.

getWindowSettings :: SFWindow a => a -> IO ContextSettings Source

Get the settings of the OpenGL context of a window.

Note that these settings may be different from what was passed to the window create function, if one or more settings were not supported. In this case, SFML chose the closest match.

pollEvent :: SFWindow a => a -> IO (Maybe SFEvent) Source

Pop the event on top of events stack, if any, and return it.

This function is not blocking: if there's no pending event then it will return false and leave a event unmodified. Note that more than one event may be present in the events stack, thus you should always call this function in a loop to make sure that you process every pending event.

waitEvent :: SFWindow a => a -> IO (Maybe SFEvent) Source

Wait for an event and return it.

This function is blocking: if there's no pending event then it will wait until an event is received.

After this function returns (and no error occured), the event object is always valid and filled properly.

This function is typically used when you have a thread that is dedicated to events handling: you want to make this thread sleep as long as no new event is received.

getWindowPosition :: SFWindow a => a -> IO Vec2i Source

Get the position of a window.

setWindowPosition :: SFWindow a => a -> Vec2i -> IO () Source

Change the position of a window on screen.

This function only works for top-level windows (i.e. it will be ignored for windows created from the handle of a child window/control).

getWindowSize :: SFWindow a => a -> IO Vec2u Source

Get the size of the rendering region of a window.

The size doesn't include the titlebar and borders of the window.

setWindowSize :: SFWindow a => a -> Vec2u -> IO () Source

Change the size of the rendering region of a window.

setWindowTitle :: SFWindow a => a -> String -> IO () Source

Change the title of a window.

setWindowIcon Source

Arguments

:: SFWindow a 
=> a 
-> Int

Icon's width, in pixels

-> Int

Icon's height, in pixels

-> Ptr b

Pixel data

-> IO () 

Change a window's icon.

Pixels must be an array of width x height pixels in 32-bits RGBA format.

setWindowVisible :: SFWindow a => a -> Bool -> IO () Source

Show or hide a window.

setMouseVisible :: SFWindow a => a -> Bool -> IO () Source

Show or hide the mouse cursor.

setVSync :: SFWindow a => a -> Bool -> IO () Source

Enable or disable vertical synchronization. Activating vertical synchronization will limit the number of frames displayed to the refresh rate of the monitor.

This can avoid some visual artifacts, and limit the framerate to a good value (but not constant across different computers).

setKeyRepeat :: SFWindow a => a -> Bool -> IO () Source

Enable or disable automatic key-repeat.

If key repeat is enabled, you will receive repeated KeyPress events while keeping a key pressed. If it is disabled, you will only get a single event when the key is pressed.

Key repeat is enabled by default.

setWindowActive :: SFWindow a => a -> Bool -> IO () Source

Activate or deactivate a window as the current target for OpenGL rendering.

A window is active only on the current thread, if you want to make it active on another thread you have to deactivate it on the previous thread first if it was active.

Only one window can be active on a thread at a time, thus the window previously active (if any) automatically gets deactivated.

requestFocus :: SFWindow a => a -> IO () Source

Request the current window to be made the active foreground window.

At any given time, only one window may have the input focus to receive input events such as keystrokes or mouse events. If a window requests focus, it only hints to the operating system, that it would like to be focused. The operating system is free to deny the request. This is not to be confused with setWindowActive.

hasFocus :: SFWindow a => a -> IO Bool Source

Check whether the render window has the input focus.

At any given time, only one window may have the input focus to receive input events such as keystrokes or most mouse events.

display :: SFDisplayable a => a -> IO () Source

Update the target's contents.

setFramerateLimit :: SFWindow a => a -> Int -> IO () Source

Limit the framerate to a maximum fixed frequency.

If a limit is set, the window will use a small delay after each call to display to ensure that the current frame lasted long enough to match the framerate limit.

setJoystickThreshold :: SFWindow a => a -> Float -> IO () Source

Change the joystick threshold.

The joystick threshold is the value below which no JoyMoved event will be generated.

getSystemHandle :: SFWindow a => a -> IO WindowHandle Source

Get the OS-specific handle of the window.

The type of the returned handle is WindowHandle, which is a typedef to the handle type defined by the OS.

You shouldn't need to use this function, unless you have very specific stuff to implement that SFML doesn't support, or implement a temporary workaround until a bug is fixed.

getMousePosition :: SFWindow a => Maybe a -> IO Vec2i Source

Get the current position of the mouse

This function returns the current position of the mouse cursor relative to the given window, or desktop if Nothing is passed.

setMousePosition :: SFWindow a => Vec2i -> Maybe a -> IO () Source

Set the current position of the mouse

This function sets the current position of the mouse cursor relative to the given window, or desktop if Nothing is passed.