mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 15:42: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
|
||||
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}"
|
||||
end
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ class IMICFPS
|
||||
|
||||
if ShaderManager.shader("lighting")
|
||||
ShaderManager.shader("lighting").use do |shader|
|
||||
glUniform3f(shader.variable("SunLight"), 1.0, 1.0, 1.0)
|
||||
|
||||
handleGlError
|
||||
draw_mesh(object.model)
|
||||
object.draw
|
||||
|
||||
@@ -10,10 +10,12 @@ class IMICFPS
|
||||
@compiled = false
|
||||
|
||||
@error_buffer_size = 1024
|
||||
@variable_missing = {}
|
||||
|
||||
create_shaders
|
||||
compile_shaders
|
||||
|
||||
# Only add shader to ShaderManager if it successfully compiles
|
||||
if @compiled
|
||||
ShaderManager.add_shader(@name, self)
|
||||
else
|
||||
@@ -51,9 +53,12 @@ class IMICFPS
|
||||
if compiled == 0
|
||||
log = ' ' * @error_buffer_size
|
||||
glGetShaderInfoLog(@vertex, @error_buffer_size, nil, log)
|
||||
puts "Vertex Shader InfoLog:\n#{log.strip}\n"
|
||||
puts "Shader Compiled status: #{compiled}"
|
||||
puts "Shader Error: Program \"#{@name}\""
|
||||
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
|
||||
return
|
||||
end
|
||||
|
||||
glCompileShader(@fragment)
|
||||
@@ -64,9 +69,12 @@ class IMICFPS
|
||||
if compiled == 0
|
||||
log = ' ' * @error_buffer_size
|
||||
glGetShaderInfoLog(@fragment, @error_buffer_size, nil, log)
|
||||
puts "Fragment Shader InfoLog:\n#{log.strip}\n"
|
||||
puts "Shader Compiled status: #{compiled}"
|
||||
puts "Shader Error: Program \"#{@name}\""
|
||||
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
|
||||
return
|
||||
end
|
||||
|
||||
@program = glCreateProgram
|
||||
@@ -81,7 +89,8 @@ class IMICFPS
|
||||
if linked == 0
|
||||
log = ' ' * @error_buffer_size
|
||||
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
|
||||
|
||||
@compiled = linked == 0 ? false : true
|
||||
@@ -91,7 +100,8 @@ class IMICFPS
|
||||
def variable(variable)
|
||||
loc = glGetUniformLocation(@program, variable)
|
||||
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
|
||||
return loc
|
||||
end
|
||||
@@ -100,8 +110,13 @@ class IMICFPS
|
||||
return unless compiled?
|
||||
glUseProgram(@program)
|
||||
|
||||
block.call(self) if block
|
||||
if block
|
||||
block.call(self)
|
||||
stop
|
||||
end
|
||||
end
|
||||
|
||||
def stop
|
||||
glUseProgram(0)
|
||||
end
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class IMICFPS
|
||||
add_asset(:obj, "objects/biped.obj")
|
||||
|
||||
# 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
|
||||
@cycled = false
|
||||
|
||||
@@ -53,14 +53,14 @@ class IMICFPS
|
||||
|
||||
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
|
||||
|
||||
face_count = 0
|
||||
@objects.each {|o| face_count+=o.faces.size}
|
||||
@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
|
||||
$window.number_of_faces+=face_count
|
||||
@model_has_texture = false
|
||||
|
||||
@@ -50,7 +50,7 @@ class IMICFPS
|
||||
end
|
||||
end
|
||||
|
||||
puts "Total Lines: #{lines}"
|
||||
puts "Total Lines: #{lines}" if $debug
|
||||
calculate_bounding_box(@vertices, @bounding_box)
|
||||
@objects.each do |o|
|
||||
calculate_bounding_box(o.vertices, o.bounding_box)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# version 150
|
||||
# extension GL_ARB_explicit_attrib_location : enable
|
||||
|
||||
layout(location = 0) in vec3 vert;
|
||||
in vec3 vert;
|
||||
uniform vec3 SunLight;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(vert, 1.0);
|
||||
|
||||
Reference in New Issue
Block a user