Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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!

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
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. –  SICGames2013 Jun 23 '13 at 4:54
    
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! –  SICGames2013 Jun 23 '13 at 5:16
    
No problem, glad that's sorted out :). Your understanding sounds correct. –  MaulingMonkey Jun 23 '13 at 5:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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