MCPcopy Create free account
hub / github.com/crownengine/crown / parse_renderer_settings

Function parse_renderer_settings

src/device/boot_config.cpp:85–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85static void parse_renderer_settings(BootConfig *config, const char *json)
86{
87 TempAllocator1024 ta;
88 JsonObject renderer(ta);
89 sjson::parse(renderer, json);
90
91 auto cur = json_object::begin(renderer);
92 auto end = json_object::end(renderer);
93 for (; cur != end; ++cur) {
94 JSON_OBJECT_SKIP_HOLE(renderer, cur);
95
96 if (cur->first == "resolution") {
97 JsonArray resolution(ta);
98 sjson::parse_array(resolution, cur->second);
99 config->window_w = sjson::parse_int(resolution[0]);
100 config->window_h = sjson::parse_int(resolution[1]);
101 } else if (cur->first == "aspect_ratio") {
102 config->aspect_ratio = sjson::parse_float(cur->second);
103 } else if (cur->first == "device_id") {
104 DynamicString hex(ta);
105 sjson::parse_string(hex, cur->second);
106 s64 id;
107 from_hex(id, hex.c_str());
108 config->device_id = (u16)id;
109 } else if (cur->first == "type") {
110 DynamicString renderer_type(ta);
111 sjson::parse_string(renderer_type, cur->second);
112 config->renderer_type = renderer_type_from_name(renderer_type.c_str());
113 if (config->renderer_type == RendererType::COUNT) {
114 logw(BOOT_CONFIG
115 , "Unknown renderer type '%s'"
116 , renderer_type.c_str()
117 );
118 config->renderer_type = RendererType::AUTO;
119 }
120 } else if (cur->first == "vsync") {
121 config->vsync = sjson::parse_bool(cur->second);
122 } else if (cur->first == "fullscreen") {
123 config->fullscreen = sjson::parse_bool(cur->second);
124 } else {
125 logw(BOOT_CONFIG
126 , "Unknown renderer property '%.*s'"
127 , cur->first.length()
128 , cur->first.data()
129 );
130 }
131 }
132}
133
134static void parse_platform_settings(BootConfig *config, const char *json)
135{

Callers 1

parse_platform_settingsFunction · 0.85

Calls 13

from_hexFunction · 0.85
renderer_type_from_nameFunction · 0.85
parseFunction · 0.50
beginFunction · 0.50
endFunction · 0.50
parse_arrayFunction · 0.50
parse_intFunction · 0.50
parse_floatFunction · 0.50
parse_stringFunction · 0.50
parse_boolFunction · 0.50
c_strMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected