| 460 | } |
| 461 | |
| 462 | void raster_program() |
| 463 | { |
| 464 | bool quit = false; |
| 465 | while (!quit) |
| 466 | { |
| 467 | SDL_Event event; |
| 468 | while (SDL_PollEvent(&event)) |
| 469 | { |
| 470 | SDL_Window* sdl_window = (SDL_Window*)App.window_handle; |
| 471 | if (SDL_GetWindowID(sdl_window) == event.window.windowID) |
| 472 | { |
| 473 | if (!SDLEventHandler(&event, sdl_window)) |
| 474 | { |
| 475 | quit = true; |
| 476 | } |
| 477 | if (event.type == SDL_WINDOWEVENT) |
| 478 | { |
| 479 | Uint8 window_event = event.window.event; |
| 480 | if (window_event == SDL_WINDOWEVENT_SIZE_CHANGED) |
| 481 | { |
| 482 | cgpu_wait_queue_idle(App.gfx_queue); |
| 483 | int width = 0, height = 0; |
| 484 | SDL_GetWindowSize(sdl_window, &width, &height); |
| 485 | CGPUSwapChainDescriptor descriptor = { |
| 486 | .present_queues = &App.gfx_queue, |
| 487 | .present_queues_count = 1, |
| 488 | .width = width, |
| 489 | .height = height, |
| 490 | .surface = App.surface, |
| 491 | .image_count = BACK_BUFFER_COUNT, |
| 492 | .format = CGPU_FORMAT_R8G8B8A8_UNORM, |
| 493 | .enable_vsync = true |
| 494 | }; |
| 495 | cgpu_free_swapchain(App.swapchain); |
| 496 | App.swapchain = cgpu_create_swapchain(App.device, &descriptor); |
| 497 | // Create views |
| 498 | for (uint32_t i = 0; i < App.swapchain->buffer_count; i++) |
| 499 | { |
| 500 | cgpu_free_texture_view(views[i]); |
| 501 | CGPUTextureViewDescriptor view_desc = { |
| 502 | .texture = App.swapchain->back_buffers[i], |
| 503 | .aspects = CGPU_TVA_COLOR, |
| 504 | .dims = CGPU_TEX_DIMENSION_2D, |
| 505 | .format = App.swapchain->back_buffers[i]->info->format, |
| 506 | .usages = CGPU_TVU_RTV_DSV, |
| 507 | .array_layer_count = 1 |
| 508 | }; |
| 509 | views[i] = cgpu_create_texture_view(App.device, &view_desc); |
| 510 | } |
| 511 | skr_thread_sleep(100); |
| 512 | } |
| 513 | } |
| 514 | } |
| 515 | } |
| 516 | raster_redraw(); |
| 517 | } |
| 518 | } |
| 519 |
no test coverage detected