tags:

views:

25

answers:

1

How to solved error Unable to cast object of type 'System.Int32' to 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

A: 

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:

  1. Consult the VertexShader documentation, and specifically its constructors documentation.
  2. Use a specific device's Device.GetVertexShaderInt32Constant and Device.SetVertexShaderConstantInt32 methods.
M.A. Hanin
Thanks for replying.Its 9.15 PM and Its Time to leave....will try Tomorrow.Thanks...!!!
Avinash