2

I am trying to save and restore state by using a StateBlock in SlimDX via the following snippet:

StateBlockMask mask = new StateBlockMask(null) { RasterizerState = true };
var sb = new StateBlock(device.Device, mask);

Both StateBlockMask and StateBlock are classes. This gives me a compilation error:

'.ctor' is not supported by the language

Reading from some other posts here on SO, it seems that this is a problem that has to do with calling the managed code with the wrong arguments. In the source of SlimDX, I find:

StateBlock::StateBlock(SlimDX::Direct3D10::Device^ device, StateBlockMask mask)

I have no experience at all with C++/CLI, so I am wondering if there is something wrong here (like a missing or extra ^), or should I concentrate of faults on my side?

(NOTE: This question has been cross-posted to gamedev.net, future users with the same question may also want to check for answers given there)

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
erik
  • 1,238
  • 3
  • 12
  • 23

2 Answers2

3

Is StateBlockMask a struct? If not, use StateBlockMask^ mask in the C++ constructor.

Lou Franco
  • 87,846
  • 14
  • 132
  • 192
  • StateBlockMask is a class (added the info to the original post). Unfortunately, I cannot recompile the C++ code at the current state of my project (not allowed). – erik Mar 01 '11 at 14:08
  • 1
    @erik - then you are done with this project, you cannot use this C++/CLI code without fixing the bug. – Hans Passant Mar 01 '11 at 15:07
  • You could write your own C++/CLI wrapper class that takes a StateBlockMask ^ and then within that wrapper class, call the StateBlock constructor. – Matt Smith Mar 02 '11 at 01:55
0

This looks like a bug in SlimDX. You might want to use the issue tracker to make sure it gets dealt with properly.

MikeP
  • 7,829
  • 33
  • 34
  • 1
    [Plagiarizing yourself?](http://www.gamedev.net/topic/596656-slimdx-c-stateblock-contructor-problem-ctor-not-supported-by-the-language/)... shame shame shame. Hurry up and get 2k rep so you can edit questions and add links to cross-posts. In the meantime you can always use comments. – Ben Voigt Mar 02 '11 at 01:47