View Full Version : TBGL_GBufferDefineFromArray how without function overloading ?
Petr, I was wondering how you handled different parameter values, like vec2f or vec3f and rgb or rgba in TBGL_GBufferDefineFromArray
without function overloading?
Thanks for any tips.
Petr Schreiber
22-05-2017, 09:24
Hi Kent,
in TBGL_GBufferCreate you specify if buffer is 2D or 3D. Then the TBGL_GBufferDefineFromArray presumes 2f or 3f accordingly. I parse just pointer to whatever is passed there, so type does not matter.
Petr
Petr Schreiber
22-05-2017, 20:22
In pure thinBASIC, you can go polymorphic with passing parameter as UDT this way:
uses "TBGL", "Console"
dim arr2d(3) as tbgl_tVector2f
dim arr3d(3) as tbgl_tVector3f
TellMeWhatItIs(arr2d)
TellMeWhatItIs(arr3d)
waitkey
function TellMeWhatItIs(byref x() as any)
select case sizeOf(x(1))
case sizeOf(tbgl_tVector2f)
printl "It is 2D!"
case sizeOf(tbgl_tVector3f)
printl "It is 3D!"
case else
printl "I am dazed and confused"
end select
end function
Petr