Quantcast
Channel: Diligent Graphics
Viewing all articles
Browse latest Browse all 31

Diligent Engine now has C API

$
0
0

C API has always been one of the most frequently requested features, and it has finally been adopted!

Check out the reworked Tutorial 03 that demonstrates the usage of the new API. This is what it looks like:

// Bind vertex and index buffers
Uint32   offset = 0;
IBuffer* pBuffs[1];
pBuffs[0] = g_pCubeVertexBuffer;
IDeviceContext_SetVertexBuffers(pContext, 0, 1, pBuffs, &offset,
                                RESOURCE_STATE_TRANSITION_MODE_TRANSITION,
                                SET_VERTEX_BUFFERS_FLAG_RESET);
IDeviceContext_SetIndexBuffer(pContext, g_pCubeIndexBuffer, 0,
                              RESOURCE_STATE_TRANSITION_MODE_TRANSITION);

// Set the pipeline state
IDeviceContext_SetPipelineState(pContext, g_pPSO);
// Commit shader resources. RESOURCE_STATE_TRANSITION_MODE_TRANSITION mode
// makes sure that resources are transitioned to required states.
IDeviceContext_CommitShaderResources(pContext, g_pSRB,
                                     RESOURCE_STATE_TRANSITION_MODE_TRANSITION);

DrawIndexedAttribs DrawAttrs;
memset(&DrawAttrs, 0, sizeof(DrawAttrs));
DrawAttrs.IndexType    = VT_UINT32; // Index type
DrawAttrs.NumIndices   = 36;
DrawAttrs.NumInstances = 1;
// Verify the state of vertex and index buffers
DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL;
IDeviceContext_DrawIndexed(pContext, &DrawAttrs);

 

 


Viewing all articles
Browse latest Browse all 31

Trending Articles