| 247 | #include "SkrRT/runtime_module.h" |
| 248 | |
| 249 | int main(int argc, char* argv[]) |
| 250 | { |
| 251 | DPIAware = skr_runtime_is_dpi_aware(); |
| 252 | |
| 253 | if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) != 0) return -1; |
| 254 | SWindowDescroptor window_desc = {}; |
| 255 | window_desc.flags = SKR_WINDOW_CENTERED | SKR_WINDOW_RESIZABLE; |
| 256 | window_desc.height = BACK_BUFFER_HEIGHT; |
| 257 | window_desc.width = BACK_BUFFER_WIDTH; |
| 258 | window = skr_create_window(gCGPUBackendNames[backend], &window_desc); |
| 259 | create_api_objects(); |
| 260 | create_resources(); |
| 261 | create_render_pipeline(); |
| 262 | // initialize |
| 263 | namespace render_graph = skr::render_graph; |
| 264 | auto graph = render_graph::RenderGraph::create( |
| 265 | [=](skr::render_graph::RenderGraphBuilder& builder) { |
| 266 | builder.with_device(device) |
| 267 | .with_gfx_queue(gfx_queue) |
| 268 | .enable_memory_aliasing(); |
| 269 | }); |
| 270 | PassProfiler profilers[RG_MAX_FRAME_IN_FLIGHT]; |
| 271 | for (uint32_t i = 0; i < RG_MAX_FRAME_IN_FLIGHT; i++) |
| 272 | { |
| 273 | profilers[i].initialize(device); |
| 274 | } |
| 275 | ImGui::CreateContext(); |
| 276 | ImGuiIO& io = ImGui::GetIO(); |
| 277 | io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls |
| 278 | io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking |
| 279 | io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows |
| 280 | ImGui::StyleColorsDark(); |
| 281 | { |
| 282 | auto& style = ImGui::GetStyle(); |
| 283 | if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable) |
| 284 | { |
| 285 | style.WindowRounding = 0.0f; |
| 286 | style.Colors[ImGuiCol_WindowBg].w = 1.0f; |
| 287 | } |
| 288 | const char8_t* font_path = u8"./../resources/font/SourceSansPro-Regular.ttf"; |
| 289 | uint32_t *font_bytes, font_length; |
| 290 | read_bytes(font_path, &font_bytes, &font_length); |
| 291 | float dpi_scaling = 1.f; |
| 292 | if (!DPIAware) |
| 293 | { |
| 294 | float ddpi; |
| 295 | SDL_GetDisplayDPI(0, &ddpi, NULL, NULL); |
| 296 | dpi_scaling = ddpi / OS_DPI; |
| 297 | // scale back |
| 298 | style.ScaleAllSizes(1.f / dpi_scaling); |
| 299 | ImGui::GetIO().FontGlobalScale = 1.f / dpi_scaling; |
| 300 | } |
| 301 | else |
| 302 | { |
| 303 | float ddpi; |
| 304 | SDL_GetDisplayDPI(0, &ddpi, NULL, NULL); |
| 305 | dpi_scaling = ddpi / OS_DPI; |
| 306 | // scale back |
nothing calls this directly
no test coverage detected