MCPcopy Create free account
hub / github.com/Wassimulator/CactusViewer / UI_init_context

Function UI_init_context

include/ui/ui_core.cpp:601–640  ·  view source on GitHub ↗

* @param UI_Context *ctx : pointer to a UI_Context struct allocated by the user in memory. * **/

Source from the content-addressed store, hash-verified

599 * @param UI_Context *ctx : pointer to a UI_Context struct allocated by the user in memory.
600 * **/
601UI_Context * UI_init_context() {
602 UI_Context *ctx = (UI_Context *)malloc(sizeof(UI_Context));
603 UI_assert(ctx != nullptr);
604 memset(ctx, 0, sizeof(*ctx));
605 // TODO(Wassim): We REALLY need an arena allocator, all this binary tree is run by pointers
606 // this is just a placeholder hack that should be changed later!
607 ctx->buffers[0].init_reserve(GB(4), 5000);
608 ctx->buffers[1].init_reserve(GB(4), 5000);
609 ctx->parents.init_reserve(GB(4), 1000);
610 ctx->data_chunks.init_reserve(GB(4), 1000);
611 ctx->blocks_hit_test.init_reserve(GB(4), 10000);
612 ctx->hashes.init_reserve(GB(4), 5000);
613
614 ctx->vertices.init_null();
615 ctx->fonts.init_null(); ctx->fonts.reserve(100);
616
617 for (int i = 0; i < UI_MAX_TEXTURES; i++)
618 ctx->textures[i] = 0;
619
620 FT_Init_FreeType(&ctx->ft_lib);
621 FT_Library_SetLcdFilter(ctx->ft_lib, FT_LCD_FILTER_LIGHT);
622
623 ctx->strings.init_reserve(GB(4), 1024 * 128);
624
625 ctx->buffer_index = 0;
626 ctx->frame_id = 0;
627 ctx->backend = UI_Render_Backend_Type::None;
628 ctx->viewport = v2(0,0);
629 ctx->backend_context = nullptr;
630 ctx->vertices.init_null();
631 ctx->debug.last_block_count = 0;
632 ctx->debug.allocated_bytes = 0;
633 ctx->debug.last_vertex_count = 0;
634 ctx->string_storage_size = 0;
635 ctx->string_storage_capacity = 5000;
636 ctx->string_storage = (char*)malloc(ctx->string_storage_capacity);
637
638 ctx->initialized = true;
639 return ctx;
640}
641
642//void UI_push_ID_(UI_Context *ctx, char* label) {
643// UI_assert(ctx != nullptr);

Callers 1

init_allFunction · 0.85

Calls 2

init_reserveMethod · 0.80
init_nullMethod · 0.80

Tested by

no test coverage detected