zengqh / slimdx

Automatically exported from code.google.com/p/slimdx
0 stars 0 forks source link

D3D9X: Effect.SetValue<bool>("param", value) #333

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
D3D9X: Effect.SetValue<bool>("param", value) is not working in 2.0.5.39 
(September 08) version.
I recieve INVALID_CALL exception.

It did work in previous June 08 SP1 version.

work-around (for me): change it to 'int' parameter

Original issue reported on code.google.com by daniel.z...@gmail.com on 10 Sep 2008 at 12:42

GoogleCodeExporter commented 9 years ago
Hmm. Yeah, the problem is that DX uses BOOL, which is actually an int. I'm not 
sure 
if we should handle that as a special case in SetValue, or add SetBool...

Original comment by promit....@gmail.com on 10 Sep 2008 at 7:56

GoogleCodeExporter commented 9 years ago
Taking ownership.

Original comment by Mike.Popoloski on 18 Sep 2008 at 7:58

GoogleCodeExporter commented 9 years ago
Fixed. (I think).

Original comment by Mike.Popoloski on 19 Sep 2008 at 3:56

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I think the array version is still broken. You can't call CopyTo to convert a 
bool[]
to an int[]. It will throw an ArrayTypeMismatchException. At least this piece 
of code
does:
var d1 = new[] {true, false, true, false};
var d2 = new int[d1.Length];
d1.CopyTo(d2, 0);

You'll probably need to copy the elements by hand.
if( T::typeid == bool::typeid )
{
    array<bool>^ oldValues = static_cast<array<bool>^>(values);
    array<BOOL>^ newValues = gcnew array<BOOL>( values->Length );
    for(int i = 0; i < values->Length; ++i){
        newValues[i] = oldValues[i];
    }

    return SetValue( parameter, newValues );
}

It might be useful to treat bool[] as a special case and provide an overload 
for it.
It will avoid the if statement and the cast from T[] to bool[].

Original comment by m...@andreloker.de on 22 Sep 2008 at 9:12

GoogleCodeExporter commented 9 years ago
Grrr...

Original comment by Mike.Popoloski on 23 Sep 2008 at 3:45

GoogleCodeExporter commented 9 years ago
OK, should be fixed now.

Original comment by Mike.Popoloski on 28 Sep 2008 at 2:17