
winW, winH = gh_window.getsize(0)


if ((buf_A > 0) and (shadertoy_prog_buf_a > 0)) then

  gh_render_target.bind(buf_A)

  gh_gpu_program.bind(shadertoy_prog_buf_a)
  gh_gpu_program.uniform3f(shadertoy_prog_buf_a, "iResolution", winW, winH, 0.0)
  gh_gpu_program.uniform1f(shadertoy_prog_buf_a, "iTime", elapsed_time)
  --gh_gpu_program.uniform1f(shadertoy_prog_buf_a, "iTimeDelta", time_step)
  gh_gpu_program.uniform1f(shadertoy_prog_buf_a, "iTimeDelta", 0.020)
  gh_gpu_program.uniform4f(shadertoy_prog_buf_a, "iMouse", mx, my, 0, 0)
  gh_gpu_program.uniform1i(shadertoy_prog_buf_a, "iFrame", frame)

  gh_gpu_program.uniform1i(shadertoy_prog_buf_a, "uReset", uReset)
  uReset = 0
  
  -- gh_texture.rt_color_bind(buf_A, 0)
  -- gh_gpu_program.uniform1i(shadertoy_prog_buf_a, "iChannel0", 0)
  -- gh_gpu_program.uniform4f(shadertoy_prog_buf_a, "iChannelResolution0", winW, winH, 0.0, 0.0)
  gh_texture.bind(tex0, 0)
  gh_gpu_program.uniform1i(shadertoy_prog_buf_a, "iChannel0", 0)
  gh_texture.bind(tex1, 1)
  gh_gpu_program.uniform1i(shadertoy_prog_buf_a, "iChannel1", 1)

  
  draw_quad(0, 0, winW, winH)  
  
  gh_render_target.unbind(buf_A)
    
end  


if ((img > 0) and (shadertoy_prog_img > 0)) then

  gh_render_target.bind(img)

  gh_gpu_program.bind(shadertoy_prog_img)
  gh_gpu_program.uniform3f(shadertoy_prog_img, "iResolution", winW, winH, 0.0)
  gh_gpu_program.uniform1f(shadertoy_prog_img, "iTime", elapsed_time)
  --gh_gpu_program.uniform1f(shadertoy_prog_img, "iTimeDelta", time_step)
  gh_gpu_program.uniform1f(shadertoy_prog_img, "iTimeDelta", 0.020)
  gh_gpu_program.uniform4f(shadertoy_prog_img, "iMouse", mx, my, 0, 0)

  
  gh_texture.rt_color_bind(buf_A, 0)
  gh_gpu_program.uniform1i(shadertoy_prog_img, "iChannel0", 0)
  --gh_gpu_program.uniform4f(shadertoy_prog_img, "iChannelResolution0", winW, winH, 0.0, 0.0)

  draw_quad(0, 0, winW, winH)  
  
  gh_render_target.unbind(img)
    
end  

