Class: RAGE::Window
- Inherits:
-
Object
- Object
- RAGE::Window
- Defined in:
- lib/rage/window.rb
Overview
Manages game window
Class Method Summary collapse
-
.create_viewport(vp_args = {}, &block) ⇒ Object
Create a viewport using specified args and add it to.
-
.draw ⇒ Object
Invoked during draw cycle to draw window.
-
.refresh ⇒ Object
Invoked during draw cycle to refresh window.
-
.set_attrs(args = {}) ⇒ Object
Set attributes on window, which may include * :width * :height.
-
.show ⇒ Object
Display window.
Class Method Details
.create_viewport(vp_args = {}, &block) ⇒ Object
Create a viewport using specified args and add it to
28 29 30 31 32 |
# File 'lib/rage/window.rb', line 28 def self.(vp_args = {}, &block) vp = vp_args, &block << vp return vp end |
.draw ⇒ Object
Invoked during draw cycle to draw window
46 47 48 49 |
# File 'lib/rage/window.rb', line 46 def self.draw Gl.glClear(Gl::GL_COLOR_BUFFER_BIT | Gl::GL_DEPTH_BUFFER_BIT) @@screen.fill_rect(0,0,width,height,@@black.color) end |
.refresh ⇒ Object
Invoked during draw cycle to refresh window
52 53 54 55 56 |
# File 'lib/rage/window.rb', line 52 def self.refresh @@screen.update_rect(0,0,0,0) SDL.GLSwapBuffers() #Gl.glFlush(); end |
.set_attrs(args = {}) ⇒ Object
Set attributes on window, which may include
-
:width
-
:height
20 21 22 23 24 25 |
# File 'lib/rage/window.rb', line 20 def self.set_attrs(args = {}) @@width = args[:width] if args.has_key? :width @@height = args[:height] if args.has_key? :height @@viewports = [] end |
.show ⇒ Object
Display window
35 36 37 38 39 40 41 42 43 |
# File 'lib/rage/window.rb', line 35 def self.show SDL.init(SDL::INIT_VIDEO) SDL.setGLAttr(SDL::GL_DOUBLEBUFFER,1) # make sdl pickup keys being held as multiple key events (TODO make this optional) SDL::Key.enableKeyRepeat(SDL::Key::DEFAULT_REPEAT_DELAY / 2, SDL::Key::DEFAULT_REPEAT_INTERVAL / 2) @@screen = SDL::Screen.open(width,height,32,SDL::OPENGL | SDL::SWSURFACE) @@black = ResourcesManager.instance.load_resource :type => :color, :color => [0,0,0] end |