accept_scroll_and_zoom
Serializable::inspect
to show more useful information
more_collections :: more_collections
Highly specific, but useful, collections-related classes.performance_analysis :: performance_analysis
Services to gather information on the performance of events by categoriesserialization :: serialization_core
Abstract services to serialize Nit objects to different formatscore :: union_find
union–find algorithm using an efficient disjoint-set data structureEulerCamera
and App::frame_core_draw
to get a stereoscopic view
# Framework for 3D games in Nit
module depth
import flat
intrude import more_materials
import more_models
import model_dimensions
import particles
import selection
import shadow
redef class App
redef fun create_scene
do
# Move the camera back a bit
world_camera.reset_height(10.0)
world_camera.near = 0.1
super
end
redef fun create_gamnit
do
super
# Cull the invisible triangles in the back of the geometries
glCullFace gl_BACK
# Prepare programs
var programs = [blinn_phong_program, normals_program, explosion_program, smoke_program, static_program, selection_program: GamnitProgram]
for program in programs do
program.compile_and_link
var gamnit_error = program.error
assert gamnit_error == null else print_error gamnit_error
end
end
redef fun frame_core_draw(display) do frame_core_depth display
# Draw all elements of `actors` and then call `frame_core_flat`
protected fun frame_core_depth(display: GamnitDisplay)
do
frame_core_depth_clock.lapse
# Compute shadows
if light isa LightCastingShadows then
frame_core_shadow_prep display
perfs["gamnit depth shadows"].add frame_core_depth_clock.lapse
end
glViewport(0, 0, display.width, display.height)
frame_core_dynamic_resolution_before display
perfs["gamnit depth dynres"].add frame_core_depth_clock.lapse
for actor in actors do
for leaf in actor.model.leaves do
leaf.material.draw(actor, leaf, app.world_camera)
assert glGetError == gl_NO_ERROR else print_error "Gamnit error on material {leaf.material.class_name}"
end
end
perfs["gamnit depth actors"].add frame_core_depth_clock.lapse
frame_core_world_sprites display
perfs["gamnit depth sprites"].add frame_core_depth_clock.lapse
# Toggle writing to the depth buffer for particles effects
glDepthMask false
for system in particle_systems do
system.draw
assert glGetError == gl_NO_ERROR else print_error "OpenGL error in {system}"
end
glDepthMask true
perfs["gamnit depth particles"].add frame_core_depth_clock.lapse
# Stop using the dynamic resolution before drawing UI sprites
frame_core_dynamic_resolution_after display
frame_core_ui_sprites display
perfs["gamnit depth ui_sprites"].add frame_core_depth_clock.lapse
# Debug, show the light point of view
#frame_core_shadow_debug display
end
private var frame_core_depth_clock = new Clock
end
lib/gamnit/depth/depth.nit:15,1--101,3