Casting from Int32 to 'Microsoft.DirectX.Direct3D.VertexShader'
How to solved error Unable to cast object of type 'System.Int32' to 开发者_C百科type 'Microsoft.DirectX.Direct3D.VertexShader'
We want to case ''System.Int32' value into 'Microsoft.DirectX.Direct3D.VertexShader' I tried with CType but not working. Also tried mD3DDevice.VertexShader = CObj(D3DFVF_CUSTOMVERTEX_BOX) but no luck Can you please help
The Microsoft.DirectX.Direct3D.VertexShader
is a class, a reference-type, not a value type. You cannot directly convert a System.Int32
to a VertexShader
, as VertexShader
isn't based on System.Int32
and there is no predefined conversion.
If you can think of a legitimate way to convert a System.Int32
to a VertexShader
, you can implement the conversion yourself.
Otherwise, it seems you should either:
- Consult the VertexShader documentation, and specifically its constructors documentation.
- Use a specific device's Device.GetVertexShaderInt32Constant and Device.SetVertexShaderConstantInt32 methods.
精彩评论