|
Boost : |
From: Michael Marcin (mmarcin_at_[hidden])
Date: 2006-12-01 16:47:23
Michael Fawcett wrote:
> I have uploaded a small prototype that demonstrates the syntax
> mentioned in the thread below. It is in the Vault under Math -
> Geometry as swizzle_demo.zip.
>
> http://article.gmane.org/gmane.comp.lib.boost.devel/149076/match=geometry+vector+lib+swizzle
>
> Here's a small example showing its use:
>
> float4 b(1, 2, 3, 4);
>
> float4 a = b.xxxx(); // a is now 1, 1, 1, 1
> a = b.wwwz(); // a is now 4, 4, 4, 3
> a = b.yzzw(); // a is now 2, 3, 3, 4
> a = b.wzyx(); // a is now 4, 3, 2, 1
>
> float4 c(10, 20, 30, 40);
> c.yz() = b.zy(); // c is now 10, 3, 2, 40
>
> <snip>
>
Very cool! I know nothing about the PP library so it is very hard for me to
decipher what the code is doing.
If I were to write:
float4 red( 1, 0, 0, 1 );
glColor4fv( (float*)&red ); // make color red
glColor4fv( (float*)&red.xxxw() ); // make color white
would this work? I'm guessing red would and white would not.
Thanks,
Michael Marcin
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk