Disabled glut, got scaling working as desired.

This commit is contained in:
2018-03-18 15:36:36 -05:00
parent 906e1775e5
commit 47a27c15d3
3 changed files with 9 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
require "opengl" require "opengl"
require "glu" require "glu"
require "glut" # require "glut"
require "gosu" require "gosu"
require "fiddle" require "fiddle"

View File

@@ -2,7 +2,7 @@ class IMICFPS
class Wavefront class Wavefront
class Model class Model
include GL include GL
include GLU # include GLU
TextureCoordinate = Struct.new(:u, :v, :weight) TextureCoordinate = Struct.new(:u, :v, :weight)
Vertex = Struct.new(:x, :y, :z, :weight) Vertex = Struct.new(:x, :y, :z, :weight)
Color = Struct.new(:red, :green, :blue, :alpha) Color = Struct.new(:red, :green, :blue, :alpha)
@@ -42,7 +42,10 @@ class IMICFPS
end end
def render(x,y,z, scale = 1) def render(x,y,z, scale = 1)
glEnable(GL_NORMALIZE)
glPushMatrix
glTranslatef(x,y,z) glTranslatef(x,y,z)
glScalef(scale, scale, scale)
@objects.each_with_index do |o, i| @objects.each_with_index do |o, i|
glEnable(GL_CULL_FACE) glEnable(GL_CULL_FACE)
glEnable(GL_COLOR_MATERIAL) glEnable(GL_COLOR_MATERIAL)
@@ -63,12 +66,14 @@ class IMICFPS
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [material.specular.red, material.specular.green, material.specular.blue, 1.0]) glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [material.specular.red, material.specular.green, material.specular.blue, 1.0])
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, [10.0]) glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, [10.0])
glNormal3f(normal.x, normal.y, normal.z) # Don't scale normals glNormal3f(normal.x, normal.y, normal.z) # Don't scale normals
glVertex3f(vertex.x*scale, vertex.y*scale, vertex.z*scale) # glVertex3f(vertex.x*scale, vertex.y*scale, vertex.z*scale)
glVertex3f(vertex.x, vertex.y, vertex.z)
end end
glEnd glEnd
glDisable(GL_CULL_FACE) glDisable(GL_CULL_FACE)
glDisable(GL_COLOR_MATERIAL) glDisable(GL_COLOR_MATERIAL)
end end
glPopMatrix
end end
def parse def parse

View File

@@ -2,7 +2,7 @@ class IMICFPS
class Window < Gosu::Window class Window < Gosu::Window
include GL include GL
include GLU include GLU
include GLUT # include GLUT
Point = Struct.new(:x, :y) Point = Struct.new(:x, :y)
def initialize(window_width = 1280, window_height = 800, fullscreen = false) def initialize(window_width = 1280, window_height = 800, fullscreen = false)