Textures work! that 3 was only getting 2... Added --native to lunch game at native resolution and fullscreen. Added basic plane.

This commit is contained in:
2018-03-20 11:18:16 -05:00
parent afc039ffe6
commit e26796f42c
6 changed files with 27 additions and 21 deletions

View File

@@ -17,19 +17,20 @@ class IMICFPS
puts "#{name} texture #{texture_path}"
@texture = Gosu::Image.new(texture_path, retro: true)
array_of_pixels = @texture.to_blob
if @texture.gl_tex_info
@texture_id = @texture.gl_tex_info.tex_name
else
puts "Allocating..."
tex_names_buf = ' ' * 8
glGenTextures(1, tex_names_buf)
@texture_id = tex_names_buf.unpack('L2').first
end
tex_names_buf = ' ' * 8
glGenTextures(1, tex_names_buf)
@texture_id = tex_names_buf.unpack('L2').first
glBindTexture(GL_TEXTURE_2D, @texture_id)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, @texture.width, @texture.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, array_of_pixels)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR)
glGenerateMipmap(GL_TEXTURE_2D)
@texture = nil
end
def texture_id

View File

@@ -49,11 +49,12 @@ class IMICFPS
def flattened_textures
unless @textures_list
list = []
@faces.each do |face|
@faces.each_with_index do |face, i|
[face[1]].each do |v|
next unless v
list << v.x
list << v.y
list << v.z
end
end

View File

@@ -59,7 +59,6 @@ class IMICFPS
file = File.open(@object_path.sub(File.basename(@object_path), '')+@material_file, 'r')
file.readlines.each do |line|
array = line.strip.split(' ')
# puts array.join
case array.first
when 'newmtl'
material = Material.new(array.last)
@@ -143,7 +142,7 @@ class IMICFPS
if array.size == 4
texture = Vertex.new(Float(array[1]), 1-Float(array[2]), Float(array[3]))
elsif array.size == 3
texture = Vertex.new(Float(array[1]), 1-Float(array[2]), 0.0)
texture = Vertex.new(Float(array[1]), 1-Float(array[2]), 1.0)
else
raise
end