
local elapsed_time = gh_utils.get_elapsed_time();

gh_renderer.set_depth_test_state(1)

gh_camera.set_position(camera, 0, 0, 40)
gh_camera.set_lookat(camera, 0, 0, 0, 1)
gh_camera.bind(camera)

gh_renderer.clear_color_depth_buffers(0.3, 0.4, 0.5, 1.0, 1.0) 

-- gh_renderer.wireframe()
-- gh_renderer.point()


gh_gpu_program.bind(clip_plane_prog)
gh_gpu_program.uniform1i(clip_plane_prog, "tex0", 0)
gh_gpu_program.uniform4f(clip_plane_prog, "light_position", 10, 50, 50, 1)

-- Plane equation: Ax + By + Cz + D = 0
gh_gpu_program.uniform4f(clip_plane_prog, "clip_plane", 0, 0, -1, 7)

gh_renderer.enable_state("GL_CLIP_DISTANCE0")

gh_texture.bind(tex01, 0)
gh_object.set_euler_angles(mesh_torus, elapsed_time*20, elapsed_time*50, elapsed_time*10)
gh_object.render(mesh_torus)

gh_renderer.disable_state("GL_CLIP_DISTANCE0")

-- gh_renderer.solid()
    



---[[
libfont_clear()

local y_offset = 40

libfont_print(20, y_offset, 1, 0.5, 0, 1, "Geometry Shaders - User Clip Planes")
y_offset = y_offset + 20

y_offset = y_offset + 20
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 + 20


libfont_render()
--]]
  
    
  
