MCPcopy Create free account
hub / github.com/StereoKit/StereoKit / demo_desktop_update

Function demo_desktop_update

Examples/StereoKitCTest/demo_desktop.cpp:168–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166///////////////////////////////////////////
167
168void demo_desktop_update() {
169 // Update our desktop texture
170 if (duplication_next_frame(duplication_api, duplication_tex)) {
171 if (tex_get_width (desktop_tex) != tex_get_width (duplication_tex) ||
172 tex_get_height(desktop_tex) != tex_get_height(duplication_tex)) {
173 tex_set_colors(desktop_tex, tex_get_width(duplication_tex), tex_get_height(duplication_tex), nullptr);
174 demo_mesh_create(desktop_tex, 1, desktop_mesh);
175 }
176 render_blit(desktop_tex, desktop_blit_mat);
177 }
178
179 // prepare a little grab handle underneath the desktop texture
180 float size = tex_get_height(desktop_tex) * 0.0004f;
181 bounds_t bounds = mesh_get_bounds(desktop_mesh);
182 bounds.center = (bounds.center + vec3{ 0, -bounds.dimensions.y / 2, bounds.dimensions.z / 2 }) * size + vec3{0,-0.02f,-0.02f};
183 bounds.dimensions = vec3{0.2f, 0.02f, 0.02f};
184
185 // UI for the grab handle
186 static pose_t desktop_pose = pose_t{ vec3{0,0,-0.5f}, quat_lookat(vec3_zero, {0,0,1}) };
187 static pose_t desktop_pose_smooth = desktop_pose;
188 ui_enable_far_interact(false);
189 ui_handle_begin("Desktop", desktop_pose, bounds, true);
190 ui_handle_end();
191 ui_enable_far_interact(true);
192
193 // Smooth out the motion extra for nicer placement
194 desktop_pose_smooth = {
195 vec3_lerp (desktop_pose_smooth.position, desktop_pose.position, 4 * time_stepf()),
196 quat_slerp(desktop_pose_smooth.orientation, desktop_pose.orientation, 4 * time_stepf()) };
197 desktop_pose = desktop_pose_smooth;
198 render_add_mesh(desktop_mesh, desktop_material, pose_matrix(desktop_pose, vec3_one * size));
199}
200
201///////////////////////////////////////////
202

Callers

nothing calls this directly

Calls 15

duplication_next_frameFunction · 0.85
tex_get_widthFunction · 0.85
tex_get_heightFunction · 0.85
tex_set_colorsFunction · 0.85
demo_mesh_createFunction · 0.85
render_blitFunction · 0.85
mesh_get_boundsFunction · 0.85
quat_lookatFunction · 0.85
ui_enable_far_interactFunction · 0.85
ui_handle_beginFunction · 0.85
ui_handle_endFunction · 0.85
vec3_lerpFunction · 0.85

Tested by

no test coverage detected