Merge pull request #237 from Hecklezz/D3D11_Index_Buffer_Format_Fix

Made D3D11 implementation work when using NK_UINT_DRAW_INDEX
This commit is contained in:
Komari Spaghetti 2020-12-29 13:07:13 +01:00 committed by GitHub
commit 4a749821c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,10 +85,15 @@ nk_d3d11_render(ID3D11DeviceContext *context, enum nk_anti_aliasing AA)
const float blend_factor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
const UINT stride = sizeof(struct nk_d3d11_vertex);
const UINT offset = 0;
#ifdef NK_UINT_DRAW_INDEX
DXGI_FORMAT index_buffer_format = DXGI_FORMAT_R32_UINT;
#else
DXGI_FORMAT index_buffer_format = DXGI_FORMAT_R16_UINT;
#endif
ID3D11DeviceContext_IASetInputLayout(context, d3d11.input_layout);
ID3D11DeviceContext_IASetVertexBuffers(context, 0, 1, &d3d11.vertex_buffer, &stride, &offset);
ID3D11DeviceContext_IASetIndexBuffer(context, d3d11.index_buffer, DXGI_FORMAT_R16_UINT, 0);
ID3D11DeviceContext_IASetIndexBuffer(context, d3d11.index_buffer, index_buffer_format, 0);
ID3D11DeviceContext_IASetPrimitiveTopology(context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
ID3D11DeviceContext_VSSetShader(context, d3d11.vertex_shader, NULL, 0);