Added Texture object for handling creating and caching textures, stubbed ParticleEmitter

This commit is contained in:
2020-03-23 08:05:40 -05:00
parent 45021a92aa
commit 18a62b81cc
8 changed files with 82 additions and 32 deletions

View File

@@ -13,23 +13,7 @@ class IMICFPS
end
def set_texture(texture_path)
# puts "#{name} texture #{texture_path}"
@texture = Gosu::Image.new(texture_path, retro: false)
array_of_pixels = @texture.to_blob
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_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
@texture_id = Texture.new(texture_path).id
end
end
end