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

Function common_init

Examples/StereoKitCTest/main.cpp:175–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175void common_init() {
176 // Create a PBR floor material
177 tex_t tex_color = tex_create_file("test.png");
178 //tex_t tex_norm = tex_create_file("test_normal.png");
179 floor_mat = material_copy_id(default_id_material);
180 material_set_texture(floor_mat, "diffuse", tex_color);
181 //material_set_texture(floor_mat, "normal", tex_norm);
182 material_set_float (floor_mat, "tex_scale", 6);
183 material_set_float (floor_mat, "roughness", 1.0f);
184 material_set_float (floor_mat, "metallic", 0.5f);
185 material_set_queue_offset(floor_mat, 1);
186 if (tex_color != nullptr) tex_release(tex_color);
187 //if (tex_norm != nullptr) tex_release(tex_norm);
188
189 // Procedurally create a cube model
190 mesh_t mesh_cube = mesh_gen_cube(vec3_one, 0);
191 floor_model = model_create_mesh(mesh_cube, floor_mat);
192 mesh_release(mesh_cube);
193
194 // Build a physical floor!
195 vec3 pos = vec3{ 0,-1.5f,0 };
196 vec3 scale = vec3{ 5,1,5 };
197 floor_tr = matrix_trs(pos, quat_identity, scale);
198 floor_solid = solid_create(pos, quat_identity, solid_type_immovable);
199 solid_add_box (floor_solid, scale);
200
201 demo_select_pose.position = vec3{0, 0, -0.4f};
202 demo_select_pose.orientation = quat_lookat(vec3_forward, vec3_zero);
203
204 // Log some system info
205 const char* text = "";
206 log_infof("Device: %s", device_get_name());
207 log_infof("GPU: %s", device_get_gpu());
208 switch (device_get_tracking()) { case device_tracking_none: text = "none"; break; case device_tracking_3dof: text = "3dof"; break; case device_tracking_6dof: text = "6dof"; break; }
209 log_infof("Tracking: %s", text);
210 log_infof("Hands: %s", device_has_hand_tracking()?"true":"false");
211 log_infof("Eyes: %s", device_has_eye_gaze()?"true":"false");
212 switch (device_display_get_type()) { case display_type_none: text = "none"; break; case display_type_flatscreen: text = "flatscreen"; break; case display_type_stereo: text = "stereo"; break; }
213 log_infof("Display Type: %s", text);
214 switch (device_display_get_blend()) { case display_blend_additive: text = "additive"; break; case display_blend_blend: text = "blend"; break; case display_blend_opaque: text = "opaque"; break; case display_blend_none: text = "none"; break; default: text = "unknown"; break; }
215 log_infof("Display Blend: %s", text);
216 log_infof("Display FoV: %.0f, %.0f, %.0f, %.0f",
217 device_display_get_fov().right,
218 device_display_get_fov().left,
219 device_display_get_fov().top,
220 device_display_get_fov().bottom);
221 log_infof("Display Hz: %.1f", device_display_get_refresh_rate());
222 log_infof("Display Size: %d<~BLK>x<~clr>%d", device_display_get_width(), device_display_get_height());
223}
224
225void common_update() {
226 static app_focus_ prev_focus = app_focus_hidden;

Callers 1

wWinMainFunction · 0.85

Calls 15

tex_create_fileFunction · 0.85
material_copy_idFunction · 0.85
material_set_textureFunction · 0.85
material_set_floatFunction · 0.85
tex_releaseFunction · 0.85
mesh_gen_cubeFunction · 0.85
model_create_meshFunction · 0.85
mesh_releaseFunction · 0.85
matrix_trsFunction · 0.85
solid_createFunction · 0.85
solid_add_boxFunction · 0.85

Tested by

no test coverage detected