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"
|
||||
# gem "opengl"
|
||||
gem "opengl-bindings"
|
||||
gem "glu"
|
||||
# gem "glut"
|
||||
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
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
glu (8.3.0)
|
||||
glu (8.3.0-x86-mingw32)
|
||||
chunky_png (1.3.10)
|
||||
glu (8.2.2)
|
||||
glu (8.2.2-x86-mingw32)
|
||||
gosu (0.13.3)
|
||||
gosu (0.13.3-x86-mingw32)
|
||||
oily_png (1.2.1)
|
||||
chunky_png (~> 1.3.7)
|
||||
opengl-bindings (1.6.6)
|
||||
wavefront (0.1.2)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
@@ -15,8 +17,8 @@ PLATFORMS
|
||||
DEPENDENCIES
|
||||
glu
|
||||
gosu
|
||||
oily_png
|
||||
opengl-bindings
|
||||
wavefront
|
||||
|
||||
BUNDLED WITH
|
||||
1.16.1
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -8,8 +8,11 @@ class IMICFPS
|
||||
attr_accessor :number_of_faces, :needs_cursor
|
||||
|
||||
def initialize(window_width = 1280, window_height = 800, fullscreen = false)
|
||||
super(window_width, window_height, fullscreen)
|
||||
# super(Gosu.screen_width, Gosu.screen_height, true)
|
||||
if ARGV.join.include?("--native")
|
||||
super(Gosu.screen_width, Gosu.screen_height, true)
|
||||
else
|
||||
super(window_width, window_height, fullscreen)
|
||||
end
|
||||
$window = self
|
||||
@needs_cursor = false
|
||||
|
||||
@@ -17,6 +20,7 @@ class IMICFPS
|
||||
@number_of_faces = 0
|
||||
@draw_skydome = true
|
||||
@skydome = Wavefront::Model.new("objects/skydome.obj")
|
||||
@plane = Wavefront::Model.new("objects/plane.obj")
|
||||
@cube = Wavefront::Model.new("objects/cube.obj")
|
||||
@model = Wavefront::Model.new("objects/biped.obj")
|
||||
@tree = Wavefront::Model.new("objects/tree.obj")
|
||||
@@ -87,11 +91,12 @@ class IMICFPS
|
||||
|
||||
@skydome.draw(0,0,0, 1, false) if @draw_skydome
|
||||
@cube.draw(0,1,-2, 0.0005)
|
||||
@plane.draw(0,-1,-4, 0.0005, false)
|
||||
@model.draw(1, 0, 0)
|
||||
@tree.draw(5, 0, 0)
|
||||
@tree.draw(5, 0, 3)
|
||||
@tree.draw(3, 0, 10)
|
||||
@mega_model.draw(0,0,0, 1)
|
||||
# @mega_model.draw(0,0,0, 1)
|
||||
end
|
||||
|
||||
# Draw crosshair
|
||||
|
||||
Reference in New Issue
Block a user