You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the awesome code, it is really helping me make the move from XNA.
I am having a small issue in the LightDemo project, perhaps you can explain why.
In the DrawScene method you have the following code:
var array = Util.GetArray(_dirLight);
_fxDirLight.SetRawValue(new DataStream(array, false, false), array.Length);
All is well until it tries to set the array as "Util.GetArray(_pointLight)" and call _fxPointLight.SetRawValue()
At the SetRawValue call an object reference error is thrown by SlimDX.
I looked it up and came across that section of the tutorial. Someone left a comment there saying that they had a similar issue and that they resolved if by initializing a new array with the size [1024] for each of these calls. I tried that and it did not work (Same Error).
Please let me know if you can help and thanks again for the awesome tutorials.
Regards,
George
The text was updated successfully, but these errors were encountered:
Hi, @ericrrichards
Are you solve this problem?
I found a way bypass this problem, just modify byte array length to suit actual size:
public static byte[] GetArray(object o) {
var len = Marshal.SizeOf(o);
_unmanagedStaging = new byte[len];
Array.Clear(_unmanagedStaging, 0, _unmanagedStaging.Length);
if (len >= _unmanagedStaging.Length) {
_unmanagedStaging = new byte[len];
}
var ptr = Marshal.AllocHGlobal(len);
Marshal.StructureToPtr(o, ptr, true);
Marshal.Copy(ptr, _unmanagedStaging, 0, len);
Marshal.FreeHGlobal(ptr);
return _unmanagedStaging;
}
Hi Eric,
Thanks for the awesome code, it is really helping me make the move from XNA.
I am having a small issue in the LightDemo project, perhaps you can explain why.
In the DrawScene method you have the following code:
var array = Util.GetArray(_dirLight);
_fxDirLight.SetRawValue(new DataStream(array, false, false), array.Length);
All is well until it tries to set the array as "Util.GetArray(_pointLight)" and call _fxPointLight.SetRawValue()
At the SetRawValue call an object reference error is thrown by SlimDX.
I looked it up and came across that section of the tutorial. Someone left a comment there saying that they had a similar issue and that they resolved if by initializing a new array with the size [1024] for each of these calls. I tried that and it did not work (Same Error).
Please let me know if you can help and thanks again for the awesome tutorials.
Regards,
George
The text was updated successfully, but these errors were encountered: