/
main-opengl.xml
201 lines (118 loc) · 5.28 KB
/
main-opengl.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<glsl_hacker>
<window name="win3d01" title="ImGui > Lot of Windows > OpenGL"
width="1280" height="720" resizable="1" menubar="1"
gl_version_major="2" gl_version_minor="1" />
<script name="init_scene" run_mode="INIT" >
<raw_data><![CDATA[
local demo_dir = gh_utils.get_demo_dir()
local lib_dir = gh_utils.get_scripting_libs_dir()
-- ImGui constants.
dofile(lib_dir .. "lua/imgui.lua")
winW, winH = gh_window.getsize()
gh_imgui.init()
bkg_color = {r=0.2, g=0.2, b=0.2, a=1.0}
gh_renderer.set_vsync(0)
os_info = gh_utils.get_os_info()
renderer_model = gh_renderer.get_renderer_model()
api_name = gh_renderer.get_api_name()
api_version = gh_renderer.get_api_version()
imgui_version = gh_imgui.get_version()
local app_version_major, app_version_minor, app_version_patch, app_version_build = gh_utils.get_app_version()
geexlab_version_str = string.format("%d.%d.%d.%d", app_version_major, app_version_minor, app_version_patch, app_version_build)
imgui_can_show_metrics_window = 0
if ((app_version_major >= 0) and (app_version_minor >= 25) and (app_version_patch >= 2)) then
imgui_can_show_metrics_window = 1
end
]]></raw_data>
</script>
<script name="terminate_scene" run_mode="TERMINATE" >
<raw_data><![CDATA[
gh_imgui.terminate()
]]></raw_data>
</script>
<script name="update_scene" run_mode="FRAME" >
<raw_data><![CDATA[
local elapsed_time = gh_utils.get_elapsed_time()
local dt = gh_utils.get_time_step()
gh_renderer.set_viewport(0, 0, winW, winH)
gh_renderer.clear_color_depth_buffers(bkg_color.r, bkg_color.g, bkg_color.b, bkg_color.a, 1.0)
local LEFT_BUTTON = 1
local mouse_left_button = gh_input.mouse_get_button_state(LEFT_BUTTON)
local RIGHT_BUTTON = 2
local mouse_right_button = gh_input.mouse_get_button_state(RIGHT_BUTTON)
local mouse_x, mouse_y = gh_input.mouse_get_position()
--[[
local mouse_wheel = 0
local mouse_wheel_delta = gh_input.mouse_get_wheel_delta()
if (mouse_wheel_delta ~= 0) then
if (mouse_wheel_delta > 0) then
mouse_wheel = mouse_wheel + 1
elseif (mouse_wheel_delta < 0) then
mouse_wheel = mouse_wheel - 1
end
end
gh_input.mouse_reset_wheel_delta()
--]]
----------------------------------------------------------------------------
-- ImGui beginning ---------------------------------------------------------
--
gh_imgui.frame_begin_v2(winW, winH, mouse_x, mouse_y, mouse_left_button, mouse_right_button, 0, dt)
-- Flags for window style, window position and window size.
--
local pos_size_flag_always = 1 -- Always set the pos and/or size
local pos_size_flag_once = 2 -- Set the pos and/or size once per runtime session (only the first call with succeed)
local pos_size_flag_first_use_ever = 4 -- Set the pos and/or size if the window has no saved data (if doesn't exist in the .ini file)
local pos_size_flag_appearing = 8 -- Set the pos and/or size if the window is appearing after being hidden/inactive (or the first time)
ImGuiWindowFlags_NoResize = 2 -- Disable user resizing with the lower-right grip
ImGuiWindowFlags_NoMove = 4 -- Disable user moving the window
local window_flags = 6
local window_width = 100
local window_height = 100
local num_windows_y = (winH / window_height) + 1
local num_windows_x = (winW / window_width) + 1
local window_counter = 0
local posy = 5
for y=1, num_windows_y do
local posx = 5
for x=1, num_windows_x do
window_counter = window_counter + 1
local window_name = "window " .. window_counter
gh_imgui.window_begin(window_name, window_width, window_height, posx, posy, window_flags, pos_size_flag_always, pos_size_flag_always)
local time_str = string.format("%.1f sec", elapsed_time + window_counter)
gh_imgui.text_rgba("GeeXLab", 1.0, 1.0, 0.0, 1.0)
gh_imgui.text_rgba("OpenGL", 0.4, 0.8, 1.0, 1.0)
gh_imgui.text_rgba("> " .. time_str, 0.4, 0.6, 0.8, 1.0)
for k=1, 4 do
local x = window_counter + k
gh_imgui.text_rgba("K::" .. x, 0.4, 0.6, 0.8, 1.0)
end
gh_imgui.window_end()
posx = posx + window_width + 5
end
posy = posy + window_height + 5
end
gh_imgui.window_begin("GeeXLab test", 400, 200, 50, 50, 0, pos_size_flag_once, pos_size_flag_once)
gh_imgui.text("GeeXLab " .. geexlab_version_str)
local time_str = string.format("%.1f sec", elapsed_time)
gh_imgui.text_rgba("Time: " .. time_str, 0.8, 0.8, 0.8, 1.0)
gh_imgui.text_rgba("Renderer: " .. renderer_model, 1.0, 1.0, 0.0, 1.0)
gh_imgui.text_rgba("3D API: " .. api_name .. " " .. api_version, 1.0, 0.7, 0.0, 1.0)
--gh_imgui.text("OS: " .. os_info)
gh_imgui.text_rgba("ImGui version: " .. imgui_version, 0.7, 0.7, 0.7, 1.0)
gh_imgui.window_end()
if (imgui_can_show_metrics_window) then
gh_imgui.show_metrics_window()
end
gh_imgui.frame_end()
--
-- ImGui end ---------------------------------------------------------------
----------------------------------------------------------------------------
]]></raw_data>
</script>
<script name="resize_scene" run_mode="SIZE" >
<raw_data><![CDATA[
winW, winH = gh_window.getsize(0)
]]></raw_data>
</script>
</glsl_hacker>