Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


How to include in *fx. file?


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
3 replies to this topic

#1 YaroslavDev   Members   -  Reputation: 113

Like
0Likes
Like

Posted 20 February 2011 - 11:34 AM

Book: "Introduction to 3d game programming with DirectX 10" by Frank D. Luna.
In the end of the chapter 5 there are some exercises. In #5 we should modify vertex shader adding a GameTimer::getGameTime() function. But this function belongs to GameTimer class. And every time I try to include "GameTimer.h" in .fx file I get an error(cannot find such file), but all files are in the same folder.

How should I include correctly this class in *.fx file?

Sponsor:

#2 Khulad   Members   -  Reputation: 103

Like
1Likes
Like

Posted 20 February 2011 - 03:37 PM

I don't know the source, but maybe you can rewrite the code as a function inside the fx file?

#3 liamf1986   Members   -  Reputation: 115

Like
1Likes
Like

Posted 20 February 2011 - 04:44 PM

I've not read the book so can't be sure but my guess is that he wants you to pass the value returned from the GameTimer::GetTime() function into the .fx file as a variable.
So something like this,

.fx file
float	gTime;

// vertex shader stuff.
Output VertexShader(Input in)
{
	Output out;

	out = in.Position*gTime;

	return out;
}

So basically in the .fx file I've created a variable at the top called gTime. This value is then accessed somewhere inside the vertex shader ( in my basic example it is multiplied with the given position values).
You would need to set this new variable in your C++ code before drawing anything with the effect applied, something like this,

.cpp file
// Heres the important line!!!
Effect.SetBool("gTime", GameTimer.GetTime());

Effect.Begin()
// Draw something awesome. Like a duck!
Effect.End()

Unfortunatly I have no idea of the exact code to set variables in your example but your current code should be setting some variables for the effect file already. So if you can find that code and copy it for your new variable that should work out.
Look in your draw code within your .cpp file and it should be setting a View or ViewProjection for the effect somewhere before drawing it.

hope that all makes sense and that its what your actually looking for.
Liam

#4 YaroslavDev   Members   -  Reputation: 113

Like
0Likes
Like

Posted 21 February 2011 - 07:51 AM

Thanks a lot! Yes, that was exactly what I needed.






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