
local elapsed_time = gh_utils.get_elapsed_time()
local dt = elapsed_time - last_time
last_time = elapsed_time


gh_renderer.set_depth_test_state(1)

gx_camera.update(camera, dt)
gh_camera.bind(camera)


gh_renderer.clear_color_depth_buffers(0.2, 0.25, 0.3, 1.0, 1.0)



if (model > 0) then

  local gpu_prog = phong_prog
  
  if (num_loaded_textures > 0) then
    gpu_prog = phong_texture_prog
  end

  gh_gpu_program.bind(gpu_prog)
  gh_gpu_program.uniform4f(gpu_prog, "light_position", 50, 200, 100, 1.0)
  if (num_loaded_textures > 0) then
    gh_gpu_program.uniform4f(gpu_prog, "light_ambient", 0.6, 0.6, 0.6, 1.0)
    gh_gpu_program.uniform4f(gpu_prog, "light_diffuse", 1.0, 1.0, 1.0, 1.0)
  else
    gh_gpu_program.uniform4f(gpu_prog, "light_ambient", 0.2, 0.2, 0.2, 1.0)
    gh_gpu_program.uniform4f(gpu_prog, "light_diffuse", 0.7, 0.7, 1.0, 1.0)
  end


  gh_object.set_position(model, 0, 0, 0)
  gh_object.set_euler_angles(model, 0, 0, 0)
  gh_object.set_scale(model, 2.0, 2.0, 2.0)
  gh_object.render(model)
end





gh_gpu_program.bind(vertex_color)
gh_object.render(grid)






---[[
libfont_clear()

local y_offset = 40

libfont_print(20, y_offset, 1, 0.5, 0, 1, "glTF object loading")
y_offset = y_offset + 40

libfont_print(20, y_offset, 1, 1, 0, 1, string.format("number of vertices: %.0f", num_vertices))
y_offset = y_offset + 40


libfont_print(20, y_offset, 1, 1, 0, 1, "GL_RENDERER")
y_offset = y_offset + 20
libfont_print(20, y_offset, 1, 1, 1, 1, "> " .. gl_renderer)
y_offset = y_offset + 20

libfont_print(20, y_offset, 1, 1, 0, 1, "GL_VERSION")
y_offset = y_offset + 20
libfont_print(20, y_offset, 1, 1, 1, 1, "> " .. gl_version)
y_offset = y_offset + 40

libfont_render()
  --]]
    
  