Class: GlStuff::Lighting

Inherits:
Object
  • Object
show all
Defined in:
lib/examples/GlStuff/lighting.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLighting

Returns a new instance of Lighting.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/examples/GlStuff/lighting.rb', line 9

def initialize
  @ambient = [ 0.0, 1.0, 0.0, 1.0 ]
  @diffuse = [ 1.0, 1.0, 1.0, 1.0 ]
  @position = MemoryPointer.new(:float, 4).put_array_of_float(0, [1.0, 5.0, 1.0, 1.0])
  @lmodel_ambient = [ 0.4, 0.4, 0.4, 1.0 ]
  @no_mat = [ 0.0, 0.0, 0.0, 1.0 ]
  @mat_ambient = [ 0.7, 0.7, 0.7, 1.0 ]
  @mat_ambient_color = [ 0.8, 0.8, 0.2, 1.0 ]
  @mat_diffuse = [ 0.1, 0.5, 0.0, 1.0 ]
  @mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
  @no_shininess = [ 0.0 ]
  @low_shininess = [ 5.0 ]
  @high_shininess = [ 100.0 ]
  @mat_emission = [0.3, 0.2, 0.2, 0.0]
  @local_view = [ 0.0 ]
end

Instance Attribute Details

#ambientObject

Returns the value of attribute ambient.



5
6
7
# File 'lib/examples/GlStuff/lighting.rb', line 5

def ambient
  @ambient
end

#diffuseObject

Returns the value of attribute diffuse.



5
6
7
# File 'lib/examples/GlStuff/lighting.rb', line 5

def diffuse
  @diffuse
end

#high_shininessObject

Returns the value of attribute high_shininess.



5
6
7
# File 'lib/examples/GlStuff/lighting.rb', line 5

def high_shininess
  @high_shininess
end

#lmodel_ambientObject

Returns the value of attribute lmodel_ambient.



5
6
7
# File 'lib/examples/GlStuff/lighting.rb', line 5

def lmodel_ambient
  @lmodel_ambient
end

#local_viewObject

Returns the value of attribute local_view.



5
6
7
# File 'lib/examples/GlStuff/lighting.rb', line 5

def local_view
  @local_view
end

#low_shininessObject

Returns the value of attribute low_shininess.



5
6
7
# File 'lib/examples/GlStuff/lighting.rb', line 5

def low_shininess
  @low_shininess
end

#mat_ambientObject

Returns the value of attribute mat_ambient.



5
6
7
# File 'lib/examples/GlStuff/lighting.rb', line 5

def mat_ambient
  @mat_ambient
end

#mat_ambient_colorObject

Returns the value of attribute mat_ambient_color.



5
6
7
# File 'lib/examples/GlStuff/lighting.rb', line 5

def mat_ambient_color
  @mat_ambient_color
end

#mat_diffuseObject

Returns the value of attribute mat_diffuse.



5
6
7
# File 'lib/examples/GlStuff/lighting.rb', line 5

def mat_diffuse
  @mat_diffuse
end

#mat_emissionObject

Returns the value of attribute mat_emission.



5
6
7
# File 'lib/examples/GlStuff/lighting.rb', line 5

def mat_emission
  @mat_emission
end

#mat_specularObject

Returns the value of attribute mat_specular.



5
6
7
# File 'lib/examples/GlStuff/lighting.rb', line 5

def mat_specular
  @mat_specular
end

#no_matObject

Returns the value of attribute no_mat.



5
6
7
# File 'lib/examples/GlStuff/lighting.rb', line 5

def no_mat
  @no_mat
end

#no_shininessObject

Returns the value of attribute no_shininess.



5
6
7
# File 'lib/examples/GlStuff/lighting.rb', line 5

def no_shininess
  @no_shininess
end

#positionObject

Returns the value of attribute position.



5
6
7
# File 'lib/examples/GlStuff/lighting.rb', line 5

def position
  @position
end

Instance Method Details

#setupObject



26
27
28
29
30
31
# File 'lib/examples/GlStuff/lighting.rb', line 26

def setup
  glEnable(GL_LIGHTING)
  glEnable(GL_LIGHT0)
  glShadeModel(GL_SMOOTH);
  glLightfv(GL_LIGHT0, GL_POSITION, @position)
end