Class: RAGE::Viewport
- Inherits:
-
Object
- Object
- RAGE::Viewport
- Defined in:
- lib/rage/viewport.rb
Overview
Viewport is the end user’s view into the world. It is represented on the screen via glViewport and has a camera attached to it managing the viewport’s projection matrix.
Instance Attribute Summary collapse
-
#camera ⇒ Object
Camera attached to viewport.
-
#height ⇒ Object
x,y pos, width, height.
-
#width ⇒ Object
x,y pos, width, height.
-
#x ⇒ Object
x,y pos, width, height.
-
#y ⇒ Object
x,y pos, width, height.
Instance Method Summary collapse
-
#draw ⇒ Object
Invoked during draw cycle to draw viewport and associated camera.
-
#initialize(args = {}) ⇒ Viewport
constructor
Create new Viewport with any of the following optional args, * :x x coordinate of viewport on screen, defaults to 0 * :y y coordinate of viewport on screen, defaults to 0 * :width width of viewport on screen or :max, defaults to :max * :height height of viewport on screen or :max, defaults to :max * :camera camera to attach to viewport, if none provided one is auto created.
Constructor Details
#initialize(args = {}) ⇒ Viewport
Create new Viewport with any of the following optional args,
-
:x x coordinate of viewport on screen, defaults to 0
-
:y y coordinate of viewport on screen, defaults to 0
-
:width width of viewport on screen or :max, defaults to :max
-
:height height of viewport on screen or :max, defaults to :max
-
:camera camera to attach to viewport, if none provided one is auto created
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rage/viewport.rb', line 25 def initialize(args = {}) @x = args[:x] if args.has_key? :x @y = args[:y] if args.has_key? :y @width = args[:width] if args.has_key? :width @height = args[:height] if args.has_key? :height @camera = args[:camera] if args.has_key? :camera @x = 0 if @x.nil? @y = 0 if @y.nil? @width = :max if @width.nil? @height = :max if @height.nil? @camera = Camera.new if @camera.nil? end |
Instance Attribute Details
#camera ⇒ Object
Camera attached to viewport
17 18 19 |
# File 'lib/rage/viewport.rb', line 17 def camera @camera end |
#height ⇒ Object
x,y pos, width, height
14 15 16 |
# File 'lib/rage/viewport.rb', line 14 def height @height end |
#width ⇒ Object
x,y pos, width, height
14 15 16 |
# File 'lib/rage/viewport.rb', line 14 def width @width end |
#x ⇒ Object
x,y pos, width, height
14 15 16 |
# File 'lib/rage/viewport.rb', line 14 def x @x end |
#y ⇒ Object
x,y pos, width, height
14 15 16 |
# File 'lib/rage/viewport.rb', line 14 def y @y end |