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.

When writing code that interacts with multiple shaders, is it best practice to hard code the use of each effect? I wrote a couple of hard-coded loops and then noticed that I accidentally ended the pass of the wrong shader, and this has me concerned that instead, I should be writing some sort of Shader class that generically executes a shader. Is this the right way to go?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

Yes, it would be more scalable in the long run to write a system could wrap and handle what your shaders need for you.

There are several ways to do this, such as having a "Shader" class like you mentioned that inspects the underlying D3D Effect object for semantic annotations that let your wrapper class determine things like which kinds of vertex or texture input are required, begins and ends all the appropriate classes, et cetera.

share|improve this answer
add comment

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.