Class: Engine::Cursor

Inherits:
Object
  • Object
show all
Defined in:
lib/engine/cursor.rb

Class Method Summary collapse

Class Method Details

.disableObject



19
20
21
# File 'lib/engine/cursor.rb', line 19

def disable
  set_input_mode(:disable)
end

.enableObject



15
16
17
# File 'lib/engine/cursor.rb', line 15

def enable
  set_input_mode(:enable)
end

.get_input_modeObject

Returns a symbol from the supported_modes, e.g. ‘:hide’



33
34
35
# File 'lib/engine/cursor.rb', line 33

def get_input_mode
  supported_modes.key(GLFW.GetInputMode(Window.window, GLFW::CURSOR))
end

.hideObject



23
24
25
# File 'lib/engine/cursor.rb', line 23

def hide
  set_input_mode(:hide)
end

.restore_input_mode(original_mode) ⇒ Object

Expects a symbol present in supported_modes, e.g. ‘:hide’



38
39
40
# File 'lib/engine/cursor.rb', line 38

def restore_input_mode(original_mode)
  set_input_mode(original_mode)
end

.set_input_mode(mode) ⇒ Object

Expects a symbol present in supported_modes, e.g. ‘:hide’



28
29
30
# File 'lib/engine/cursor.rb', line 28

def set_input_mode(mode)
  GLFW.SetInputMode(Window.window, GLFW::CURSOR, supported_modes[mode])
end

.supported_modesObject



7
8
9
10
11
12
13
# File 'lib/engine/cursor.rb', line 7

def supported_modes
  {
    :enable   => GLFW::CURSOR_NORMAL,
    :disable  => GLFW::CURSOR_DISABLED,
    :hide     => GLFW::CURSOR_HIDDEN
  }
end