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


gh_renderer.set_depth_test_state(0)
gh_camera.bind(camera)
gh_renderer.clear_color_buffer(0.2, 0.2, 0.2, 1.0)


gh_texture.bind(tex01, 0)

if (webcam1 > 0) then
  gh_utils.webcam_grab_frame(webcam1)
  gh_utils.webcam_update_texture(webcam1, tex01)
end
  

gh_gpu_program.bind(texture_prog)

VideoQuadResize(winW, winH, 1.0)
gh_object.render(mesh_quad)






libfont_clear()

local y_offset = 40

libfont_print(20, y_offset, 1.0, 1.0, 0, 1, "Webcam demo")
y_offset = y_offset + 30


local hms_str, hour, min, sec = gh_utils.time_to_hour_min_sec(elapsed_time)
libfont_print(20, y_offset, 0.7, 0.7, 0.7, 1, string.format("elapsed time: %s", hms_str))
y_offset = y_offset + 30


if (webcam1 > 0) then
  libfont_print(20, y_offset, 0.7, 0.7, 0.7, 1, "Webcam info")
  y_offset = y_offset + 20

  libfont_print(20, y_offset, 0.7, 0.7, 0.7, 1, string.format("- name: %s", webcam_name))
  y_offset = y_offset + 20

  libfont_print(20, y_offset, 0.7, 0.7, 0.7, 1, string.format("- resolution: %d x %d", frame_w, frame_h))
  y_offset = y_offset + 20

else
  libfont_print(20, y_offset, 1.0, 0.5, 0.0, 1, "*** This demo works on Windows platform only ***")
end


libfont_render()



