-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdraw_text.lua
30 lines (21 loc) · 1.01 KB
/
draw_text.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
-- Draw text
hg = require("harfang")
hg.InputInit()
hg.WindowSystemInit()
res_x, res_y = 1280, 720
win = hg.RenderInit('Harfang - Draw Text', res_x, res_y, hg.RF_VSync)
-- load font and shader program
font = hg.LoadFontFromFile('resources_compiled/font/default.ttf', 96)
font_prg = hg.LoadProgramFromFile('resources_compiled/core/shader/font')
-- text uniforms and render state
text_uniform_values = {hg.MakeUniformSetValue('u_color', hg.Vec4(1, 1, 0))}
text_render_state = hg.ComputeRenderState(hg.BM_Alpha, hg.DT_Always, hg.FC_Disabled)
-- main loop
while not hg.ReadKeyboard():Key(hg.K_Escape) and hg.IsWindowOpen(win) do
hg.SetView2D(0, 0, 0, res_x, res_y, -1, 1, hg.CF_Color | hg.CF_Depth, hg.ColorI(32, 32, 32), 0, 1)
hg.DrawText(0, font, 'Hello world!', font_prg, 'u_tex', 0, hg.Mat4.Identity, hg.Vec3(res_x / 2, res_y / 2, 0), hg.DTHA_Center, hg.DTVA_Center, text_uniform_values, {}, text_render_state)
hg.Frame()
hg.UpdateWindow(win)
end
hg.RenderShutdown()
hg.DestroyWindow(win)