A
AbdEllah Gogop
Guest
i have converted the native C++ transparency project (from DirectX10 SDk 2010) to vb.NET, and the vb sample works fine but there is a point concerning assining a value (an IntPtr) to a member of a structure: a piece of code is:
' g_QuadVertices is an array of structure:
Dim g_QuadVertices(0 To 5) As QuadVertex
g_QuadVertices(0).v3Pos = New D3DXVECTOR3(-1.0F, -1.0F, 0.0F)
g_QuadVertices(0).v3Normal = New D3DXVECTOR3(0.0F, 0.0F, -1.0F)
g_QuadVertices(0).v2TexCoord = New D3DXVECTOR2(0.0F, 1.0F)
g_QuadVertices(1).v3Pos = New D3DXVECTOR3(-1.0F, 1.0F, 0.0F)
g_QuadVertices(1).v3Normal = New D3DXVECTOR3(0.0F, 0.0F, -1.0F)
g_QuadVertices(1).v2TexCoord = New D3DXVECTOR2(0.0F, 0.0F)
g_QuadVertices(2).v3Pos = New D3DXVECTOR3(1.0F, -1.0F, 0.0F)
g_QuadVertices(2).v3Normal = New D3DXVECTOR3(0.0F, 0.0F, -1.0F)
g_QuadVertices(2).v2TexCoord = New D3DXVECTOR2(1.0F, 1.0F)
g_QuadVertices(3).v3Pos = New D3DXVECTOR3(-1.0F, 1.0F, 0.0F)
g_QuadVertices(3).v3Normal = New D3DXVECTOR3(0.0F, 0.0F, -1.0F)
g_QuadVertices(3).v2TexCoord = New D3DXVECTOR2(0.0F, 0.0F)
g_QuadVertices(4).v3Pos = New D3DXVECTOR3(1.0F, 1.0F, 0.0F)
g_QuadVertices(4).v3Normal = New D3DXVECTOR3(0.0F, 0.0F, -1.0F)
g_QuadVertices(4).v2TexCoord = New D3DXVECTOR2(1.0F, 0.0F)
g_QuadVertices(5).v3Pos = New D3DXVECTOR3(1.0F, -1.0F, 0.0F)
g_QuadVertices(5).v3Normal = New D3DXVECTOR3(0.0F, 0.0F, -1.0F)
g_QuadVertices(5).v2TexCoord = New D3DXVECTOR2(1.0F, 1.0F)
Dim _all As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(GetType(QuadVertex)) * g_QuadVertices.Length)
Dim g_QuadVertices_p(0 To g_QuadVertices.Length) As IntPtr
For i = 0 To g_QuadVertices.Length - 1
g_QuadVertices_p(i) = Marshal.AllocHGlobal(Marshal.SizeOf(GetType(QuadVertex)))
Marshal.StructureToPtr(g_QuadVertices(i), g_QuadVertices_p(i), True)
Next i
Marshal.Copy(g_QuadVertices_p, 0, _all, g_QuadVertices_p.Length)
InitData.pSysMem = _all
so the sample does not show the quad (nothing is shown) but if the code above is replaced with the following code , it works
BOOL ver2(QuadVertex sv[], D3D10_SUBRESOURCE_DATA * InitData)
{
InitData->pSysMem = (void*)sv;
return TRUE;
}
remark: the ver2 function is the bridge between the vb.NET project and the native C++ code:
so finally , what is the equivalent vb.NET code for the line : InitData->pSysMem = (void*)sv;
Continue reading...
' g_QuadVertices is an array of structure:
Dim g_QuadVertices(0 To 5) As QuadVertex
g_QuadVertices(0).v3Pos = New D3DXVECTOR3(-1.0F, -1.0F, 0.0F)
g_QuadVertices(0).v3Normal = New D3DXVECTOR3(0.0F, 0.0F, -1.0F)
g_QuadVertices(0).v2TexCoord = New D3DXVECTOR2(0.0F, 1.0F)
g_QuadVertices(1).v3Pos = New D3DXVECTOR3(-1.0F, 1.0F, 0.0F)
g_QuadVertices(1).v3Normal = New D3DXVECTOR3(0.0F, 0.0F, -1.0F)
g_QuadVertices(1).v2TexCoord = New D3DXVECTOR2(0.0F, 0.0F)
g_QuadVertices(2).v3Pos = New D3DXVECTOR3(1.0F, -1.0F, 0.0F)
g_QuadVertices(2).v3Normal = New D3DXVECTOR3(0.0F, 0.0F, -1.0F)
g_QuadVertices(2).v2TexCoord = New D3DXVECTOR2(1.0F, 1.0F)
g_QuadVertices(3).v3Pos = New D3DXVECTOR3(-1.0F, 1.0F, 0.0F)
g_QuadVertices(3).v3Normal = New D3DXVECTOR3(0.0F, 0.0F, -1.0F)
g_QuadVertices(3).v2TexCoord = New D3DXVECTOR2(0.0F, 0.0F)
g_QuadVertices(4).v3Pos = New D3DXVECTOR3(1.0F, 1.0F, 0.0F)
g_QuadVertices(4).v3Normal = New D3DXVECTOR3(0.0F, 0.0F, -1.0F)
g_QuadVertices(4).v2TexCoord = New D3DXVECTOR2(1.0F, 0.0F)
g_QuadVertices(5).v3Pos = New D3DXVECTOR3(1.0F, -1.0F, 0.0F)
g_QuadVertices(5).v3Normal = New D3DXVECTOR3(0.0F, 0.0F, -1.0F)
g_QuadVertices(5).v2TexCoord = New D3DXVECTOR2(1.0F, 1.0F)
Dim _all As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(GetType(QuadVertex)) * g_QuadVertices.Length)
Dim g_QuadVertices_p(0 To g_QuadVertices.Length) As IntPtr
For i = 0 To g_QuadVertices.Length - 1
g_QuadVertices_p(i) = Marshal.AllocHGlobal(Marshal.SizeOf(GetType(QuadVertex)))
Marshal.StructureToPtr(g_QuadVertices(i), g_QuadVertices_p(i), True)
Next i
Marshal.Copy(g_QuadVertices_p, 0, _all, g_QuadVertices_p.Length)
InitData.pSysMem = _all
so the sample does not show the quad (nothing is shown) but if the code above is replaced with the following code , it works
BOOL ver2(QuadVertex sv[], D3D10_SUBRESOURCE_DATA * InitData)
{
InitData->pSysMem = (void*)sv;
return TRUE;
}
remark: the ver2 function is the bridge between the vb.NET project and the native C++ code:
so finally , what is the equivalent vb.NET code for the line : InitData->pSysMem = (void*)sv;
Continue reading...