Class: SDL2::Window
Overview
System Window A rectangular area you can blit into.
Defined Under Namespace
Classes: Data
Constant Summary collapse
- FULLSCREEN =
0x00000001- OPENGL =
0x00000002- SHOWN =
0x00000004- HIDDEN =
0x00000008- BORDERLESS =
0x00000010- RESIZABLE =
0x00000020- MINIMIZED =
0x00000040- MAXIMIZED =
0x00000080- INPUT_GRABBED =
0x00000100- INPUT_FOCUS =
0x00000200- MOUSE_FOCUS =
0x00000400- FULLSCREEN_DESKTOP =
( FULLSCREEN | 0x00001000 )
- FOREIGN =
0x00000800
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
- .create(title = '', x = 0, y = 0, w = 100, h = 100, flags = 0) ⇒ Object
- .create!(*args) ⇒ Object
- .create_from(data) ⇒ Object
- .create_with_renderer(w, h, flags) ⇒ Object
- .from_id(id) ⇒ Object
- .release(pointer) ⇒ Object
Instance Method Summary collapse
- #brightness ⇒ Object
- #brightness=(level) ⇒ Object
- #current_size ⇒ Object
- #current_size=(size) ⇒ Object
- #display ⇒ Object
- #display_index ⇒ Object
- #display_mode ⇒ Object
- #flags ⇒ Object
- #fullscreen=(flags) ⇒ Object
- #grab=(value) ⇒ Object
- #grab? ⇒ Boolean
- #hide ⇒ Object
- #icon=(surface) ⇒ Object
- #id ⇒ Object
-
#initialize(*args, &block) ⇒ Window
constructor
A new instance of Window.
- #maximize ⇒ Object
- #maximum_size ⇒ Object
- #maximum_size=(size) ⇒ Object
- #minimize ⇒ Object
- #minimum_size ⇒ Object
- #minimum_size=(size) ⇒ Object
- #pixel_format ⇒ Object
- #position ⇒ Object
- #position=(location) ⇒ Object
- #raise_above ⇒ Object
- #restore ⇒ Object
- #show ⇒ Object
- #surface ⇒ Object
- #title ⇒ Object
- #title=(value) ⇒ Object
- #update_surface ⇒ Object
- #update_surface! ⇒ Object
Methods inherited from Struct
Constructor Details
#initialize(*args, &block) ⇒ Window
Returns a new instance of Window.
74 75 76 77 |
# File 'lib/sdl2/window.rb', line 74 def initialize(*args, &block) super(*args, &block) @data = Data.new(self) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
72 73 74 |
# File 'lib/sdl2/window.rb', line 72 def data @data end |
Class Method Details
.create(title = '', x = 0, y = 0, w = 100, h = 100, flags = 0) ⇒ Object
79 80 81 |
# File 'lib/sdl2/window.rb', line 79 def self.create(title ='', x = 0, y = 0, w = 100, h = 100, flags = 0) SDL2.create_window(title, x, y, w, h, flags) end |
.create!(*args) ⇒ Object
91 92 93 94 95 |
# File 'lib/sdl2/window.rb', line 91 def self.create!(*args) creation = create(*args) get_error() if creation.null? return creation end |
.create_from(data) ⇒ Object
83 84 85 |
# File 'lib/sdl2/window.rb', line 83 def self.create_from(data) create_window_from(data) end |
.create_with_renderer(w, h, flags) ⇒ Object
97 98 99 100 101 102 103 104 105 |
# File 'lib/sdl2/window.rb', line 97 def self.create_with_renderer(w, h, flags) window = Window.new renderer = Renderer.new if SDL2.create_window_and_renderer(w,h,flags,window,renderer) == 0 [window, renderer] else nil end end |
.from_id(id) ⇒ Object
87 88 89 |
# File 'lib/sdl2/window.rb', line 87 def self.from_id(id) get_window_from_id(id) end |
.release(pointer) ⇒ Object
107 108 109 |
# File 'lib/sdl2/window.rb', line 107 def self.release(pointer) destroy_window(pointer) end |
Instance Method Details
#brightness ⇒ Object
111 112 113 |
# File 'lib/sdl2/window.rb', line 111 def brightness SDL2.get_window_brightness(self) end |
#brightness=(level) ⇒ Object
115 116 117 |
# File 'lib/sdl2/window.rb', line 115 def brightness=(level) SDL2.set_window_brightness(self, level.to_f) end |
#current_size ⇒ Object
205 206 207 208 209 210 |
# File 'lib/sdl2/window.rb', line 205 def current_size() w_struct, h_struct = IntStruct.new, IntStruct.new SDL2::get_window_size(self, w_struct, h_struct) w, h = w_struct[:value], h_struct[:value] [w, h] end |
#current_size=(size) ⇒ Object
212 213 214 |
# File 'lib/sdl2/window.rb', line 212 def current_size=(size) SDL2.set_window_size(self, size[0], size[1]) end |
#display ⇒ Object
133 134 135 |
# File 'lib/sdl2/window.rb', line 133 def display Display[display_index] end |
#display_index ⇒ Object
129 130 131 |
# File 'lib/sdl2/window.rb', line 129 def display_index SDL2.get_window_display_index(self) end |
#display_mode ⇒ Object
119 120 121 122 123 124 125 126 127 |
# File 'lib/sdl2/window.rb', line 119 def display_mode dm = SDL2::Display::Mode.new if SDL2.get_window_display_mode(self, dm) == 0 return dm else dm.pointer.free return nil end end |
#flags ⇒ Object
137 138 139 |
# File 'lib/sdl2/window.rb', line 137 def flags SDL2.get_window_flags(self) end |
#fullscreen=(flags) ⇒ Object
254 255 256 |
# File 'lib/sdl2/window.rb', line 254 def fullscreen=(flags) SDL2.set_window_fullscreen(self, flags) end |
#grab=(value) ⇒ Object
145 146 147 148 149 150 |
# File 'lib/sdl2/window.rb', line 145 def grab=(value) unless value == :true or value == :false value = value ? :true : :false end set_window_grab(self, value) end |
#grab? ⇒ Boolean
141 142 143 |
# File 'lib/sdl2/window.rb', line 141 def grab? get_window_grab(self) == :true end |
#hide ⇒ Object
168 169 170 |
# File 'lib/sdl2/window.rb', line 168 def hide SDL2.hide_window(self) end |
#icon=(surface) ⇒ Object
192 193 194 |
# File 'lib/sdl2/window.rb', line 192 def icon=(surface) set_window_icon(self, surface) end |
#id ⇒ Object
152 153 154 |
# File 'lib/sdl2/window.rb', line 152 def id SDL2.get_window_id(self) end |
#maximize ⇒ Object
172 173 174 |
# File 'lib/sdl2/window.rb', line 172 def maximize SDL2.maximize_window(self) end |
#maximum_size ⇒ Object
216 217 218 219 220 221 |
# File 'lib/sdl2/window.rb', line 216 def maximum_size w_struct, h_struct = IntStruct.new, IntStruct.new SDL2::get_window_maximum_size(self, w_struct, h_struct) w, h = w_struct[:value], h_struct[:value] [w, h] end |
#maximum_size=(size) ⇒ Object
223 224 225 |
# File 'lib/sdl2/window.rb', line 223 def maximum_size=(size) SDL2.set_window_maximum_size(self, size[0], size[1]) end |
#minimize ⇒ Object
176 177 178 |
# File 'lib/sdl2/window.rb', line 176 def minimize SDL2.minimize_window(self) end |
#minimum_size ⇒ Object
227 228 229 230 231 232 |
# File 'lib/sdl2/window.rb', line 227 def minimum_size w_struct, h_struct = IntStruct.new, IntStruct.new SDL2::get_window_minimum_size(self, w_struct, h_struct) w, h = w_struct[:value], h_struct[:value] [w, h] end |
#minimum_size=(size) ⇒ Object
234 235 236 |
# File 'lib/sdl2/window.rb', line 234 def minimum_size=(size) SDL2.set_window_minimum_size(self, size[0], size[1]) end |
#pixel_format ⇒ Object
156 157 158 |
# File 'lib/sdl2/window.rb', line 156 def pixel_format SDL2.get_window_pixel_format(self) end |
#position ⇒ Object
238 239 240 241 242 243 244 |
# File 'lib/sdl2/window.rb', line 238 def position position = [IntStruct.new, IntStruct.new] SDL2::get_window_position(self, position[0], position[1]) x, y = position[0][:value], position[1][:value] position.each{|struct|struct.pointer.free} [x, y] end |
#position=(location) ⇒ Object
246 247 248 |
# File 'lib/sdl2/window.rb', line 246 def position=(location) SDL2::set_window_position(self, location[0],location[1]) end |
#raise_above ⇒ Object
180 181 182 |
# File 'lib/sdl2/window.rb', line 180 def raise_above SDL2.raise_window(self) end |
#restore ⇒ Object
184 185 186 |
# File 'lib/sdl2/window.rb', line 184 def restore SDL2.restore_window(self) end |
#show ⇒ Object
188 189 190 |
# File 'lib/sdl2/window.rb', line 188 def show SDL2.show_window(self) end |
#surface ⇒ Object
250 251 252 |
# File 'lib/sdl2/window.rb', line 250 def surface SDL2.get_window_surface(self) end |
#title ⇒ Object
160 161 162 |
# File 'lib/sdl2/window.rb', line 160 def title SDL2.get_window_title(self) end |
#title=(value) ⇒ Object
164 165 166 |
# File 'lib/sdl2/window.rb', line 164 def title=(value) SDL2.set_window_title(self, value) end |
#update_surface ⇒ Object
196 197 198 |
# File 'lib/sdl2/window.rb', line 196 def update_surface() SDL2.update_window_surface(self) end |
#update_surface! ⇒ Object
200 201 202 203 |
# File 'lib/sdl2/window.rb', line 200 def update_surface!() SDL2.raise_error_unless update_surface == 0 return 0 end |