-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlovr_minimal.lua
44 lines (35 loc) · 1.13 KB
/
lovr_minimal.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
UI2D = require "ui2d..ui2d"
lovr.graphics.setBackgroundColor( 0.2, 0.2, 0.7 )
function lovr.load()
-- Initialize the library. You can optionally pass a font size. Default is 14.
UI2D.Init( "lovr" )
end
function lovr.keypressed( key, scancode, repeating )
UI2D.KeyPressed( key, repeating )
end
function lovr.textinput( text, code )
UI2D.TextInput( text )
end
function lovr.keyreleased( key, scancode )
UI2D.KeyReleased()
end
function lovr.wheelmoved( deltaX, deltaY )
UI2D.WheelMoved( deltaX, deltaY )
end
function lovr.update( dt )
-- This gets input information for the library.
UI2D.InputInfo()
end
function lovr.draw( pass )
pass:setProjection( 1, mat4():orthographic( pass:getDimensions() ) )
-- Every window should be contained in a Begin/End block.
UI2D.Begin( "My Window", 200, 200 )
UI2D.Button( "My First Button" )
UI2D.End( pass )
-- This marks the end of the GUI.
-- RenderFrame returns a table of passes generated by UI2D.
-- Insert the main pass into that table and call lovr.graphics.submit.
local ui_passes = UI2D.RenderFrame( pass )
table.insert( ui_passes, pass )
return lovr.graphics.submit( ui_passes )
end