0
\$\begingroup\$

Lets say I have vertices and indices for Box and Sphere and I put them into one vertex buffer. But if I want to use different constant buffers for each of the figures, how would I do that?

As I understand I need to somehow say in VertexShader "Do those calculations for those vertices, and these calculations for these". But to my understanding, shaders don't work that way? Also I can't have two input layouts for each figure (it doesn't even make sense). I've heard you are not suppose to do it that way these days, better to have different buffers for each figure, but still I want to try it.

\$\endgroup\$
1
\$\begingroup\$

So, it's dead simple. object->SetConstBuffer(put here first thing); object->UpdateConstantBuffer(); object->DrawFirstOne();

object->SetConstBuffer(here goes second thing); object->UpdateConstantBuffer(exactly the same one, we overwriting); object->DrawSecondOne();

Update is where your Map/Unmap/updateSubresource happen. Nothing needs to be changed in vertex shader. The order is functions of important, you can end up reading from the same thing second time.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.