MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / raster_program

Function raster_program

samples/cgpu/cgpu-basic/texture/texture.c:362–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360}
361
362void raster_program()
363{
364 bool quit = false;
365 while (!quit)
366 {
367 SDL_Event event;
368 while (SDL_PollEvent(&event))
369 {
370 if (SDL_GetWindowID(sdl_window) == event.window.windowID)
371 {
372 if (!SDLEventHandler(&event, sdl_window))
373 {
374 quit = true;
375 }
376 if (event.type == SDL_WINDOWEVENT)
377 {
378 Uint8 window_event = event.window.event;
379 if (window_event == SDL_WINDOWEVENT_SIZE_CHANGED)
380 {
381 cgpu_wait_queue_idle(gfx_queue);
382 int width = 0, height = 0;
383 SDL_GetWindowSize(sdl_window, &width, &height);
384 CGPUSwapChainDescriptor descriptor = {
385 .present_queues = &gfx_queue,
386 .present_queues_count = 1,
387 .width = width,
388 .height = height,
389 .surface = surface,
390 .image_count = BACK_BUFFER_COUNT,
391 .format = CGPU_FORMAT_R8G8B8A8_UNORM,
392 .enable_vsync = true
393 };
394 cgpu_free_swapchain(swapchain);
395 swapchain = cgpu_create_swapchain(device, &descriptor);
396 // Create views
397 for (uint32_t i = 0; i < swapchain->buffer_count; i++)
398 {
399 cgpu_free_texture_view(views[i]);
400 CGPUTextureViewDescriptor view_desc = {
401 .texture = swapchain->back_buffers[i],
402 .aspects = CGPU_TVA_COLOR,
403 .dims = CGPU_TEX_DIMENSION_2D,
404 .format = swapchain->back_buffers[i]->info->format,
405 .usages = CGPU_TVU_RTV_DSV,
406 .array_layer_count = 1
407 };
408 views[i] = cgpu_create_texture_view(device, &view_desc);
409 }
410 skr_thread_sleep(100);
411 }
412 }
413 }
414 }
415 raster_redraw();
416 }
417}
418
419void finalize()

Callers 1

ProgramMainFunction · 0.70

Calls 8

cgpu_wait_queue_idleFunction · 0.85
cgpu_free_swapchainFunction · 0.85
cgpu_create_swapchainFunction · 0.85
cgpu_free_texture_viewFunction · 0.85
cgpu_create_texture_viewFunction · 0.85
raster_redrawFunction · 0.70
SDLEventHandlerFunction · 0.50
skr_thread_sleepFunction · 0.50

Tested by

no test coverage detected