app :: App :: frame_core_shadow_debug
The shadow depth texture is a square that can be deformed by this projection.
# Draw the light view in the bottom left of the screen, for debugging only
#
# The shadow depth texture is a square that can be deformed by this projection.
protected fun frame_core_shadow_debug(display: GamnitDisplay)
do
if not supports_shadows then
print_error "Error: Shadows are not supported by the current hardware configuration"
return
end
perf_clock_shadow.lapse
var program = shadow_debug_program
glBindBuffer(gl_ARRAY_BUFFER, shadow_context.buffer_array)
glViewport(0, 0, display.width/3, display.height/3)
glClear gl_DEPTH_BUFFER_BIT
program.use
# Uniforms
glActiveTexture gl_TEXTURE0
glBindTexture(gl_TEXTURE_2D, shadow_context.depth_texture)
program.texture.uniform 0
# Attributes
var sizeof_gl_float = 4
var n_floats = 3
glEnableVertexAttribArray program.coord.location
glVertexAttribPointeri(program.coord.location, n_floats, gl_FLOAT, false, 0, 0)
var offset = 4 * n_floats * sizeof_gl_float
n_floats = 2
glEnableVertexAttribArray program.tex_coord.location
glVertexAttribPointeri(program.tex_coord.location, n_floats, gl_FLOAT, false, 0, offset)
var gl_error = glGetError
assert gl_error == gl_NO_ERROR else print_error gl_error
# Draw
glDrawArrays(gl_TRIANGLE_STRIP, 0, 4)
gl_error = glGetError
assert gl_error == gl_NO_ERROR else print_error gl_error
# Take down
glBindBuffer(gl_ARRAY_BUFFER, 0)
gl_error = glGetError
assert gl_error == gl_NO_ERROR else print_error gl_error
sys.perfs["gamnit shadow debug"].add app.perf_clock_shadow.lapse
end
lib/gamnit/depth/shadow.nit:131,2--179,4