@@ -182,39 +182,35 @@ int main(int argc, char **argv) {
182182 }
183183
184184 CommandBuffer * cmd = $ (renderDevice , acquireCommandBuffer );
185- Swapchain swapchain = { 0 };
186185
187- if (!$ (renderDevice , acquireSwapchainTexture , cmd , & swapchain )) {
188- $ (cmd , cancel );
189- release (cmd );
190- continue ;
191- }
192-
193- float4x4 modelView = float4x4_rotation (angleX , float3_new (1.f , 0.f , 0.f ));
194- modelView = float4x4_mul (float4x4_rotation (angleY , float3_new (0.f , 1.f , 0.f )), modelView );
195- modelView = float4x4_mul (float4x4_translation (float3_new (0.f , 0.f , -2.5f )), modelView );
196- const float4x4 projection = float4x4_perspective (45.f , (float ) swapchain .size .w / (float ) swapchain .size .h , 0.01f , 100.f );
197- const float4x4 modelViewProjection = float4x4_mul (projection , modelView );
198-
199- SDL_GPUColorTargetInfo colorTarget = {
200- .texture = swapchain .texture ,
201- .clear_color = { 0.1f , 0.1f , 0.2f , 1.0f },
202- .load_op = SDL_GPU_LOADOP_CLEAR ,
203- .store_op = SDL_GPU_STOREOP_STORE ,
204- };
205-
206- SDL_GPUDepthStencilTargetInfo depthTarget = $ (framebuffer , depthTargetInfo ,
207- SDL_GPU_LOADOP_CLEAR , SDL_GPU_STOREOP_DONT_CARE , 1.f );
208-
209- RenderPass * renderPass = $ (cmd , beginRenderPass , & colorTarget , 1 , & depthTarget );
210- $ (renderPass , bindPipeline , pipeline );
211- $ (renderPass , bindVertexBuffers , 0 , & (SDL_GPUBufferBinding ) {
212- .buffer = vertexBuffer ,
213- .offset = 0 ,
214- }, 1 );
215- $ (cmd , pushVertexUniformData , 0 , modelViewProjection .f , sizeof (modelViewProjection ));
216- $ (renderPass , drawPrimitives , (Uint32 ) SDL_arraysize (vertex_data ), 1 , 0 , 0 );
217- release (renderPass );
186+ SwapchainTexture swapchain = { 0 };
187+ if ($ (cmd , acquireSwapchainTexture , window , & swapchain )) {
188+
189+ float4x4 modelView = float4x4_rotation (angleX , float3_new (1.f , 0.f , 0.f ));
190+ modelView = float4x4_mul (float4x4_rotation (angleY , float3_new (0.f , 1.f , 0.f )), modelView );
191+ modelView = float4x4_mul (float4x4_translation (float3_new (0.f , 0.f , -2.5f )), modelView );
192+ const float4x4 projection = float4x4_perspective (45.f , (float ) swapchain .size .w / (float ) swapchain .size .h , 0.01f , 100.f );
193+ const float4x4 modelViewProjection = float4x4_mul (projection , modelView );
194+
195+ SDL_GPUColorTargetInfo colorTarget = {
196+ .texture = swapchain .texture ,
197+ .clear_color = { 0.1f , 0.1f , 0.2f , 1.0f },
198+ .load_op = SDL_GPU_LOADOP_CLEAR ,
199+ .store_op = SDL_GPU_STOREOP_STORE ,
200+ };
201+
202+ SDL_GPUDepthStencilTargetInfo depthTarget = $ (framebuffer , depthTargetInfo , SDL_GPU_LOADOP_CLEAR , SDL_GPU_STOREOP_DONT_CARE , 1.f );
203+
204+ RenderPass * renderPass = $ (cmd , beginRenderPass , & colorTarget , 1 , & depthTarget );
205+ $ (renderPass , bindPipeline , pipeline );
206+ $ (renderPass , bindVertexBuffers , 0 , & (SDL_GPUBufferBinding ) {
207+ .buffer = vertexBuffer ,
208+ .offset = 0 ,
209+ }, 1 );
210+ $ (cmd , pushVertexUniformData , 0 , modelViewProjection .f , sizeof (modelViewProjection ));
211+ $ (renderPass , drawPrimitives , (Uint32 ) SDL_arraysize (vertex_data ), 1 , 0 , 0 );
212+ release (renderPass );
213+ }
218214
219215 $ (cmd , submit );
220216 release (cmd );
0 commit comments