Class: LiteRGSS::DisplayWindow

Inherits:
Object
  • Object
show all
Defined in:
LiteRGSS.rb.yard.rb

Overview

Class that describe a Window holding the OpenGL context & all drawable

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, width, height, scale, bpp = 32, frame_rate = 60, vsync = false, fullscreen = false, mouse_visible = false) ⇒ DisplayWindow

Create a new DisplayWindow

Parameters:

  • title (String) —

    title of the window

  • width (Integer) —

    width of the window content

  • height (Integer) —

    height of the window content

  • scale (Float) —

    scale of the window content (if width = 320 & scale = 2, window final width is 640 + frame)

  • bpp (Integer) (defaults to: 32) —

    number of bit per pixels

  • frame_rate (Integer) (defaults to: 60) —

    locked framerate of the window, 0 = unlimited fps

  • vsync (Boolean) (defaults to: false) —

    if vsync is on or off

  • fullscreen (Boolean) (defaults to: false) —

    if window should be in fullscreen mode

  • mouse_visible (Boolean) (defaults to: false) —

    if the mouse should be visible inside the window



985
986
987
# File 'LiteRGSS.rb.yard.rb', line 985

def initialize(title, width, height, scale, bpp = 32, frame_rate = 60, vsync = false, fullscreen = false, mouse_visible = false)

end

Instance Attribute Details

#height ⇒ Integer (readonly)

Returns get the height of the window.

Returns:

  • (Integer) —

    get the height of the window



1010
1011
1012
# File 'LiteRGSS.rb.yard.rb', line 1010

def height
  @height
end

#icon=(value) ⇒ Image (writeonly)

Returns Set the icon of the window.

Returns:

  • (Image) —

    Set the icon of the window



1024
1025
1026
# File 'LiteRGSS.rb.yard.rb', line 1024

def icon=(value)
  @icon = value
end

#openGL_version ⇒ Array<Integer> (readonly)

Returns Major & Minor version number of the currently running OpenGL version.

Returns:

  • (Array<Integer>) —

    Major & Minor version number of the currently running OpenGL version



1039
1040
1041
# File 'LiteRGSS.rb.yard.rb', line 1039

def openGL_version
  @openGL_version
end

#settings ⇒ Array(title, width, height, scale, bpp, fps, vsync, fullscreen, visible_mouse)

Returns:

  • (Array(title, width, height, scale, bpp, fps, vsync, fullscreen, visible_mouse))


1033
1034
1035
# File 'LiteRGSS.rb.yard.rb', line 1033

def settings
  @settings
end

#shader ⇒ Shader

Returns Set the global shader applied to the final content of the window (shader is applied with total pixel size and not native pixel size).

Returns:

  • (Shader) —

    Set the global shader applied to the final content of the window (shader is applied with total pixel size and not native pixel size)



1022
1023
1024
# File 'LiteRGSS.rb.yard.rb', line 1022

def shader
  @shader
end

#width ⇒ Integer (readonly)

Returns get the width of the window.

Returns:

  • (Integer) —

    get the width of the window



1008
1009
1010
# File 'LiteRGSS.rb.yard.rb', line 1008

def width
  @width
end

#x ⇒ Integer

Returns X coordinate of the window on the desktop.

Returns:

  • (Integer) —

    X coordinate of the window on the desktop



1035
1036
1037
# File 'LiteRGSS.rb.yard.rb', line 1035

def x
  @x
end

#y ⇒ Integer

Returns Y coordinate of the window on the desktop.

Returns:

  • (Integer) —

    Y coordinate of the window on the desktop



1037
1038
1039
# File 'LiteRGSS.rb.yard.rb', line 1037

def y
  @y
end

Class Method Details

.desktop_height ⇒ Integer

Get the desktop height

Returns:

  • (Integer)


1226
1227
1228
# File 'LiteRGSS.rb.yard.rb', line 1226

def self.desktop_height

end

.desktop_width ⇒ Integer

Get the desktop width

Returns:

  • (Integer)


1221
1222
1223
# File 'LiteRGSS.rb.yard.rb', line 1221

def self.desktop_width

end

.list_resolutions ⇒ Array

List all the resolution available on the current device

Returns:

  • (Array) —

    [[width1, height1], [width2, height2], ...]



1216
1217
1218
# File 'LiteRGSS.rb.yard.rb', line 1216

def self.list_resolutions

end

.max_texture_size ⇒ Integer

Maximum size of the texture for the device the OpenGL context are currently running over

Returns:

  • (Integer)


973
974
# File 'LiteRGSS.rb.yard.rb', line 973

def self.max_texture_size
end

Instance Method Details

#dispose

Dispose the window and forcefully close it



989
990
991
# File 'LiteRGSS.rb.yard.rb', line 989

def dispose

end

#on_closed=(proc)

Define the event called when the on close event is detected

Examples:

Prevent the user from closing the window if $no_close is true

win.on_close = proc do
  next false if $no_close


1044
1045
1046
# File 'LiteRGSS.rb.yard.rb', line 1044

def on_closed=(proc)

end

#on_gained_focus=(proc)

Define the event called when the window gains focus

Examples:

Detect that the window gained focus

win.on_gained_focus = proc do
  puts "Focus gained"
end


1071
1072
1073
# File 'LiteRGSS.rb.yard.rb', line 1071

def on_gained_focus=(proc)

end

#on_joystick_button_pressed=(proc)

Define the event called when a button is pressed on a joystick

Examples:

Detect the button press of a joystick

win.on_joystick_button_pressed = proc do |joy_id, button|
  puts "Joystick button ##{button} on stick ##{joy_id} was pressed"
end


1147
1148
1149
# File 'LiteRGSS.rb.yard.rb', line 1147

def on_joystick_button_pressed=(proc)

end

#on_joystick_button_released=(proc)

Define the event called when a button is released on a joystick

Examples:

Detect a button release of a joystick

win.on_joystick_button_released = proc do |joy_id, button|
  puts "Joystick button ##{button} on stick ##{joy_id} was released"
end


1155
1156
1157
# File 'LiteRGSS.rb.yard.rb', line 1155

def on_joystick_button_released=(proc)

end

#on_joystick_connected=(proc)

Define the event called when a joystick gets plugged in

Examples:

Detect a joystick connection

win.on_joystick_connected = proc do |joy_id|
  puts "Joystick #{joy_id} connected!"
end


1171
1172
1173
# File 'LiteRGSS.rb.yard.rb', line 1171

def on_joystick_connected=(proc)

end

#on_joystick_disconnected=(proc)

Define the event called when a joystick gets unplugged

Examples:

Detect a joystick disconnection

win.on_joystick_disconnected = proc do |joy_id|
  puts "Joystick #{joy_id} disconnected!"
end


1179
1180
1181
# File 'LiteRGSS.rb.yard.rb', line 1179

def on_joystick_disconnected=(proc)

end

#on_joystick_moved=(proc)

Define the event called when a joystick axis is moved

Examples:

Detect a joystick axis movement

win.on_joystick_moved = proc do |joy_id, axis, position|
  puts "Axis #{axis} of joystick ##{joy_id} moved to #{position}"
end


1163
1164
1165
# File 'LiteRGSS.rb.yard.rb', line 1163

def on_joystick_moved=(proc)

end

#on_key_pressed=(proc)

Define the event called when a key is pressed

Examples:

Detect the key press

win.on_key_pressed = proc do |key, alt, control, shift, system|
  puts "User pressed #{key} with following state: a:#{alt}, c:#{control}, s:#{shift}, sys:#{system}"
end


1087
1088
1089
# File 'LiteRGSS.rb.yard.rb', line 1087

def on_key_pressed=(proc)

end

#on_key_released=(proc)

Define the event called when a key is released

Examples:

Detect the key release

win.on_key_released = proc do |key|
  puts "User released #{key}"
end


1095
1096
1097
# File 'LiteRGSS.rb.yard.rb', line 1095

def on_key_released=(proc)

end

#on_lost_focus=(proc)

Define the event called when the window lost focus

Examples:

Detect that the window lost focus

win.on_lost_focus = proc do
  puts "Lost focus"
end


1063
1064
1065
# File 'LiteRGSS.rb.yard.rb', line 1063

def on_lost_focus=(proc)

end

#on_mouse_button_pressed=(proc)

Define the event called when a mouse key is pressed

Examples:

Detect a mouse press event

win.on_mouse_button_pressed = proc do |button|
  puts "Mouse button pressed: #{button}"
end


1111
1112
1113
# File 'LiteRGSS.rb.yard.rb', line 1111

def on_mouse_button_pressed=(proc)

end

#on_mouse_button_released=(proc)

Define the event called when a mouse key is released

Examples:

Detect a mouse key released event

win.on_mouse_button_released = proc do |button|
  puts "Mouse button released: #{button}"
end


1119
1120
1121
# File 'LiteRGSS.rb.yard.rb', line 1119

def on_mouse_button_released=(proc)

end

#on_mouse_entered=(proc)

Define the event called when the mouse enters the window

Examples:

Detect a mouse enter event

win.on_mouse_entered = proc { puts "Mouse entered the screen" }


1133
1134
1135
# File 'LiteRGSS.rb.yard.rb', line 1133

def on_mouse_entered=(proc)

end

#on_mouse_left=(proc)

Define the event called when the mouse leaves the window

Examples:

Detect a move left event

win.on_mouse_left = proc { puts "Mouse left the screen" }


1139
1140
1141
# File 'LiteRGSS.rb.yard.rb', line 1139

def on_mouse_left=(proc)

end

#on_mouse_moved=(proc)

Define the event called when the mouse moves

Examples:

Detect a mouse moved event

win.on_mouse_moved = proc|x, y|
  puts "Mouse moved to: (#{x}, #{y})"
end


1127
1128
1129
# File 'LiteRGSS.rb.yard.rb', line 1127

def on_mouse_moved=(proc)

end

#on_mouse_wheel_scrolled=(proc)

Define the event called when the mouse wheel is scrolled

Examples:

Detect a mouse wheel event

win.on_mouse_wheel_scrolled = proc do |wheel, delta|
  puts "Mouse wheel ##{wheel} scrolled #{delta}"
end


1103
1104
1105
# File 'LiteRGSS.rb.yard.rb', line 1103

def on_mouse_wheel_scrolled=(proc)

end

#on_resized=(proc)

next true end Define the event called when the resize event is detected

Examples:

Detect that the window was resize

win.on_resized = proc do |width, height|
  puts "Resized to : (#{width}, #{height})"
end


1055
1056
1057
# File 'LiteRGSS.rb.yard.rb', line 1055

def on_resized=(proc)

end

#on_sensor_changed=(proc)

Define the event called when a sensor event was triggered

Examples:

Detect a sensor change

win.on_sensor_changed = proc do |sensor_type, x, y, z|
  puts "Sensor #{sensor_type} changed to: (#{x}, #{y}, #{z})"
end


1211
1212
1213
# File 'LiteRGSS.rb.yard.rb', line 1211

def on_sensor_changed=(proc)

end

#on_text_entered=(proc)

Define the event called when a text entry is detected on the window (usally a character representing the UTF-8 pressed key)

Examples:

Detect the text entered

win.on_text_entered = proc do |text|
  puts "User entered : #{text}"
end


1079
1080
1081
# File 'LiteRGSS.rb.yard.rb', line 1079

def on_text_entered=(proc)

end

#on_touch_began=(proc)

Define the event called when a touch event has begun

Examples:

Detect a touch event that begins

win.on_touch_began = proc do |finger_id, x, y|
  puts "Touch ##{finger_id} started on: (#{x}, #{y})"
end


1187
1188
1189
# File 'LiteRGSS.rb.yard.rb', line 1187

def on_touch_began=(proc)

end

#on_touch_ended=(proc)

Define the event called when the touche ended

Examples:

Detect a touch end event

win.on_touch_ended = proc do |finger_id, x, y|
  puts "Touch ##{finger_id} ended on: (#{x}, #{y})"
end


1203
1204
1205
# File 'LiteRGSS.rb.yard.rb', line 1203

def on_touch_ended=(proc)

end

#on_touch_moved=(proc)

Define the event called when the touch moved

Examples:

Detect a touch moved example

win.on_touch_moved = proc do |finger_id, x, y|
  puts "Touch ##{finger_id} moved to: (#{x}, #{y})"
end


1195
1196
1197
# File 'LiteRGSS.rb.yard.rb', line 1195

def on_touch_moved=(proc)

end

#resize_screen(width, height) ⇒ self

Change the window screen size but keep every other parameter in the same settings

Parameters:

  • width (Integer)
  • height (Integer)

Returns:

  • (self)


1029
1030
1031
# File 'LiteRGSS.rb.yard.rb', line 1029

def resize_screen(width, height)

end

#snap_to_bitmap ⇒ Bitmap

Take a snapshot of the window content

Returns:



1004
1005
1006
# File 'LiteRGSS.rb.yard.rb', line 1004

def snap_to_bitmap

end

#sort_z ⇒ self

Update window internal order according to z of each entities

Returns:

  • (self)


999
1000
1001
# File 'LiteRGSS.rb.yard.rb', line 999

def sort_z

end

#update ⇒ self

Update window content & events. This method might wait for vsync before updating events

Returns:

  • (self)


994
995
996
# File 'LiteRGSS.rb.yard.rb', line 994

def update

end

#update_no_input ⇒ self

Update the window content. This method might wait for vsync before returning

Returns:

  • (self)


1013
1014
1015
# File 'LiteRGSS.rb.yard.rb', line 1013

def update_no_input

end

#update_only_input ⇒ self

Update the window event without drawing anything.

Returns:

  • (self)


1018
1019
1020
# File 'LiteRGSS.rb.yard.rb', line 1018

def update_only_input

end