Hello,
im sorry if this thread is barely on topic, im writing an editor for my engine in VB.NET but the problem is not in the 3d department
Let me explain the situation, i have the engine core done in a C++ DLL, the DLL exports many functions which work very well when called from the VB.NET application. Everything works fine, marshalling structures, floats, integers etc, the editor stays up for days rendering and operating, the application seems stable.
I've added an export function which is expected to fill an array of structures defined both VB and in C++ with vertex and pixel shaders information, each element of the array is a vertex or a pixel shader information structure. The VB.NET application creates the array and passes it to the dll function, the dll function fills the array and then returns the number of shaders it has loaded so far. The problem is, AFTER i call the DLL function (which is called DllEnumeraShaders() ) the size of the VB.NET array, which is defined as 512 in the VB.NET application, is truncated to 1(0), no matter what i do in the C++ DLL (so im sure it's a marshalling problem).
Here is the code:
Dim InfoArray(512) As InfoShader
Dim ret As Integer
ret = DllEnumeraShaders(InfoArray, InfoArray.Length, eTipoShader.IS_VERTEXSHADER)
this is the function def in vb net:
Public Declare Auto Function DllEnumeraShaders Lib "DLLEngine" Alias "_116" (<MarshalAs(UnmanagedType.LPArray)> ByRef array() As InfoShader, <MarshalAs(UnmanagedType.I4)> ByVal lunghezzamax As Integer, <MarshalAs(UnmanagedType.I4)> ByVal TipoShader As eTipoShader) As Integer
this is the InfoShader structure (which is expected to grow as soon i've fixed this):
<StructLayout(LayoutKind.Sequential)> _
Public Structure InfoShader
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=512)> Public NomeFile As String
Public RefCount As Integer
End Structure
this is the C++ DLL function:
// DllEnumeraShaders
int DLLENGINE_API _116(Dispositivo::InfoShader **info, int arraylen, int type)
{
// Even by doing nothing the array gets truncated
return 3;
if (Engine == 0) {
g_LogClass.ScriviFileDiLog("DllEnumeraShaders() Engine non inizializzato", E_ERRORE, V_SEMPRE);
return 0;
}
return Engine->EnumeraShaders(info, arraylen, type);
}
Im getting quite mad, i can't seem to figure out what im doing wrong... any ideas?
im sorry if this thread is barely on topic, im writing an editor for my engine in VB.NET but the problem is not in the 3d department
Let me explain the situation, i have the engine core done in a C++ DLL, the DLL exports many functions which work very well when called from the VB.NET application. Everything works fine, marshalling structures, floats, integers etc, the editor stays up for days rendering and operating, the application seems stable.
I've added an export function which is expected to fill an array of structures defined both VB and in C++ with vertex and pixel shaders information, each element of the array is a vertex or a pixel shader information structure. The VB.NET application creates the array and passes it to the dll function, the dll function fills the array and then returns the number of shaders it has loaded so far. The problem is, AFTER i call the DLL function (which is called DllEnumeraShaders() ) the size of the VB.NET array, which is defined as 512 in the VB.NET application, is truncated to 1(0), no matter what i do in the C++ DLL (so im sure it's a marshalling problem).
Here is the code:
Dim InfoArray(512) As InfoShader
Dim ret As Integer
ret = DllEnumeraShaders(InfoArray, InfoArray.Length, eTipoShader.IS_VERTEXSHADER)
this is the function def in vb net:
Public Declare Auto Function DllEnumeraShaders Lib "DLLEngine" Alias "_116" (<MarshalAs(UnmanagedType.LPArray)> ByRef array() As InfoShader, <MarshalAs(UnmanagedType.I4)> ByVal lunghezzamax As Integer, <MarshalAs(UnmanagedType.I4)> ByVal TipoShader As eTipoShader) As Integer
this is the InfoShader structure (which is expected to grow as soon i've fixed this):
<StructLayout(LayoutKind.Sequential)> _
Public Structure InfoShader
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=512)> Public NomeFile As String
Public RefCount As Integer
End Structure
this is the C++ DLL function:
// DllEnumeraShaders
int DLLENGINE_API _116(Dispositivo::InfoShader **info, int arraylen, int type)
{
// Even by doing nothing the array gets truncated
return 3;
if (Engine == 0) {
g_LogClass.ScriviFileDiLog("DllEnumeraShaders() Engine non inizializzato", E_ERRORE, V_SEMPRE);
return 0;
}
return Engine->EnumeraShaders(info, arraylen, type);
}
Im getting quite mad, i can't seem to figure out what im doing wrong... any ideas?