ReneMiner
29-09-2013, 11:31
It's not TBGL-question but I saw in TBGL-Module a technique where I'm nosy about.
It's about TBGL_EntitySetUserData( SceneID, EntityID, UserData )
In UserData-parameter I just pass the name of the variable of an arbitrary type - the function does the rest...
Now what I want to know:
How does the function know, what data & which size to store - how does it get the information of correct varptr and varsize?
I know how to get correct pointer - but how to get size then?
Uses "console"
Type t_Type
A As Long
B As Byte
C As Double
End Type
Dim foo As t_Type
Long mySize
DWord myPtr
Sub GetInfo(ByRef var As Any, ByRef lSize As Long, ByRef vPtr As DWord)
vPtr = VarPtr var
lSize = SizeOf(var)
End Sub
GetInfo foo, mySize, myPtr
PrintL VarPtr( foo ) + $TAB + myPtr ' should both be equal...
PrintL SizeOf( foo ) + $TAB + mySize ' but size is not...
PrintL Repeat$(50, "-" )
PrintL "key to end" + $CRLF
WaitKey
Got a hint for me?
Edit:
- I think I've found out...
just
Sub GetInfo(ByRef var, ByRef lSize As Long, ByRef vPtr As DWord)
but not working if foo were an array....but no problem here- I intend to pass simple absolute variables only
It's about TBGL_EntitySetUserData( SceneID, EntityID, UserData )
In UserData-parameter I just pass the name of the variable of an arbitrary type - the function does the rest...
Now what I want to know:
How does the function know, what data & which size to store - how does it get the information of correct varptr and varsize?
I know how to get correct pointer - but how to get size then?
Uses "console"
Type t_Type
A As Long
B As Byte
C As Double
End Type
Dim foo As t_Type
Long mySize
DWord myPtr
Sub GetInfo(ByRef var As Any, ByRef lSize As Long, ByRef vPtr As DWord)
vPtr = VarPtr var
lSize = SizeOf(var)
End Sub
GetInfo foo, mySize, myPtr
PrintL VarPtr( foo ) + $TAB + myPtr ' should both be equal...
PrintL SizeOf( foo ) + $TAB + mySize ' but size is not...
PrintL Repeat$(50, "-" )
PrintL "key to end" + $CRLF
WaitKey
Got a hint for me?
Edit:
- I think I've found out...
just
Sub GetInfo(ByRef var, ByRef lSize As Long, ByRef vPtr As DWord)
but not working if foo were an array....but no problem here- I intend to pass simple absolute variables only