Jump to content

  • Log In with Google      Sign In   
  • Create Account

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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 axefrog   Members   -  Reputation: 397

Like
1Likes
Like

Posted 21 February 2014 - 01:35 AM

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, 21 February 2014 - 01:43 AM.

I'm blogging about my journey to learn 3D graphics and game programming: http://nathanridley.com


Sponsor:

#2 axefrog   Members   -  Reputation: 397

Like
1Likes
Like

Posted 21 February 2014 - 04:21 AM

I solved the problem. I wasn't setting the constant buffer properly.

http://www.gamedev.net/topic/648400-sharpdx-how-to-set-constant-buffer-when-using-effect-technique/


I'm blogging about my journey to learn 3D graphics and game programming: http://nathanridley.com





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS