MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / sokol_main

Function sokol_main

Examples/SCExample/SCExample.cpp:330–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328SC::Console* globalConsole;
329
330sapp_desc sokol_main(int, char*[])
331{
332 using namespace SC;
333 Console console;
334 globalConsole = &console;
335
336 Globals::init(Globals::Global);
337 sapp_desc desc = {};
338
339 desc.window_title = "SCExample";
340 desc.high_dpi = true;
341 desc.enable_clipboard = true;
342
343 desc.init_cb = []()
344 {
345 gModelSystem = new ApplicationSystem();
346 if (not gModelSystem->create())
347 {
348 sapp_quit();
349 }
350 sg_desc desc = {};
351
352 desc.environment = sglue_environment();
353 sg_setup(&desc);
354
355 simgui_desc_t simgui_desc = {};
356 simgui_setup(&simgui_desc);
357
358 gGlobalPassAction.colors[0].load_action = SG_LOADACTION_CLEAR;
359 gGlobalPassAction.colors[0].clear_value = {0.0f, 0.5f, 0.7f, 1.0f};
360 };
361
362 desc.frame_cb = []()
363 {
364 simgui_new_frame({sapp_width(), sapp_height(), sapp_frame_duration(), sapp_dpi_scale()});
365 ApplicationView applicationView = {*gModelSystem, gModelSystem->state, gViewState};
366 applicationView.draw();
367
368 sg_pass pass = {};
369 pass.action = gGlobalPassAction;
370 pass.swapchain = sglue_swapchain();
371 sg_begin_pass(&pass);
372 simgui_render();
373 sg_end_pass();
374 sg_commit();
375
376 if (not gModelSystem->runLoopStepInsideSokolApp())
377 {
378 sapp_quit();
379 }
380 };
381
382 desc.cleanup_cb = []()
383 {
384 if (not gModelSystem->close())
385 {
386 sapp_quit();
387 }

Callers

nothing calls this directly

Calls 6

initFunction · 0.85
resetLastEventTimeMethod · 0.80
createMethod · 0.45
drawMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected