# 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.

## 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 on other sites
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 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 on other sites
ouch...

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

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633323
• Total Posts
3011361
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

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!