module Eagle::Window

Overview

The game window: its size, title, fullscreen state and cursor.

Sizes are in logical points, the units you draw in. On high-DPI screens the framebuffer has more pixels (.pixel_size), and Eagle scales for you.

g.print("PAUSED", Window.center.x, Window.center.y, align: TextAlign::Center)
Window.fullscreen = !Window.fullscreen? if Input.pressed?(Key::F11)
Window.title = "Level 2"

Defined in:

eagle/core/window.cr

Class Method Summary

Class Method Detail

def self.aspect : Float32 #

Width divided by height.


def self.center : Vec2 #

The center of the window, handy for placing things in the middle of the screen.


def self.cursor_visible=(v : Bool) #

Shows or hides the mouse cursor, for games that draw their own crosshair.


def self.focused? : Bool #

True while the window has keyboard focus. Pause the game when it loses focus if you like.


def self.fullscreen=(v : Bool) #

Switches between fullscreen and windowed mode.


def self.fullscreen? : Bool #

True in fullscreen mode.


def self.height : Int32 #

Height in logical points.


def self.pixel_height : Int32 #

Framebuffer height in device pixels.


def self.pixel_size : Vec2 #

Framebuffer size in device pixels. It is larger than .size on Retina screens.


def self.pixel_width : Int32 #

Framebuffer width in device pixels.


def self.rect : Rect #

The whole window as a Rect from (0, 0).


def self.relative_mouse=(v : Bool) #

Captures the mouse for mouse-look: the cursor is hidden and locked, and Input.mouse_delta keeps reporting movement. Turn it off again for menus.


def self.scale : Float32 #

Device pixels per logical point: 2 on most Retina screens, 1 elsewhere.


def self.size : Vec2 #

(width, height) in logical points.


def self.title : String #

The window title.


def self.title=(t : String) #

Changes the window title.


def self.vsync=(v : Bool) #

Turns vsync on or off.


def self.vsync? : Bool #

True when presentation waits for the display's refresh.


def self.width : Int32 #

Width in logical points.