-
Notifications
You must be signed in to change notification settings - Fork 0
/
tiled_display.xml
111 lines (74 loc) · 2.96 KB
/
tiled_display.xml
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<glsl_hacker>
<window name="win3d01" title="Tiled Display"
width="800" height="600"
gl_version_major="4" gl_version_minor="4"
build_opengl_extensions_list="0" />
<!-- <gpu_program name="gpu_program" filename_ps="clouds.shadertoy.glsl"> -->
<gpu_program name="gpu_program" filename_ps="tiled_display.glsl">
<raw_data_vs><![CDATA[
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
]]></raw_data_vs>
</gpu_program>
<script name="init_scene" run_mode="INIT" >
<raw_data><![CDATA[
winW, winH = gh_window.getsize()
font_a = gh_utils.font_create("Tahoma", 14)
camera_ortho = gh_camera.create_ortho(-winW/2, winW/2, -winH/2, winH/2, 1.0, -1.0)
gh_camera.set_viewport(camera_ortho, 0, 0, winW, winH)
gh_camera.set_position(camera_ortho, 0, 0, 1)
gpu_prog_01 = gh_node.getid("gpu_program")
local abs_path=0
tex01 = gh_texture.create_from_file("data/tarte_fruits.jpg", 3, abs_path)
vid02 = gh_av.decoder_open("data/FORM.MPG", 1)
tex02 = gh_texture.create_from_file("data/tarte_fruits.jpg", 3, abs_path)
tex03 = gh_texture.create_from_file("data/tarte_fruits.jpg", 3, abs_path)
tex04 = gh_texture.create_from_file("data/tarte_fruits.jpg", 3, abs_path)
mesh_quad = gh_mesh.create_quad(winW, winH)
--gh_object.use_gl2_vertex_array(mesh_quad, 1) -- *** Old OpenGL... ***
gh_renderer.set_vsync(0)
gh_renderer.set_scissor_state(0)
]]></raw_data>
</script>
<script name="update_scene" run_mode="FRAME" >
<raw_data><![CDATA[
elapsed_time = gh_utils.get_elapsed_time()
gh_renderer.set_depth_test_state(1)
gh_camera.bind(camera_ortho)
gh_renderer.clear_color_depth_buffers(0.2, 0.2, 0.2, 1.0, 1.0)
gh_gpu_program.bind(gpu_prog_01)
gh_gpu_program.uniform1f(gpu_prog_01, "iTime", elapsed_time)
gh_gpu_program.uniform3f(gpu_prog_01, "iResolution", winW, winH, 0)
mouse_x, mouse_y = gh_input.mouse_getpos()
gh_gpu_program.uniform4f(gpu_prog_01, "iMouse", mouse_x, winH-mouse_y, 0, 0)
gh_gpu_program.uniform1i(gpu_prog_01, "iChannel0", 0);
gh_gpu_program.uniform1i(gpu_prog_01, "iChannel1", 1);
gh_gpu_program.uniform1i(gpu_prog_01, "iChannel2", 2);
gh_gpu_program.uniform1i(gpu_prog_01, "iChannel3", 3);
gh_texture.bind(tex01, 0)
gh_texture.bind(tex02, 1)
gh_texture.bind(tex03, 2)
gh_texture.bind(tex04, 3)
gh_object.render(mesh_quad)
-- TODO: remove text
gh_utils.font_render(font_a, 10, 20, 0.2, 1.0, 0.0, 1.0, "Tiled Display Demo")
]]></raw_data>
</script>
<script name="resize_scene" run_mode="SIZE" >
<raw_data><![CDATA[
winW, winH = gh_window.getsize(0)
aspect = 1.333
if (winH > 0) then
aspect = winW / winH
end
gh_camera.update_ortho(camera_ortho, -winW/2, winW/2, -winH/2, winH/2, 1.0, -1.0)
gh_camera.set_viewport(camera_ortho, 0, 0, winW, winH)
gh_utils.font_set_viewport_info(font_a, 0, 0, winW, winH)
gh_mesh.update_quad_size(mesh_quad, winW, winH)
]]></raw_data>
</script>
</glsl_hacker>