Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


Need help


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

#1 dawoodr   Members   -  Reputation: 259

Like
0Likes
Like

Posted 10 August 2014 - 05:54 PM

Hello!
 
	XMVECTOR gringo = { 1, 2, 3, 4 };

	float a = XMVectorGetY(gringo);
	cout << a << endl;
	XMVectorSetY(gringo, 40);
	a = XMVectorGetY(gringo);
	cout << a << endl;

The first output should be 2 which it is. The second output should be 40 put it's still 2, why? What have I done wrong?

 

Regards!

 



Sponsor:

#2 Buckeye   Crossbones+   -  Reputation: 5678

Like
1Likes
Like

Posted 10 August 2014 - 06:08 PM


What have I done wrong?

XMVectorSetY does not set the Y value in gringo. It returns an XMVECTOR the same as the argument (gringo, in your case), except the Y value is replaced. Your code generates the new vector, which would be { 1, 40, 3, 4} but you don't store it.

    XMVECTOR g = { 1, 2, 3, 4 };
    float a = XMVectorGetY(g); // get g's Y value of 2.0f
    XMVECTOR g2 = XMVectorSetY(g, 40.0f);
    a = XMVectorGetY(g2); // get g2's Y value of 40.0f

Alternatively,

gringo = XMVectorSetY(gringo, 40.0f);
a = XMVectorGetY(gringo); // now a==40.0f

FYI, I didn't know that of my own certain knowledge. I looked at the docs (which you can, also) and tried a quick test.


Edited by Buckeye, 10 August 2014 - 06:15 PM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.


#3 dawoodr   Members   -  Reputation: 259

Like
0Likes
Like

Posted 10 August 2014 - 06:18 PM

Thanks, so it was just that it was never stored,

 

Here is how I changed it now and it works fine, thanks once again!

 

XMVECTOR gringo = { 1, 2, 3, 4 };
 
float a = XMVectorGetY(gringo);
cout << a << endl;
gringo = XMVectorSetY(gringo, 40);
a = XMVectorGetY(gringo);
cout << a << endl;





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