mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 15:42:35 +00:00
Broke everything
This commit is contained in:
@@ -3,19 +3,20 @@ class IMICFPS
|
||||
include GL
|
||||
include GLU
|
||||
include GLUT
|
||||
Point = Struct.new(:x, :y)
|
||||
|
||||
def initialize(window_width = 1280, window_height = 800, fullscreen = false)
|
||||
# super(window_width, window_height, fullscreen)
|
||||
super(Gosu.screen_width, Gosu.screen_height, true)
|
||||
super(window_width, window_height, fullscreen)
|
||||
# super(Gosu.screen_width, Gosu.screen_height, true)
|
||||
$window = self
|
||||
@level = Object.new("objects/cube.obj")
|
||||
# @level = Object.new("objects/sponza.obj")
|
||||
@camera = Object::Vertex.new(0,-1,0)
|
||||
@camera_target = Object::Vertex.new(0,-1,0)
|
||||
@model = Wavefront::Model.new("objects/cube.obj")
|
||||
# @model = Object.new("objects/sponza.obj")
|
||||
@camera = Wavefront::Model::Vertex.new(0,-1,0)
|
||||
@camera_target = Wavefront::Model::Vertex.new(0,-1,0)
|
||||
@speed = 0.05
|
||||
@angle_y = 0 # |
|
||||
@angle_x = 0 # _
|
||||
@mouse = Object::Vertex.new(Gosu.screen_width/2,Gosu.screen_height/2,0)
|
||||
@mouse = Point.new(Gosu.screen_width/2, Gosu.screen_height/2)
|
||||
self.mouse_x, self.mouse_y = Gosu.screen_width/2, Gosu.screen_height/2
|
||||
|
||||
@font = Gosu::Font.new(18, name: "DejaVu Sans")
|
||||
@@ -56,10 +57,6 @@ class IMICFPS
|
||||
glEnable(GL_LIGHTING)
|
||||
glEnable(GL_LIGHT0)
|
||||
glEnable(GL_DEPTH_TEST)
|
||||
glEnable(GL_CULL_FACE)
|
||||
|
||||
glEnable(GL_COLOR_MATERIAL)
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE)
|
||||
|
||||
# glRotatef(@angle_y,0,1,0)
|
||||
# glRotatef(@angle_x,1,0,0)
|
||||
@@ -68,23 +65,9 @@ class IMICFPS
|
||||
gluLookAt(@camera.x,@camera.y,@camera.z, @angle_x,@angle_y,0, 0,1,0)
|
||||
|
||||
color = [@c1, @c2, @c3]
|
||||
glBegin(GL_TRIANGLES) # begin drawing model
|
||||
@level.faces.each do |vert|
|
||||
vertex = vert[0]
|
||||
normal = vert[1]
|
||||
@model.draw
|
||||
|
||||
glColor3f(color[0], color[1], color[2])
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [@c1, @c2, @c3, 1.0])
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [@c1, @c2, @c3, 1.0])
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [1,1,1,1])
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, [10.0])
|
||||
|
||||
glNormal3f(normal.x, normal.y, normal.z)
|
||||
glVertex3f(vertex.x, vertex.y, vertex.z)
|
||||
end
|
||||
glEnd
|
||||
end
|
||||
|
||||
@text.split("~").each_with_index do |bit, i|
|
||||
@font.draw(bit.strip, 10, @font.height*i, Float::INFINITY)
|
||||
end
|
||||
@@ -98,11 +81,11 @@ class IMICFPS
|
||||
~
|
||||
Angle Y: #{@angle_y} Angle X: #{@angle_x} ~
|
||||
X:#{@camera.x} Y:#{@camera.y} Z:#{@camera.z} ~
|
||||
Mesh Vert Array: #{@level.faces.size} ~
|
||||
Model Faces: #{@model.faces_count} ~
|
||||
Last Frame: #{Gosu.milliseconds-@last_frame_time}ms (#{Gosu.fps} fps)"
|
||||
@last_frame_time = Gosu.milliseconds
|
||||
|
||||
# $window.caption = "Gosu OBJ Level - FPS:#{Gosu.fps}"
|
||||
# $window.caption = "Gosu OBJ object - FPS:#{Gosu.fps}"
|
||||
@angle_x-=Integer(@mouse.x-self.mouse_x)
|
||||
@angle_y-=Integer(@mouse.y-self.mouse_y)
|
||||
@angle_x = @angle_x.clamp(-360, 360)
|
||||
|
||||
Reference in New Issue
Block a user