Class: RAGE::Window

Inherits:
Object
  • Object
show all
Defined in:
lib/rage/window.rb

Overview

Manages game window

Class Method Summary collapse

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.create_viewport(vp_args = {}, &block)
  vp = viewport vp_args, &block
  viewports << vp
  return vp
end

.drawObject

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

.refreshObject

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

.showObject

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