module Espresso

Overview

Lightweight wrapper around GLFW for Crystal.

Included Modules

Extended Modules

Defined in:

espresso.cr
espresso/api_unavailable_error.cr
espresso/bool_conversion.cr
espresso/bounds.cr
espresso/button_state.cr
espresso/client_api.cr
espresso/context_creation_api.cr
espresso/context_robustness.cr
espresso/coordinates.cr
espresso/cursor.cr
espresso/cursor_mode.cr
espresso/cursor_shape.cr
espresso/enum_copy.cr
espresso/error_handling.cr
espresso/event_handling.cr
espresso/format_unavailable_error.cr
espresso/frame_size.cr
espresso/gamepad_axis.cr
espresso/gamepad_button.cr
espresso/gamepad_state.cr
espresso/gamma_ramp.cr
espresso/glfw_error.cr
espresso/image.cr
espresso/invalid_enum_error.cr
espresso/invalid_value_error.cr
espresso/joystick.cr
espresso/joystick_hat_state.cr
espresso/key.cr
espresso/key_state.cr
espresso/keyboard.cr
espresso/keyboard_char_event.cr
espresso/keyboard_char_mods_event.cr
espresso/keyboard_event.cr
espresso/keyboard_key_event.cr
espresso/modifier_key.cr
espresso/monitor.cr
espresso/mouse.cr
espresso/mouse_button.cr
espresso/mouse_button_event.cr
espresso/mouse_enter_event.cr
espresso/mouse_event.cr
espresso/mouse_move_event.cr
espresso/mouse_scroll_event.cr
espresso/no_current_context_error.cr
espresso/no_window_context_error.cr
espresso/not_initialized_error.cr
espresso/opengl_profile.cr
espresso/out_of_memory_error.cr
espresso/platform_error.cr
espresso/position.cr
espresso/release_behavior.cr
espresso/scale.cr
espresso/size.cr
espresso/timer.cr
espresso/version_unavailable_error.cr
espresso/video_mode.cr
espresso/window.cr
espresso/window_builder.cr
espresso/window_closing_event.cr
espresso/window_drop_event.cr
espresso/window_event.cr
espresso/window_focus_event.cr
espresso/window_iconify_event.cr
espresso/window_maximize_event.cr
espresso/window_move_event.cr
espresso/window_refresh_event.cr
espresso/window_resize_event.cr
espresso/window_scale_event.cr

Constant Summary

VERSION = "0.1.5"

Current version of the shard.

Instance Method Summary

Instance Method Detail

def compiled_version #

Version of GLFW that Espresso was compiled against. This should match #runtime_version to have consistent/expected behavior. A SemanticVersion is returned.


[View source]
def init(joystick_hat_buttons : Bool? = nil, cocoa_chdir_resources : Bool? = nil, cocoa_menubar : Bool? = nil) : Nil #

Prepares GLFW so that it can be used. This method must be called prior to any features that require initialization. If the initialization fails, a GLFWError will be raised.

Before exiting the program, and after GLFW is no longer needed, the #terminate method must be called. It is recommended to use #run instead of this method.

Arguments to this method are initialization hints. When unspecified (nil), the hints will use their default value. Specify true or false for the hints as needed.

joystick_hat_buttons specifies whether to also expose joystick hats as buttons, for compatibility with earlier versions of GLFW that did not have this feature.

macOS specific hints:

cocoa_chdir_resources pecifies whether to set the current directory to the application to the Contents/Resources subdirectory of the application's bundle, if present.

cocoa_menubar specifies whether to create a basic menu bar, either from a nib or manually, when the first window is created, which is when AppKit is initialized.

Calling this method when GLFW is already initialized does nothing.

A PlatformError will be raised if GLFW couldn't be initialized.


[View source]
def run(joystick_hat_buttons : Bool? = nil, cocoa_chdir_resources : Bool? = nil, cocoa_menubar : Bool? = nil, &) #

Initializes GLFW and yields for the duration it is usable. GLFW is automatically terminated after the block completes, even if an uncaught exception is raised.

Arguments to this method are initialization hints. When unspecified (nil), the hints will use their default value. Specify true or false for the hints as needed. See #init for details on what these hints do.

The value of the block is returned by this method.

Calling this method when GLFW is already initialized does nothing.

A PlatformError will be raised if GLFW couldn't be initialized.

Usage:

Espresso.run do
  # Use GLFW here.
end

[View source]
def runtime_version #

Version of GLFW that is loaded and in-use by Espresso. This should match #compiled_version to have consistent/expected behavior. A SemanticVersion is returned.


[View source]
def terminate : Nil #

Cleans up resources used by GLFW and and changes it made to the system. This method must be called after GLFW is no longer used and before the program exits. Once GLFW is terminated, it must be reinitialized before using it again.

Calling this method when GLFW is already terminated does nothing.

A PlatformError can be raised if GLFW couldn't be terminated.


[View source]
def version #

Version of GLFW that is loaded and in-use by Espresso. A SemanticVersion is returned.


[View source]
def version_string #

Compiled version string produced by GLFW. Includes the version string and additional compilation and environment information.


[View source]