2
\$\begingroup\$

I have one HLSL file for DirectX11 that only has input layout for color and position. Then another HLSL file for the simple cube that has position, normal and textures. What I noticed is when I render the simple cube; the grid also changes and doesn't remain pure white color. They have different pixelshaders, vertexshaders, constant buffers and different inputlayout descriptions.

Would anyone like to chip in and help get this resolved? This has been puzzling for a day!

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

I highly recommend grabbing a graphics debugger. Aside from the free GPU vendor ones (such as AMD's PerfStudio, and Nvidia's Nsight) there's also one built into VS2012 Professional. This will let you look at the current state of the ID3D11GraphicsContext and confirm you've set everything correctly when you draw the grid.

If you want to take the brute force approach, you could compare and contrast the state when you go to render said grid in two different scenarios: where you don't render the cube, and the grid looks correct, vs where you do render the cube, and the grid looks incorrect. If you understand the device context state, just looking at the wrong result is likely to let you figure things out faster.

Wildly guessing, I'm guessing the fundamental problem is that you set something on the graphics context once on the creation/initialization of something, when it really needs to be set each time before you render the grid that uses it. Direct3D and OpenGL are both very much driven by "what is the current state of the graphics context" rather than how things were originally created.

\$\endgroup\$
3
  • \$\begingroup\$ You know what - I think you're correct. So, when a a mesh is being initialized; I set up the mesh and buffers but only set them inside the render function? Same goes with the mesh's shader too, right? If I understand you correctly, initialization is preparing for the output merger and the output merger is the rendering state. I'll have to toy around with that and get back to you. \$\endgroup\$ Jun 23, 2013 at 4:54
  • \$\begingroup\$ Ah, that worked like a charm! Thank you so much MaulingMonkey! I took all the IASET functions and placed them inside the render functions. Now, the grid is perfectly white and the textured cube! \$\endgroup\$ Jun 23, 2013 at 5:16
  • \$\begingroup\$ No problem, glad that's sorted out :). Your understanding sounds correct. \$\endgroup\$ Jun 23, 2013 at 5:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .