Objectified lights, cleanup and messification.

This commit is contained in:
2018-03-19 08:44:07 -05:00
parent 62364b2145
commit 4818d5a67e
4 changed files with 52 additions and 40 deletions

View File

@@ -44,7 +44,7 @@ class IMICFPS
def draw(x, y, z, scale = MODEL_METER_SCALE, back_face_culling = true)
e = glGetError()
if e != GL_NO_ERROR
$stderr.puts "OpenGL error in \"#{desc}\": #{gluErrorString(e)} (#{e})\n"
$stderr.puts "OpenGL error in: #{gluErrorString(e)} (#{e})\n"
exit
end
render(x,y,z, scale, back_face_culling)
@@ -64,16 +64,16 @@ class IMICFPS
glEnableClientState(GL_VERTEX_ARRAY)
glEnableClientState(GL_COLOR_ARRAY)
glEnableClientState(GL_NORMAL_ARRAY)
if false#@model_has_texture
if @model_has_texture
glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, @materials[@textured_material].texture_id)
glEnableClientState(GL_TEXTURE_COORD_ARRAY)
glTexCoordPointer(3, GL_FLOAT, 0, o.flattened_textures.pack("i*"))
glTexCoordPointer(3, GL_FLOAT, 0, o.flattened_textures)
end
glVertexPointer(4, GL_FLOAT, 0, o.flattened_vertices.pack("i*"))
glColorPointer(3, GL_FLOAT, 0, o.flattened_materials.pack("i*"))
glNormalPointer(GL_FLOAT, 0, o.flattened_normals.pack("i*"))
glDrawArrays(GL_TRIANGLES, 0, o.flattened_vertices.count/4)
glVertexPointer(4, GL_FLOAT, 0, o.flattened_vertices)
glColorPointer(3, GL_FLOAT, 0, o.flattened_materials)
glNormalPointer(GL_FLOAT, 0, o.flattened_normals)
glDrawArrays(GL_TRIANGLES, 0, o.flattened_vertices_size/4)
# glBegin(GL_TRIANGLES) # begin drawing model
# o.faces.each do |vert|
# vertex = vert[0]
@@ -93,9 +93,9 @@ class IMICFPS
glDisableClientState(GL_VERTEX_ARRAY)
glDisableClientState(GL_COLOR_ARRAY)
glDisableClientState(GL_NORMAL_ARRAY)
if false#@model_has_texture
if @model_has_texture
glDisableClientState(GL_TEXTURE_COORD_ARRAY)
glBindTexture(GL_TEXTURE_2D, 0)
# glBindTexture(GL_TEXTURE_2D, 0)
glDisable(GL_TEXTURE_2D)
end
glDisable(GL_CULL_FACE) if back_face_culling

View File

@@ -31,12 +31,17 @@ class IMICFPS
end
end
@vertices_list = list
@vertices_list_size = list.size
@vertices_list = list.pack("i*")
end
return @vertices_list
end
def flattened_vertices_size
@vertices_list_size
end
def flattened_materials
unless @materials_list
list = []
@@ -53,7 +58,8 @@ class IMICFPS
end
end
@materials_list = list
@materials_list_size = list.size
@materials_list = list.pack("i*")
end
return @materials_list
@@ -68,11 +74,12 @@ class IMICFPS
list << v.x
list << v.y
list << v.z
# list << v.alpha
# list << v.weight
end
end
@normals_list = list
@normals_list_size = list.size
@normals_list = list.pack("i*")
end
return @normals_list
@@ -89,7 +96,8 @@ class IMICFPS
end
end
@textures_list = list
@textures_list_size = list.size
@textures_list = list.pack("i*")
end
return @textures_list