forked from harfang3d/tutorials-hg2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender_resize_to_window.py
31 lines (21 loc) · 1.01 KB
/
render_resize_to_window.py
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
# How to resize the render window.
import harfang as hg
hg.InputInit()
hg.WindowSystemInit()
res_x, res_y = 512, 512
win = hg.RenderInit('Harfang - Render Resize to Window', res_x, res_y, hg.RF_VSync | hg.RF_MSAA4X)
# create model
vtx_layout = hg.VertexLayoutPosFloatNormUInt8()
cube_mdl = hg.CreateCubeModel(vtx_layout, 1, 1, 1)
cube_prg = hg.LoadProgramFromFile('resources_compiled/shaders/mdl')
# main loop
while not hg.ReadKeyboard().Key(hg.K_Escape) and hg.IsWindowOpen(win):
render_was_reset, res_x, res_y = hg.RenderResetToWindow(win, res_x, res_y, hg.RF_VSync | hg.RF_MSAA4X | hg.RF_MaxAnisotropy)
if render_was_reset:
print('Render reset to %dx%d' % (res_x, res_y))
viewpoint = hg.TransformationMat4(hg.Vec3(1, 1, -2), hg.Deg3(24, -27, 0))
hg.SetViewPerspective(0, 0, 0, res_x, res_y, viewpoint, 0.01, 100, 1.8, hg.CF_Color | hg.CF_Depth, hg.ColorI(64, 64, 64), 1, 0)
hg.DrawModel(0, cube_mdl, cube_prg, [], [], hg.TranslationMat4(hg.Vec3(0, 0, 0)))
hg.Frame()
hg.UpdateWindow(win)
hg.RenderShutdown()