sfml.window

package sfml.window

Provides OpenGL-based windows, and abstractions for events and input handling.

Attributes

Members list

Type members

Classlikes

trait ContextSettings(using ctor: ctor)

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
enum Event

Defines a system event and its parameters.

Defines a system event and its parameters.

Event holds all the informations about a system event that just happened.

Events are retrieved using the pollEvent function.

A Event instance contains the type of the event (mouse moved, key pressed, window closed, ...) as well as the details about this particular event.

val window: Window = ???
val doSomethingWithTheNewSize: (Int, Int) => Unit = ???

for event <- window.pollEvent() do
   event match
       // Request for closing the window
       case Event.Closed() => window.close()

       // The escape key was pressed
       case Event.KeyPressed(Keyboard.Key.Escape, _, _, _, _, _) => window.close()

       // The window was resized
       case Event.Resized(width, height) => doSomethingWithTheNewSize(width, height)

       // etc...

       case _ => ()

Attributes

Companion
object
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Event

Attributes

Companion
enum
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Event.type
object Joystick

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Joystick.type
object Keyboard

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Keyboard.type
object Mouse

Give access to the real-time state of the mouse.

Give access to the real-time state of the mouse.

sfml.window.Mouse provides an interface to the state of the mouse.

It only contains static functions (a single mouse is assumed), so it's not meant to be instantiated.

This class allows users to query the mouse state at any time and directly, without having to deal with a window and its events. Compared to the MouseMoved, MouseButtonPressed and MouseButtonReleased events, Mouse can retrieve the state of the cursor and the buttons at any time (you don't need to store and update a boolean on your side in order to know if a button is pressed or released), and you always get the real state of the mouse, even if it is moved, pressed or released when your window is out of focus and no event is triggered.

The position_= and position functions can be used to change or retrieve the current position of the mouse pointer. There are two versions: one that operates in global coordinates (relative to the desktop) and one that operates in window coordinates (relative to a specific window).

val window: Window = ???


if Mouse.Button.Left.isPressed() then
   // left click...
   ???

// get global mouse position
val position = Mouse.position

// set mouse position relative to a window
Mouse.position_=(window, (100, 200))

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Mouse.type
object Sensor

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Sensor.type
enum Style(val value: Int)

Enumeration of the window styles.

Enumeration of the window styles.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
trait VideoMode(using ctor: ctor)

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object VideoMode

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
VideoMode.type
trait Window(using ctor: ctor)

Window that serves as a target for OpenGL rendering.

Window that serves as a target for OpenGL rendering.

Window is the main class of the Window module.

It defines an OS window that is able to receive an OpenGL rendering.

A Window can create its own new window, or be embedded into an already existing control using the create(handle) function. This can be useful for embedding an OpenGL rendering area into a view which is part of a bigger GUI with existing windows, controls, etc. It can also serve as embedding an OpenGL rendering area into a window created by another (probably richer) GUI library like Qt or wxWidgets.

The Window class provides a simple interface for manipulating the window: move, resize, show/hide, control mouse cursor, etc. It also provides event handling through its pollEvent function .

Note that OpenGL experts can pass their own parameters (antialiasing level, bits for the depth and stencil buffers, etc.) to the OpenGL context attached to the window, with the ContextSettings structure which is passed as an optional argument when creating the window.

// Declare and create a new render-window
val window = Window(VideoMode(800, 600), "SFML window")

// Limit the framerate to 60 frames per second (this step is optional)
window.framerateLimit = 60;

// The main loop - ends as soon as the window is closed
while window.isOpen() do
   // Event processing
   for event <- window.pollEvent() do
       event match
           // Request for closing the window
           case Event.Closed() => window.close()
           case _              => ()



   // End the current frame and display its contents on screen
   window.display()

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait RenderWindow
object Window

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Window.type