mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 15:42:35 +00:00
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:
2
Gemfile
2
Gemfile
@@ -1,7 +1,5 @@
|
|||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
# gem "opengl"
|
|
||||||
gem "opengl-bindings"
|
gem "opengl-bindings"
|
||||||
gem "glu"
|
gem "glu"
|
||||||
# gem "glut"
|
# gem "glut"
|
||||||
gem "gosu"
|
gem "gosu"
|
||||||
gem "wavefront" # Gem for opening blender or blender exported object with texturing
|
|
||||||
|
|||||||
10
Gemfile.lock
10
Gemfile.lock
@@ -1,12 +1,14 @@
|
|||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
glu (8.3.0)
|
chunky_png (1.3.10)
|
||||||
glu (8.3.0-x86-mingw32)
|
glu (8.2.2)
|
||||||
|
glu (8.2.2-x86-mingw32)
|
||||||
gosu (0.13.3)
|
gosu (0.13.3)
|
||||||
gosu (0.13.3-x86-mingw32)
|
gosu (0.13.3-x86-mingw32)
|
||||||
|
oily_png (1.2.1)
|
||||||
|
chunky_png (~> 1.3.7)
|
||||||
opengl-bindings (1.6.6)
|
opengl-bindings (1.6.6)
|
||||||
wavefront (0.1.2)
|
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
@@ -15,8 +17,8 @@ PLATFORMS
|
|||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
glu
|
glu
|
||||||
gosu
|
gosu
|
||||||
|
oily_png
|
||||||
opengl-bindings
|
opengl-bindings
|
||||||
wavefront
|
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.16.1
|
1.16.1
|
||||||
|
|||||||
@@ -17,19 +17,20 @@ class IMICFPS
|
|||||||
puts "#{name} texture #{texture_path}"
|
puts "#{name} texture #{texture_path}"
|
||||||
@texture = Gosu::Image.new(texture_path, retro: true)
|
@texture = Gosu::Image.new(texture_path, retro: true)
|
||||||
array_of_pixels = @texture.to_blob
|
array_of_pixels = @texture.to_blob
|
||||||
if @texture.gl_tex_info
|
|
||||||
@texture_id = @texture.gl_tex_info.tex_name
|
tex_names_buf = ' ' * 8
|
||||||
else
|
glGenTextures(1, tex_names_buf)
|
||||||
puts "Allocating..."
|
@texture_id = tex_names_buf.unpack('L2').first
|
||||||
tex_names_buf = ' ' * 8
|
|
||||||
glGenTextures(1, tex_names_buf)
|
|
||||||
@texture_id = tex_names_buf.unpack('L2').first
|
|
||||||
end
|
|
||||||
glBindTexture(GL_TEXTURE_2D, @texture_id)
|
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)
|
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)
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR)
|
||||||
glGenerateMipmap(GL_TEXTURE_2D)
|
glGenerateMipmap(GL_TEXTURE_2D)
|
||||||
|
|
||||||
|
@texture = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def texture_id
|
def texture_id
|
||||||
|
|||||||
@@ -49,11 +49,12 @@ class IMICFPS
|
|||||||
def flattened_textures
|
def flattened_textures
|
||||||
unless @textures_list
|
unless @textures_list
|
||||||
list = []
|
list = []
|
||||||
@faces.each do |face|
|
@faces.each_with_index do |face, i|
|
||||||
[face[1]].each do |v|
|
[face[1]].each do |v|
|
||||||
next unless v
|
next unless v
|
||||||
list << v.x
|
list << v.x
|
||||||
list << v.y
|
list << v.y
|
||||||
|
list << v.z
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ class IMICFPS
|
|||||||
file = File.open(@object_path.sub(File.basename(@object_path), '')+@material_file, 'r')
|
file = File.open(@object_path.sub(File.basename(@object_path), '')+@material_file, 'r')
|
||||||
file.readlines.each do |line|
|
file.readlines.each do |line|
|
||||||
array = line.strip.split(' ')
|
array = line.strip.split(' ')
|
||||||
# puts array.join
|
|
||||||
case array.first
|
case array.first
|
||||||
when 'newmtl'
|
when 'newmtl'
|
||||||
material = Material.new(array.last)
|
material = Material.new(array.last)
|
||||||
@@ -143,7 +142,7 @@ class IMICFPS
|
|||||||
if array.size == 4
|
if array.size == 4
|
||||||
texture = Vertex.new(Float(array[1]), 1-Float(array[2]), Float(array[3]))
|
texture = Vertex.new(Float(array[1]), 1-Float(array[2]), Float(array[3]))
|
||||||
elsif array.size == 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
|
else
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,8 +8,11 @@ class IMICFPS
|
|||||||
attr_accessor :number_of_faces, :needs_cursor
|
attr_accessor :number_of_faces, :needs_cursor
|
||||||
|
|
||||||
def initialize(window_width = 1280, window_height = 800, fullscreen = false)
|
def initialize(window_width = 1280, window_height = 800, fullscreen = false)
|
||||||
super(window_width, window_height, fullscreen)
|
if ARGV.join.include?("--native")
|
||||||
# super(Gosu.screen_width, Gosu.screen_height, true)
|
super(Gosu.screen_width, Gosu.screen_height, true)
|
||||||
|
else
|
||||||
|
super(window_width, window_height, fullscreen)
|
||||||
|
end
|
||||||
$window = self
|
$window = self
|
||||||
@needs_cursor = false
|
@needs_cursor = false
|
||||||
|
|
||||||
@@ -17,6 +20,7 @@ class IMICFPS
|
|||||||
@number_of_faces = 0
|
@number_of_faces = 0
|
||||||
@draw_skydome = true
|
@draw_skydome = true
|
||||||
@skydome = Wavefront::Model.new("objects/skydome.obj")
|
@skydome = Wavefront::Model.new("objects/skydome.obj")
|
||||||
|
@plane = Wavefront::Model.new("objects/plane.obj")
|
||||||
@cube = Wavefront::Model.new("objects/cube.obj")
|
@cube = Wavefront::Model.new("objects/cube.obj")
|
||||||
@model = Wavefront::Model.new("objects/biped.obj")
|
@model = Wavefront::Model.new("objects/biped.obj")
|
||||||
@tree = Wavefront::Model.new("objects/tree.obj")
|
@tree = Wavefront::Model.new("objects/tree.obj")
|
||||||
@@ -87,11 +91,12 @@ class IMICFPS
|
|||||||
|
|
||||||
@skydome.draw(0,0,0, 1, false) if @draw_skydome
|
@skydome.draw(0,0,0, 1, false) if @draw_skydome
|
||||||
@cube.draw(0,1,-2, 0.0005)
|
@cube.draw(0,1,-2, 0.0005)
|
||||||
|
@plane.draw(0,-1,-4, 0.0005, false)
|
||||||
@model.draw(1, 0, 0)
|
@model.draw(1, 0, 0)
|
||||||
@tree.draw(5, 0, 0)
|
@tree.draw(5, 0, 0)
|
||||||
@tree.draw(5, 0, 3)
|
@tree.draw(5, 0, 3)
|
||||||
@tree.draw(3, 0, 10)
|
@tree.draw(3, 0, 10)
|
||||||
@mega_model.draw(0,0,0, 1)
|
# @mega_model.draw(0,0,0, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Draw crosshair
|
# Draw crosshair
|
||||||
|
|||||||
Reference in New Issue
Block a user