From e39e9b5bf1fb28f321b01fa427e2a7c206195b2c Mon Sep 17 00:00:00 2001 From: Marc Sunet Date: Fri, 21 Nov 2025 10:58:06 -0800 Subject: Tidy --- app/include/dxwindow.h | 9 +++++++++ hello/main.c | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/app/include/dxwindow.h b/app/include/dxwindow.h index 7e5a373..14caa36 100644 --- a/app/include/dxwindow.h +++ b/app/include/dxwindow.h @@ -21,8 +21,17 @@ void window_global_quit(); /// Return the last Window error. const char* window_get_error(); +/// Initialize the window. Window* window_init(int width, int height, const char* title); + +/// Destroy the window. void window_destroy(Window**); + +/// Return the Windows handle. HWND window_handle(Window*); + +/// Update the window, poll for events. void window_update(Window*); + +/// Return whether the user has requested that the window should be closed. bool window_should_close(const Window*); diff --git a/hello/main.c b/hello/main.c index 738f5c0..44f8a90 100644 --- a/hello/main.c +++ b/hello/main.c @@ -47,6 +47,7 @@ static void d3d_create_swap_chain(D3D* d3d) { assert(d3d); assert(d3d->pDxgiFactory); assert(d3d->pCommandQueue); + assert(d3d->pWindow); SafeRelease(d3d->pSwapChain); @@ -80,7 +81,9 @@ static void d3d_create_swap_chain_buffer_render_target_views(D3D* d3d) { assert(d3d); assert(d3d->pDevice); assert(d3d->pSwapChain); + assert(d3d->pSwapChainBuffer); assert(d3d->pRtvHeap); + assert(d3d->rtv_descriptor_size > 0); // Create the new buffer views. D3D12_CPU_DESCRIPTOR_HANDLE rtv_heap_handle; @@ -276,6 +279,7 @@ static void d3d_init(D3D* d3d, Window* pWindow, const D3DSettings* pSettings) { static D3D12_CPU_DESCRIPTOR_HANDLE d3d_get_current_back_buffer_view(const D3D* d3d) { assert(d3d); + assert(d3d->pSwapChain); assert(d3d->pRtvHeap); assert(d3d->rtv_descriptor_size > 0); D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle; @@ -288,11 +292,15 @@ static D3D12_CPU_DESCRIPTOR_HANDLE d3d_get_current_back_buffer_view(const D3D* d static ID3D12Resource* d3d_get_current_back_buffer(const D3D* d3d) { assert(d3d); + assert(d3d->pSwapChain); + assert(d3d->pSwapChainBuffer); return d3d->pSwapChainBuffer[d3d->pSwapChain->lpVtbl->GetCurrentBackBufferIndex(d3d->pSwapChain)]; } static void d3d_populate_command_list(D3D* d3d) { assert(d3d); + assert(d3d->pCommandAllocator); + assert(d3d->pCommandList); /// Note that we skip the following two items: /// @@ -356,6 +364,8 @@ static void d3d_populate_command_list(D3D* d3d) { static void d3d_wait_for_previous_frame(D3D* d3d) { assert(d3d); + assert(d3d->pFence); + assert(d3d->pCommandQueue); // Advance the fence value to mark commands up to this fence point. d3d->fence_value++; @@ -385,6 +395,8 @@ static void d3d_wait_for_previous_frame(D3D* d3d) { static void d3d_render(D3D* d3d) { assert(d3d); + assert(d3d->pCommandQueue); + assert(d3d->pSwapChain); d3d_populate_command_list(d3d); -- cgit v1.2.3