Class: Hate::Graphics::Shapes::Base
- Inherits:
-
Object
- Object
- Hate::Graphics::Shapes::Base
- Defined in:
- lib/hate/graphics/shapes.rb
Instance Attribute Summary collapse
-
#c ⇒ Object
readonly
Returns the value of attribute c.
-
#memory ⇒ Object
Returns the value of attribute memory.
-
#ra ⇒ Object
readonly
Returns the value of attribute ra.
-
#rx ⇒ Object
readonly
Returns the value of attribute rx.
-
#ry ⇒ Object
readonly
Returns the value of attribute ry.
-
#rz ⇒ Object
readonly
Returns the value of attribute rz.
-
#size ⇒ Object
Returns the value of attribute size.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
-
#z ⇒ Object
readonly
Returns the value of attribute z.
Instance Method Summary collapse
- #color(r = 0.0, g = 0.0, b = 0.0) ⇒ Object
- #compile ⇒ Object
- #destroy ⇒ Object
-
#initialize(s = 1.0) ⇒ Base
constructor
A new instance of Base.
- #rotate(a = 0.0, x = 0.0, y = 0.0, z = 0.0) ⇒ Object
- #run ⇒ Object
- #translate(x = 0.0, y = 0.0, z = 0.0) ⇒ Object
Constructor Details
#initialize(s = 1.0) ⇒ Base
Returns a new instance of Base.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/hate/graphics/shapes.rb', line 12 def initialize(s=1.0) @size = s @memory = nil compile translate rotate color end |
Instance Attribute Details
#c ⇒ Object (readonly)
Returns the value of attribute c.
10 11 12 |
# File 'lib/hate/graphics/shapes.rb', line 10 def c @c end |
#memory ⇒ Object
Returns the value of attribute memory.
7 8 9 |
# File 'lib/hate/graphics/shapes.rb', line 7 def memory @memory end |
#ra ⇒ Object (readonly)
Returns the value of attribute ra.
9 10 11 |
# File 'lib/hate/graphics/shapes.rb', line 9 def ra @ra end |
#rx ⇒ Object (readonly)
Returns the value of attribute rx.
9 10 11 |
# File 'lib/hate/graphics/shapes.rb', line 9 def rx @rx end |
#ry ⇒ Object (readonly)
Returns the value of attribute ry.
9 10 11 |
# File 'lib/hate/graphics/shapes.rb', line 9 def ry @ry end |
#rz ⇒ Object (readonly)
Returns the value of attribute rz.
9 10 11 |
# File 'lib/hate/graphics/shapes.rb', line 9 def rz @rz end |
#size ⇒ Object
Returns the value of attribute size.
7 8 9 |
# File 'lib/hate/graphics/shapes.rb', line 7 def size @size end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
8 9 10 |
# File 'lib/hate/graphics/shapes.rb', line 8 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
8 9 10 |
# File 'lib/hate/graphics/shapes.rb', line 8 def y @y end |
#z ⇒ Object (readonly)
Returns the value of attribute z.
8 9 10 |
# File 'lib/hate/graphics/shapes.rb', line 8 def z @z end |
Instance Method Details
#color(r = 0.0, g = 0.0, b = 0.0) ⇒ Object
33 34 35 36 |
# File 'lib/hate/graphics/shapes.rb', line 33 def color(r=0.0, g=0.0, b=0.0) @c = [r, g, b] self end |
#compile ⇒ Object
38 39 40 41 42 43 |
# File 'lib/hate/graphics/shapes.rb', line 38 def compile @memory = glGenLists(1) if @memory.nil? glNewList(@memory, GL_COMPILE) build glEndList end |
#destroy ⇒ Object
55 56 57 58 |
# File 'lib/hate/graphics/shapes.rb', line 55 def destroy glDeleteLists(@memory) @memory = nil end |
#rotate(a = 0.0, x = 0.0, y = 0.0, z = 0.0) ⇒ Object
28 29 30 31 |
# File 'lib/hate/graphics/shapes.rb', line 28 def rotate(a=0.0, x=0.0, y=0.0, z=0.0) @ra, @rx, @ry, @rz = a, x, y, z self end |
#run ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/hate/graphics/shapes.rb', line 45 def run glLoadIdentity glPushMatrix glColor3f(@c[0], @c[1], @c[2]) glTranslatef(@x, @y, @z) glRotatef(@ra, @rx, @ry, @rz) @memory.nil? ? build : glCallList(@memory) glPopMatrix end |
#translate(x = 0.0, y = 0.0, z = 0.0) ⇒ Object
23 24 25 26 |
# File 'lib/hate/graphics/shapes.rb', line 23 def translate(x=0.0, y=0.0, z=0.0) @x, @y, @z = x, y, z self end |