mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 23:52:35 +00:00
Improved shader error formatting, hide puts statements that are only useful in debug mode.
This commit is contained in:
@@ -20,7 +20,7 @@ class IMICFPS
|
|||||||
|
|
||||||
def available_light
|
def available_light
|
||||||
raise "Using to many lights, #{LightManager.light_count}/#{LightManager::MAX_LIGHTS}" if LightManager.light_count > LightManager::MAX_LIGHTS
|
raise "Using to many lights, #{LightManager.light_count}/#{LightManager::MAX_LIGHTS}" if LightManager.light_count > LightManager::MAX_LIGHTS
|
||||||
puts "OpenGL::GL_LIGHT#{LightManager.light_count}"
|
puts "OpenGL::GL_LIGHT#{LightManager.light_count}" if $debug
|
||||||
@light_id = Object.const_get "OpenGL::GL_LIGHT#{LightManager.light_count}"
|
@light_id = Object.const_get "OpenGL::GL_LIGHT#{LightManager.light_count}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ class IMICFPS
|
|||||||
|
|
||||||
if ShaderManager.shader("lighting")
|
if ShaderManager.shader("lighting")
|
||||||
ShaderManager.shader("lighting").use do |shader|
|
ShaderManager.shader("lighting").use do |shader|
|
||||||
|
glUniform3f(shader.variable("SunLight"), 1.0, 1.0, 1.0)
|
||||||
|
|
||||||
handleGlError
|
handleGlError
|
||||||
draw_mesh(object.model)
|
draw_mesh(object.model)
|
||||||
object.draw
|
object.draw
|
||||||
|
|||||||
@@ -10,10 +10,12 @@ class IMICFPS
|
|||||||
@compiled = false
|
@compiled = false
|
||||||
|
|
||||||
@error_buffer_size = 1024
|
@error_buffer_size = 1024
|
||||||
|
@variable_missing = {}
|
||||||
|
|
||||||
create_shaders
|
create_shaders
|
||||||
compile_shaders
|
compile_shaders
|
||||||
|
|
||||||
|
# Only add shader to ShaderManager if it successfully compiles
|
||||||
if @compiled
|
if @compiled
|
||||||
ShaderManager.add_shader(@name, self)
|
ShaderManager.add_shader(@name, self)
|
||||||
else
|
else
|
||||||
@@ -51,9 +53,12 @@ class IMICFPS
|
|||||||
if compiled == 0
|
if compiled == 0
|
||||||
log = ' ' * @error_buffer_size
|
log = ' ' * @error_buffer_size
|
||||||
glGetShaderInfoLog(@vertex, @error_buffer_size, nil, log)
|
glGetShaderInfoLog(@vertex, @error_buffer_size, nil, log)
|
||||||
puts "Vertex Shader InfoLog:\n#{log.strip}\n"
|
puts "Shader Error: Program \"#{@name}\""
|
||||||
puts "Shader Compiled status: #{compiled}"
|
puts " Vertex Shader InfoLog:", " #{log.strip.split("\n").join("\n ")}\n\n"
|
||||||
|
puts " Shader Compiled status: #{compiled}"
|
||||||
|
puts " NOTE: assignment of uniforms in shaders is illegal!"
|
||||||
puts
|
puts
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
glCompileShader(@fragment)
|
glCompileShader(@fragment)
|
||||||
@@ -64,9 +69,12 @@ class IMICFPS
|
|||||||
if compiled == 0
|
if compiled == 0
|
||||||
log = ' ' * @error_buffer_size
|
log = ' ' * @error_buffer_size
|
||||||
glGetShaderInfoLog(@fragment, @error_buffer_size, nil, log)
|
glGetShaderInfoLog(@fragment, @error_buffer_size, nil, log)
|
||||||
puts "Fragment Shader InfoLog:\n#{log.strip}\n"
|
puts "Shader Error: Program \"#{@name}\""
|
||||||
puts "Shader Compiled status: #{compiled}"
|
puts " Fragment Shader InfoLog:", " #{log.strip.split("\n").join("\n ")}\n\n"
|
||||||
|
puts " Shader Compiled status: #{compiled}"
|
||||||
|
puts " NOTE: assignment of uniforms in shader is illegal!"
|
||||||
puts
|
puts
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@program = glCreateProgram
|
@program = glCreateProgram
|
||||||
@@ -81,7 +89,8 @@ class IMICFPS
|
|||||||
if linked == 0
|
if linked == 0
|
||||||
log = ' ' * @error_buffer_size
|
log = ' ' * @error_buffer_size
|
||||||
glGetProgramInfoLog(@program, @error_buffer_size, nil, log)
|
glGetProgramInfoLog(@program, @error_buffer_size, nil, log)
|
||||||
puts "Program InfoLog:\n#{log.strip}\n"
|
puts "Shader Error: Program \"#{@name}\""
|
||||||
|
puts " Program InfoLog:", " #{log.strip.split("\n").join("\n ")}\n\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
@compiled = linked == 0 ? false : true
|
@compiled = linked == 0 ? false : true
|
||||||
@@ -91,7 +100,8 @@ class IMICFPS
|
|||||||
def variable(variable)
|
def variable(variable)
|
||||||
loc = glGetUniformLocation(@program, variable)
|
loc = glGetUniformLocation(@program, variable)
|
||||||
if (loc == -1)
|
if (loc == -1)
|
||||||
puts "Shader:\"#{@name}\" No such uniform named #{variable}"
|
puts "Shader Error: Program \"#{@name}\" has no such uniform named \"#{variable}\"", " Is it used in the shader? GLSL may have optimized it out.", " Is it miss spelled?" unless @variable_missing[variable]
|
||||||
|
@variable_missing[variable] = true
|
||||||
end
|
end
|
||||||
return loc
|
return loc
|
||||||
end
|
end
|
||||||
@@ -100,8 +110,13 @@ class IMICFPS
|
|||||||
return unless compiled?
|
return unless compiled?
|
||||||
glUseProgram(@program)
|
glUseProgram(@program)
|
||||||
|
|
||||||
block.call(self) if block
|
if block
|
||||||
|
block.call(self)
|
||||||
|
stop
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def stop
|
||||||
glUseProgram(0)
|
glUseProgram(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class IMICFPS
|
|||||||
add_asset(:obj, "objects/biped.obj")
|
add_asset(:obj, "objects/biped.obj")
|
||||||
|
|
||||||
# Currently broken
|
# Currently broken
|
||||||
# Shader.new(name: "lighting", vertex_file: "shaders/vertex/lighting.glsl", fragment_file: "shaders/fragment/lighting.glsl")
|
Shader.new(name: "lighting", vertex_file: "shaders/vertex/lighting.glsl", fragment_file: "shaders/fragment/lighting.glsl")
|
||||||
|
|
||||||
@act = false
|
@act = false
|
||||||
@cycled = false
|
@cycled = false
|
||||||
|
|||||||
@@ -53,14 +53,14 @@ class IMICFPS
|
|||||||
|
|
||||||
parse
|
parse
|
||||||
|
|
||||||
puts "#{@file_path.split('/').last} took #{((Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)-start_time)/1000.0).round(2)} seconds to parse"
|
puts "#{@file_path.split('/').last} took #{((Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)-start_time)/1000.0).round(2)} seconds to parse" if $debug
|
||||||
|
|
||||||
# populate_buffers
|
# populate_buffers
|
||||||
|
|
||||||
face_count = 0
|
face_count = 0
|
||||||
@objects.each {|o| face_count+=o.faces.size}
|
@objects.each {|o| face_count+=o.faces.size}
|
||||||
@objects.each_with_index do |o, i|
|
@objects.each_with_index do |o, i|
|
||||||
puts " Model::Object Name: #{o.name}, Faces: #{o.faces.size}"
|
puts " Model::Object Name: #{o.name}, Faces: #{o.faces.size}" if $debug
|
||||||
end
|
end
|
||||||
$window.number_of_faces+=face_count
|
$window.number_of_faces+=face_count
|
||||||
@model_has_texture = false
|
@model_has_texture = false
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class IMICFPS
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Total Lines: #{lines}"
|
puts "Total Lines: #{lines}" if $debug
|
||||||
calculate_bounding_box(@vertices, @bounding_box)
|
calculate_bounding_box(@vertices, @bounding_box)
|
||||||
@objects.each do |o|
|
@objects.each do |o|
|
||||||
calculate_bounding_box(o.vertices, o.bounding_box)
|
calculate_bounding_box(o.vertices, o.bounding_box)
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
# version 150
|
# version 150
|
||||||
# extension GL_ARB_explicit_attrib_location : enable
|
# extension GL_ARB_explicit_attrib_location : enable
|
||||||
|
|
||||||
layout(location = 0) in vec3 vert;
|
in vec3 vert;
|
||||||
|
uniform vec3 SunLight;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = vec4(vert, 1.0);
|
gl_Position = vec4(vert, 1.0);
|
||||||
|
|||||||
Reference in New Issue
Block a user