Advertisement Jump to content
Sign in to follow this  
Muzzy A

DirectX 11 Drawing multiple instances of the same object

This topic is 1749 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to set up Direct X 11 and I have a cube that I'm trying to render multiple times in different places.  The problem is only the last one being drawn gets rendered.

 

 

Here is how I set my constant buffers

struct objData
{
    Matrix4x4 world;
    Matrix4x4 viewProj;
};

// I do this for every object
void CRenderer::setPerObjectData( const Matrix4x4& world,const Matrix4x4& viewProj )
{
    D3D11* d3d = g_Engine->getD3D();
 
    objData d = { world,viewProj };
 
    D3D11_MAPPED_SUBRESOURCE edit;
    d3d->getDeviceContext()->Map(_pObjectData, 0, D3D11_MAP_WRITE_DISCARD, 0, &edit);

    memcpy(edit.pData, &d, sizeof( objData ) );

    d3d->getDeviceContext()->Unmap(_pObjectData, 0);
 
    // '_pObjectData' is the same buffer for all the objects being rendered
    d3d->getDeviceContext()->VSSetConstantBuffers(0, 1, &_pObjectData);
}
Edited by Muzzy A

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!