
local demo_dir = gh_utils.get_demo_dir()
    
local lib_dir = gh_utils.get_scripting_libs_dir() 		
dofile(lib_dir .. "lua/gx_cam_lib_v1.lua")
dofile(lib_dir .. "lua/libfont/libfont1.lua")   
dofile(lib_dir .. "lua/imgui.lua")    
dofile(lib_dir .. "lua/gxl.lua")  


winW, winH = gh_window.getsize(0)


win_hovered = 0


camera_ortho = gxl.create_camera_2d(winW, winH, 1.0, 10.0)






electrical_arc_prog = gh_node.getid("electrical_arc_prog")
gh_gpu_program.uniform1i(electrical_arc_prog, "tex0", 0)







local PF_U8_RGB = 1
local PF_U8_RGBA = 3
local PF_F32_RGBA = 6
local pixel_format = PF_U8_RGBA
local gen_mipmaps = 1
local compressed_texture = 0

local filename = demo_dir .. "textures/20190201-ROG-mechanical-eye.jpg"
tex0 = gh_texture.create_from_file_v6(filename, pixel_format, gen_mipmaps, compressed_texture)


filename = demo_dir .. "textures/noise_001.jpg"
tex_noise = gh_texture.create_from_file_v6(filename, pixel_format, gen_mipmaps, compressed_texture)





--quad = gh_mesh.create_quad(winW*0.8, winH*0.8)
quad = gh_mesh.create_quad(winW, winH)







local absolute_path = 0
local stream = 0 
-- https://freesound.org/people/Sergenious/sounds/55829/
--sound = gh_audio.sound_create("sound/55829__sergenious__electric.wav", absolute_path, stream)

-- http://www.universal-soundbank.com/electricite.htm
sound = gh_audio.sound_create("sound/arc-electrique-7918.mp3", absolute_path, stream)
gh_audio.sound_set_loop_state(sound, 1)
channel = gh_audio.sound_play(sound)
gh_audio.sound_set_volume(sound, channel, 0.9)






gh_renderer.set_vsync(1)

last_time = gh_utils.get_elapsed_time()


gl_renderer = gh_renderer.get_renderer_model()
gl_version = gh_renderer.get_api_version()


fps_time = 0
fps = 0
frames = 0

noise_volume = 0.8

arc_x = 0.63
line_size = 0.005
noise_scale = 0.025

bkgcolor = {r=0.2, g=0.2, b=0.2, a=1.0}
arc_color1 = {r=1.0, g=0.12, b=0.0, a=1.0}
arc_color2 = {r=0.0, g=0.7, b=1.0, a=1.0}