Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

It looks like you can use the MarshalAs attribute like so

[StructLayout(LayoutKind.Sequential, Pack = 16)]
public struct cb0_t
{
    public Matrix mWorld;
    public Matrix mView;
    public Matrix mProj;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
    public Vector4[] vLightDir;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
    public Vector4[] vLightColor;
    public Vector4 vOutputColor;
} 

You can take a look at this article, search for the heading Arrays.

Otherwise here's a shorter solution on StackOverflowshorter solution on StackOverflow.

It looks like you can use the MarshalAs attribute like so

[StructLayout(LayoutKind.Sequential, Pack = 16)]
public struct cb0_t
{
    public Matrix mWorld;
    public Matrix mView;
    public Matrix mProj;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
    public Vector4[] vLightDir;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
    public Vector4[] vLightColor;
    public Vector4 vOutputColor;
} 

You can take a look at this article, search for the heading Arrays.

Otherwise here's a shorter solution on StackOverflow.

It looks like you can use the MarshalAs attribute like so

[StructLayout(LayoutKind.Sequential, Pack = 16)]
public struct cb0_t
{
    public Matrix mWorld;
    public Matrix mView;
    public Matrix mProj;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
    public Vector4[] vLightDir;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
    public Vector4[] vLightColor;
    public Vector4 vOutputColor;
} 

You can take a look at this article, search for the heading Arrays.

Otherwise here's a shorter solution on StackOverflow.

Source Link

It looks like you can use the MarshalAs attribute like so

[StructLayout(LayoutKind.Sequential, Pack = 16)]
public struct cb0_t
{
    public Matrix mWorld;
    public Matrix mView;
    public Matrix mProj;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
    public Vector4[] vLightDir;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
    public Vector4[] vLightColor;
    public Vector4 vOutputColor;
} 

You can take a look at this article, search for the heading Arrays.

Otherwise here's a shorter solution on StackOverflow.