aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/include/dxwindow.h9
-rw-r--r--hello/main.c12
2 files changed, 21 insertions, 0 deletions
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();
21/// Return the last Window error. 21/// Return the last Window error.
22const char* window_get_error(); 22const char* window_get_error();
23 23
24/// Initialize the window.
24Window* window_init(int width, int height, const char* title); 25Window* window_init(int width, int height, const char* title);
26
27/// Destroy the window.
25void window_destroy(Window**); 28void window_destroy(Window**);
29
30/// Return the Windows handle.
26HWND window_handle(Window*); 31HWND window_handle(Window*);
32
33/// Update the window, poll for events.
27void window_update(Window*); 34void window_update(Window*);
35
36/// Return whether the user has requested that the window should be closed.
28bool window_should_close(const Window*); 37bool 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) {
47 assert(d3d); 47 assert(d3d);
48 assert(d3d->pDxgiFactory); 48 assert(d3d->pDxgiFactory);
49 assert(d3d->pCommandQueue); 49 assert(d3d->pCommandQueue);
50 assert(d3d->pWindow);
50 51
51 SafeRelease(d3d->pSwapChain); 52 SafeRelease(d3d->pSwapChain);
52 53
@@ -80,7 +81,9 @@ static void d3d_create_swap_chain_buffer_render_target_views(D3D* d3d) {
80 assert(d3d); 81 assert(d3d);
81 assert(d3d->pDevice); 82 assert(d3d->pDevice);
82 assert(d3d->pSwapChain); 83 assert(d3d->pSwapChain);
84 assert(d3d->pSwapChainBuffer);
83 assert(d3d->pRtvHeap); 85 assert(d3d->pRtvHeap);
86 assert(d3d->rtv_descriptor_size > 0);
84 87
85 // Create the new buffer views. 88 // Create the new buffer views.
86 D3D12_CPU_DESCRIPTOR_HANDLE rtv_heap_handle; 89 D3D12_CPU_DESCRIPTOR_HANDLE rtv_heap_handle;
@@ -276,6 +279,7 @@ static void d3d_init(D3D* d3d, Window* pWindow, const D3DSettings* pSettings) {
276 279
277static D3D12_CPU_DESCRIPTOR_HANDLE d3d_get_current_back_buffer_view(const D3D* d3d) { 280static D3D12_CPU_DESCRIPTOR_HANDLE d3d_get_current_back_buffer_view(const D3D* d3d) {
278 assert(d3d); 281 assert(d3d);
282 assert(d3d->pSwapChain);
279 assert(d3d->pRtvHeap); 283 assert(d3d->pRtvHeap);
280 assert(d3d->rtv_descriptor_size > 0); 284 assert(d3d->rtv_descriptor_size > 0);
281 D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle; 285 D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle;
@@ -288,11 +292,15 @@ static D3D12_CPU_DESCRIPTOR_HANDLE d3d_get_current_back_buffer_view(const D3D* d
288 292
289static ID3D12Resource* d3d_get_current_back_buffer(const D3D* d3d) { 293static ID3D12Resource* d3d_get_current_back_buffer(const D3D* d3d) {
290 assert(d3d); 294 assert(d3d);
295 assert(d3d->pSwapChain);
296 assert(d3d->pSwapChainBuffer);
291 return d3d->pSwapChainBuffer[d3d->pSwapChain->lpVtbl->GetCurrentBackBufferIndex(d3d->pSwapChain)]; 297 return d3d->pSwapChainBuffer[d3d->pSwapChain->lpVtbl->GetCurrentBackBufferIndex(d3d->pSwapChain)];
292} 298}
293 299
294static void d3d_populate_command_list(D3D* d3d) { 300static void d3d_populate_command_list(D3D* d3d) {
295 assert(d3d); 301 assert(d3d);
302 assert(d3d->pCommandAllocator);
303 assert(d3d->pCommandList);
296 304
297 /// Note that we skip the following two items: 305 /// Note that we skip the following two items:
298 /// 306 ///
@@ -356,6 +364,8 @@ static void d3d_populate_command_list(D3D* d3d) {
356 364
357static void d3d_wait_for_previous_frame(D3D* d3d) { 365static void d3d_wait_for_previous_frame(D3D* d3d) {
358 assert(d3d); 366 assert(d3d);
367 assert(d3d->pFence);
368 assert(d3d->pCommandQueue);
359 369
360 // Advance the fence value to mark commands up to this fence point. 370 // Advance the fence value to mark commands up to this fence point.
361 d3d->fence_value++; 371 d3d->fence_value++;
@@ -385,6 +395,8 @@ static void d3d_wait_for_previous_frame(D3D* d3d) {
385 395
386static void d3d_render(D3D* d3d) { 396static void d3d_render(D3D* d3d) {
387 assert(d3d); 397 assert(d3d);
398 assert(d3d->pCommandQueue);
399 assert(d3d->pSwapChain);
388 400
389 d3d_populate_command_list(d3d); 401 d3d_populate_command_list(d3d);
390 402