Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. void RenderFrame(void)
  2. {
  3. D3DXMATRIX matView, matProjection;
  4. D3DXMATRIX matFinal;
  5.  
  6. // create a view matrix
  7. D3DXMatrixLookAtLH(&matView,
  8. &D3DXVECTOR3(0.0f, 9.0f, 24.0f), // the camera position
  9. &D3DXVECTOR3(0.0f, 0.0f, 0.0f), // the look-at position
  10. &D3DXVECTOR3(0.0f, 1.0f, 0.0f)); // the up direction
  11.  
  12. // create a projection matrix
  13. D3DXMatrixPerspectiveFovLH(&matProjection,
  14. (FLOAT)D3DXToRadian(45), // field of view
  15. (FLOAT)SCREEN_WIDTH / (FLOAT)SCREEN_HEIGHT, // aspect ratio
  16. 1.0f, // near view-plane
  17. 100.0f); // far view-plane
  18.  
  19. // create the final transform
  20. matFinal = matView * matProjection;
  21.  
  22. devcon->ClearRenderTargetView(backbuffer, D3DXCOLOR(0.0f, 0.2f, 0.4f, 1.0f));
  23.  
  24. devcon->ClearDepthStencilView(zbuffer, D3D11_CLEAR_DEPTH, 1.0f, 0);
  25.  
  26. UINT stride = sizeof(VERTEX);
  27. UINT offset = 0;
  28. devcon->IASetVertexBuffers(0, 1, &pVBuffer, &stride, &offset);
  29. devcon->IASetIndexBuffer(pIBuffer, DXGI_FORMAT_R32_UINT, 0);
  30. devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
  31.  
  32. devcon->UpdateSubresource(pCBuffer, 0, 0, &matFinal, 0, 0);
  33. devcon->DrawIndexed(24, 0, 0);
  34.  
  35. swapchain->Present(0, 0);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement