--
-- small demonstrator for Lua binding on pixwerx
--

-- loading our libraries
pw.script:load_all()

print("hello pixwerx!")

local w = pw.window.new()
--w.visible = false

-- set title
w.title = "pixwerx 0.1"

-- set size
w.size = pw.size.new(640,480)

-- move window
w.position = pw.point.new(100,100)

print("client size after resize: ",w.client_size.width,w.client_size.height)

local pl = pw.pipeline.new()
if pl:create(w.client_size) then
    print("pipeline ok")
else
    print("pipeline failed")
end

-- setup a lua callback function as callback
w.on_update = function(self)
    pl:draw()
	-- print("test on update",w.position.x,w.position.y,pw.time.now)
end

-- show all displays
local ds = pw.display:all()
for i = 1,#ds do
    print("display ",i,ds[i].name)
end

local t = pw.time.new()

w.visible = true

while w:update() do
    -- somehow works
    if (pw.input.get().input_string == 'f') then
        w.fullscreen = not w.fullscreen
    end

    -- keycode for quit
    if (pw.input.get().input_string == 'q') then
        break;
    end

    -- just to check
    if (pw.input:get().mouse_button == 1) then
        print("elapsed",t.elapsed)
            t:reset()
        print(pw.input:get().mouse_position.x,pw.input:get().mouse_position.y,w.client_size.width,w.client_size.height)
    end

--     print("update")
end

--local scene = pw:scene.new()

