Sign in to follow this  

[SharpDX] After changing my noob code to use a technique instead of shaders directly, nothing displays anymore

This topic is 1425 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 normally wouldn't ask anything like this, I hate it when people dump code on forums and expect you to debug it for them. I am however completely stumped and have nowhere to turn, so I figure if I can keep things succinct, maybe one of you fine folks might be able to spot where I am going wrong.

 

Also, I'm a big fan of the concept "give a man a fish and you'll feed him for a day, teach a man to fish and you'll feed him for a lifetime", so I'll be describing the problem below, but I'd really appreciate if you could help me understand how I could have debugged the problem myself. Normally when developing software I am able to debug almost anything via a process of elimination, narrowing the problem range, observation of values while in debug mode, following stack traces and so forth, but in this case it's completely unclear what I need to look for mainly due to my inexperience working with the Direct3D APIs.

 

Note: any linked words below go directly to source code on Github for your reference.

 

Ok, so I've been learning basic 3D programming with Direct3D 11 using SharpDX. I had a nice test project (source here) working that would display some animated rainbow-coloured cubes and was shading them using individually-compiled vertex and pixel shaders. The vertex shader was just for the basic transforms and the pixel shader just picked an interpolated colour. This all worked fine, as you'll see if you feel like compiling the source code.

 

The next chapter in my book has been talking about using effects files and so I copied my source to a new project (source here), and took my vertex and pixel shader code, put them both in the same .fx file and added code into that file to describe the technique that should encapsulate both shaders, with the intention to apply the technique in my code rather than hooking up the shaders directly.

 

My new class for making use of the technique replaced my shader classes I had in the old version of my project and I started using "pass.Apply" to render, rather than setting the vertex and pixel shaders manually before calling my Draw() methods. So my renderer now calls directly into my effect class to do the drawing. Note also that my initialization of the input layout now takes the input layout from the signature of the first pass in the technique, rather than directly from the vertex shader which it did in the old version.

 

Even though my code seems to be straightforward and I've attempted to follow examples and understand what I'm doing, no cubes are rendering anymore. All I get is a blank background.

 

Any help would be much appreciated, and in particular any suggestions on how I could have figured out the problem myself, for future reference.

Edited by axefrog

Share this post


Link to post
Share on other sites

This topic is 1425 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this