Jump to content
  • Advertisement
Sign in to follow this  
Keba

ID3DXEffect::SetVector question

This topic is 4845 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

SDK doc:
Quote:
Syntax: HRESULT SetVector(D3DXHANDLE hParameter, CONST D3DXVECTOR4* pVector ); Parameters hParameter [in] Unique identifier. See Handles. pVector [in] Pointer to a 4-D vector. Return Value If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be D3DERR_INVALIDCALL. Remarks If the destination vector is smaller than the source vector, the additional components of the source vector will be ignored.
now, take a look at the remarks....what if the source vector i smaller than a 4 component vector, assume this:

class CMyCoolVectorClass
{
public:
....

....

protected:
float X;
float Y;
float Z;

};
is it safe to put an object from CMyCoolVectorClass as input to SetVector? will D3DX realise thats just a 3 component vector?

Share this post


Link to post
Share on other sites
Advertisement
The way I read it, the source vector must be 4 components. You can't send a 3 component vector as in passing a D3DXVECTOR3 structure in. Granted, if you know that your destination vector is always going to be 3 or less components, and you want to cast your CMyCoolVectorClass to a D3DXVECTOR4 structure when passing it in, I don't see why it wouldn't work (but there are no guarantees). I hope you don't forget about it later when you decide to add a 4-element vector to the effect. :)

Chris

Share this post


Link to post
Share on other sites
Remember, you can always just use ID3DXEffect::SetValue() for data structures that the effect framework doesn't account for. It is quite useful for custom data structures (like lights), arrays, and batch updating.

Share this post


Link to post
Share on other sites
ouch...

SetValue....what an obvious function, didn't see that one :D
thanks circlesoft

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!