View Full Version : Boosting calculation speed using compilers DLLs (such as FreeBasic)
look at http://www.thinbasic.com/community/showthread.php?12608-GBuffer-tests , i have used big equations to display the simpsons figure, the calculation time is about 10 seconds so Peter have provided an animation to track the progress while you are waiting
i was toying with freebasic dlls to see how much we can boost thinbasic speed, i have used this tutorial (Creating your own DLL for Rapid-Q using FreeBasic ) http://rapidq.phatcode.net/tutorial/Freebasic_DLL_tutorial.html ,the good think it is easier to use thinbasic to declare and use functions in other dlls
the time of running this simpson code 1 second, compare to the previous 10 seconds. so we can use the Brain of thinbasic (with all its functions and Graphics capabilities) while when needed we seek help from the muscles of other compilers for math repetitive tasks like this one.
notes if you want to compile the freebasic code yourself use this:
fbc -dll dll_udt_VertexArrays.bas
don't forget to add to the freebasic path in environment variable: (in windows xp):
C:\FreeBASIC;C:\FreeBASIC\bin\win32
the big size of dll_udt_VertexArrays.bas and its compiled form dll_udt_VertexArrays.dll (inside the attached rar file) is because it contains the X, Y data for the simpson shape which are too big
ErosOlmi
27-11-2015, 19:07
Great way to mix the power of different languages.
I would be curious to see how this can be developed using thinBasic Oxygen module.
Oxygen is a JIT (Just In Time) Compiler developed by Charles Pegge.
It can take a BASIC Like syntax very close to thinBasic language and compile it on the fly in machine code.
Usually execution speed is 100 times faster than thinBasic execution speed that is parsing/interpreting source code directly over and over.
It is also possible to interact between thinBasic and Oxygen variables.
If someone has some time ... :)
Ciao
Eros
Petr Schreiber
27-11-2015, 20:20
Thanks for nice FreeBasic - ThinBASIC interop example!
Here is how you can just-in-time compile and execute super fast code via Oxygen:
Uses "TBGL", "math", "Oxygen"
Function TBMain()
Local hWnd As DWord
Local FrameRate As Double
' -- Create and show window
hWnd = TBGL_CreateWindowEx("Plotting 3D Data in an array using GBuffers- Calculate with Oxygen JIT ..Esc to quit", 600, 600, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX)
TBGL_ShowWindow
TBGL_BackColor 255,255,255
'TBGL_SetDrawDistance 250
' -- Create 3D points buffer
DWord gbPoints = TBGL_GBufferCreate(%TBGL_POINTS, %TBGL_3D)
Global Nb As DWord = 22619 ' 72*pi/0.01
' -- Define data for it
Global VertexA(Nb) As TBGL_TVECTOR3F ' single
Global ColorA(Nb) As TBGL_TRGB ' Byte
FillArrays()
' -- Create buffer dynamically linked to the arrays above
TBGL_GBufferDefineFromArray(gbPoints, %TBGL_DYNAMIC, CountOf(VertexA), VertexA(1), ColorA(1))
' -- Resets status of all keys
TBGL_ResetKeyState()
'TBGL_PointSize 2
' -- Main loop
While TBGL_IsWindow(hWnd)
'init
FrameRate = TBGL_GetFrameRate
TBGL_ClearFrame
TBGL_Camera(0, 0, 90, 0, 0, 0)
' -- Turn triangle
TBGL_Rotate GetTickCount/50, 0, 1, 0
TBGL_Scale 0.6, 0.6, 0.6
' -- Render it
TBGL_GBufferRender(gbPoints)
TBGL_DrawFrame
' -- ESCAPE key to exit application
If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While
Wend
' -- Destroying the buffer is not necessary,
' -- the garbage collector will take care of it
' -- Destroy window
TBGL_DestroyWindow
End Function
Function FillArrays()
String src = "
basic
' -- Re-declare types
Type TBGL_TRGB
r As Byte
g As Byte
b As Byte
End Type
Type TBGL_TVECTOR3F
x As Single
y As Single
z As Single
end type
Function theta(a As Single) As Single
If a<=0 Then
Function = 0
Else
Function = 1
End If
End Function
' -- Link variables
dim oVertexA(30159) At #VertexA As TBGL_TVECTOR3F
dim oColorA(30159) At #ColorA As TBGL_TRGB
Single x, y, z, t
DWord N = 1
While t <= 72*3.14
x = ((-5/37 *Sin(61/42-8 *t)-112/41 *Sin(36/23-7 *t)-62/37 *Sin(14/9-6 *t)-31/7 *Sin(69/44-5 *t)-275/13 *Sin(47/30-3 *t)-23/38 *Sin(48/31-2 *t)+461/10 *Sin(t+107/68)+8/23 *Sin(4 *t+179/38)-2345/18) *theta(71 *Pi-t) *theta(t-67 *Pi)+(-41/74 *Sin(112/75-17 *t)-274/37 *Sin(17/11-11 *t)-907/30 *Sin(36/23-5 *t)+623/15 *Sin(t+47/30)+684/29 *Sin(2 *t+212/45)+3864/25 *Sin(3 *t+63/40)+1513/78 *Sin(4 *t+19/12)+269/45 *Sin(6 *t+14/9)+66/25 *Sin(7 *t+155/33)+121/35 *Sin(8 *t+27/17)+44/13 *Sin(9 *t+35/22)+71/7 *Sin(10 *t+30/19)+87/40 *Sin(12 *t+57/37)+61/62 *Sin(13 *t+47/28)+43/65 *Sin(14 *t+31/20)+54/37 *Sin(15 *t+127/27)+56/27 *Sin(16 *t+30/19)+11843/35) *theta(67 *Pi-t) *theta(t-63 *Pi)+(-119/55 *Sin(65/43-13 *t)-78/11 *Sin(82/55-12 *t)-25/31 *Sin(36/23-11 *t)-70/9 *Sin(31/20-9 *t)-707/65 *Sin(47/30-7 *t)-953/22 *Sin(45/29-5 *t)+962/15 *Sin(t+113/72)+1091/30 *Sin(2 *t+212/45)+3177/26 *Sin(3 *t+27/17)+1685/22 *Sin(4 *t+43/27)+143/27 *Sin(6 *t+49/32)+203/27 *Sin(8 *t+27/17)+411/37 *Sin(10 *t+50/31)+65/27 *Sin(14 *t+33/20)+8/19 *Sin(15 *t+13/7)+3/11 *Sin(16 *t+43/33)-11597/35) *theta(63 *Pi-t) *theta(t-59 *Pi)+(-1/7 *Sin(41/81-30 *t)-8/27 *Sin(3/28-28 *t)-10/23 *Sin(3/26-26 *t)+2377/13 *Sin(t+33/28)+43/15 *Sin(2 *t+26/7)+131/18 *Sin(3 *t+3/25)+45/41 *Sin(4 *t+105/32)+43/14 *Sin(5 *t+87/23)+135/136 *Sin(6 *t+51/20)+51/14 *Sin(7 *t+118/43)+19/18 *Sin(8 *t+23/18)+49/23 *Sin(9 *t+25/12)+14/19 *Sin(10 *t+63/55)+54/49 *Sin(11 *t+68/41)+32/37 *Sin(12 *t+30/29)+5/12 *Sin(13 *t+43/24)+34/45 *Sin(14 *t+15/17)+13/30 *Sin(15 *t+67/23)+21/31 *Sin(16 *t+43/60)+25/62 *Sin(17 *t+89/34)+9/20 *Sin(18 *t+11/26)+4/17 *Sin(19 *t+55/28)+26/51 *Sin(20 *t+4/17)+2/33 *Sin(21 *t+247/62)+14/31 *Sin(22 *t+9/44)+5/26 *Sin(23 *t+113/34)+9/17 *Sin(24 *t+3/10)+4/25 *Sin(25 *t+99/32)+6/23 *Sin(27 *t+548/183)+10/33 *Sin(29 *t+129/37)+5/12 *Sin(31 *t+127/39)-9719/87) *theta(59 *Pi-t) *theta(t-55 *Pi)+(228/65 *Sin(t+116/33)+353/40 *Sin(2 *t+33/19)+107/24 *Sin(3 *t+58/33)+58/21 *Sin(4 *t+519/130)+19/15 *Sin(5 *t+45/37)+13/12 *Sin(6 *t+145/38)+43/42 *Sin(7 *t+25/99)+11/19 *Sin(8 *t+105/44)+203/19) *theta(55 *Pi-t) *theta(t-51 *Pi)+(-23/10 *Sin(22/17-4 *t)-159/17 *Sin(156/125-3 *t)+523/112 *Sin(t+80/21)+111/23 *Sin(2 *t+25/24)+92/79 *Sin(5 *t+57/32)+58/37 *Sin(6 *t+159/35)+18/31 *Sin(7 *t+27/43)-7563/28) *theta(51 *Pi-t) *_
theta(t-47 *Pi)+(-76/17 *Sin(42/41-14 *t)-154/31 *Sin(37/38-11 *t)+10820/41 *Sin(t+25/34)+1476/31 *Sin(2 *t+36/19)+595/12 *Sin(3 *t+67/43)+3568/67 *Sin(4 *t+282/77)+974/59 *Sin(5 *t+40/19)+427/18 *Sin(6 *t+47/25)+454/23 *Sin(7 *t+20/27)+41/40 *Sin(8 *t+9/2)+139/22 *Sin(9 *t+99/26)+276/37 *Sin(10 *t+37/29)+113/25 *Sin(12 *t+61/30)+37/29 *Sin(13 *t+37/31)+51/19 *Sin(15 *t+127/34)+115/72 *Sin(16 *t+7/38)+162/43 *Sin(17 *t+67/21)+26/33 *Sin(18 *t+194/45)-3614/99) *theta(47 *Pi-t) *theta(t-43 *Pi)+(347/17 *Sin(t+3/13)+9951/41) *theta(43 *Pi-t) *theta(t-39 *Pi)+(760/29 *Sin(t+23/25)-6059/28) *theta(39 *Pi-t) *theta(t-35 *Pi)+(-106/41 *Sin(7/13-18 *t)-55/38 *Sin(13/29-16 *t)-173/19 *Sin(34/29-7 *t)-484/31 *Sin(13/16-5 *t)-1193/17 *Sin(97/83-2 *t)+6885/26 *Sin(t+41/48)+99/5 *Sin(3 *t+5/16)+751/36 *Sin(4 *t+73/18)+129/40 *Sin(6 *t+83/18)+327/31 *Sin(8 *t+17/23)+498/47 *Sin(9 *t+123/88)+298/49 *Sin(10 *t+54/25)+82/15 *Sin(11 *t+153/35)+106/27 *Sin(12 *t+3/32)+171/43 *Sin(13 *t+433/173)+36/11 *Sin(14 *t+98/33)+39/22 *Sin(15 *t+97/25)+68/37 *Sin(17 *t+157/34)-227/29) *theta(35 *Pi-t) *theta(t-31 *Pi)+(-2/15 *Sin(66/47-14 *t)-45/23 *Sin(5/9-11 *t)-151/43 *Sin(13/32-8 *t)-31/36 *Sin(24/19-7 *t)+2121/32 *Sin(t+45/38)+2085/47 *Sin(2 *t+299/88)+1321/43 *Sin(3 *t+72/25)+557/37 *Sin(4 *t+74/21)+205/17 *Sin(5 *t+27/23)+13/9 *Sin(6 *t+113/32)+35/17 *Sin(9 *t+7/22)+93/26 *Sin(10 *t+112/25)+11/14 *Sin(12 *t+58/17)+8/15 *Sin(13 *t+47/30)+33/20 *Sin(15 *t+32/25)+31/94 *Sin(16 *t+192/59)+35/31 *Sin(17 *t+51/77)+9473/34) *theta(31 *Pi-t) *theta(t-27 *Pi)+(-33/29 *Sin(27/55-12 *t)+388/13 *Sin(t+5/13)+2087/30 *Sin(2 *t+193/55)+1311/49 *Sin(3 *t+133/30)+993/41 *Sin(4 *t+134/31)+175/17 *Sin(5 *t+73/29)+83/23 *Sin(6 *t+28/33)+9/19 *Sin(7 *t+73/36)+101/32 *Sin(8 *t+57/28)+51/25 *Sin(9 *t+106/39)+47/28 *Sin(10 *t+129/47)+17/29 *Sin(11 *t+33/17)+27/22 *Sin(13 *t+155/86)+108/65 *Sin(14 *t+8/27)+9/16 *Sin(15 *t+44/13)+11/14 *Sin(16 *t+3/19)+11/23 *Sin(17 *t+106/23)+9/64 *Sin(18 *t+97/22)-10004/35) *theta(27 *Pi-t) *theta(t-23 *Pi)+(-18/13 *Sin(7/50-18 *t)-7/5 *Sin(1/10-16 *t)-51/25 *Sin(18/19-12 *t)-219/35 *Sin(7/30-10 *t)-158/43 *_
Sin(40/37-6 *t)-512/25 *Sin(13/16-4 *t)-289/29 *Sin(68/67-2 *t)+18315/101 *Sin(t+29/18)+664/31 *Sin(3 *t+61/23)+48/11 *Sin(5 *t+84/67)+489/49 *Sin(7 *t+11/25)+397/33 *Sin(8 *t+8/19)+73/12 *Sin(9 *t+9/53)+194/41 *Sin(11 *t+17/14)+2/3 *Sin(13 *t+149/50)+43/29 *Sin(14 *t+91/31)+61/35 *Sin(15 *t+131/56)+29/37 *Sin(17 *t+1/19)+49/43 *Sin(19 *t+65/24)+15/19 *Sin(20 *t+88/21)+11/38 *Sin(21 *t+217/50)+3917/10) *theta(23 *Pi-t) *theta(t-19 *Pi)+(-8/9 *Sin(12/23-16 *t)-504/53 *Sin(8/29-8 *t)-635/43 *Sin(32/37-4 *t)-307/41 *Sin(8/27-3 *t)-20292/91 *Sin(16/19-t)+483/19 *Sin(2 *t+41/13)+108/23 *Sin(5 *t+70/29)+74/35 *Sin(6 *t+145/34)+287/43 *Sin(7 *t+69/16)+254/39 *Sin(9 *t+5/27)+19/4 *Sin(10 *t+37/30)+129/46 *Sin(11 *t+75/32)+24/19 *Sin(12 *t+71/46)+125/52 *Sin(13 *t+87/44)+46/27 *Sin(14 *t+40/31)+26/29 *Sin(15 *t+106/27)+25/63 *Sin(17 *t+53/12)+23/22 *Sin(18 *t+9/29)+3/35 *Sin(19 *t+205/103)+200/201 *Sin(20 *t+22/25)+8/31 *Sin(21 *t+77/25)-15195/29) *theta(19 *Pi-t) *theta(t-15 *Pi)+(-15/23 *Sin(22/23-35 *t)-21/26 *Sin(13/40-30 *t)-71/64 *Sin(16/19-29 *t)-97/29 *Sin(15/41-23 *t)-57/17 *Sin(54/35-16 *t)-79/25 *Sin(41/39-14 *t)-24/11 *Sin(3/8-13 *t)-149/17 *Sin(21/62-6 *t)-613/31 *Sin(16/17-2 *t)+6033/20 *Sin(t+24/17)+631/16 *Sin(3 *t+127/30)+463/31 *Sin(4 *t+71/28)+94/23 *Sin(5 *t+98/25)+45/11 *Sin(7 *t+31/10)+39/23 *Sin(8 *t+163/39)+23/22 *Sin(9 *t+42/17)+167/44 *Sin(10 *t+232/231)+233/49 *Sin(11 *t+29/45)+194/129 *Sin(12 *t+3/5)+166/37 *Sin(15 *t+83/29)+123/35 *Sin(17 *t+136/35)+47/26 *Sin(18 *t+64/25)+72/35 *Sin(19 *t+41/14)+56/31 *Sin(20 *t+48/35)+63/25 *Sin(21 *t+2/5)+100/37 *Sin(22 *t+13/15)+4/3 *Sin(24 *t+59/19)+17/25 *Sin(25 *t+15/38)+51/19 *Sin(26 *t+68/19)+11/27 *Sin(27 *t+228/91)+19/14 *Sin(28 *t+31/9)+4/13 *Sin(31 *t+14/55)+31/37 *Sin(32 *t+2/31)+150/151 *Sin(33 *t+58/21)+41/32 *Sin(34 *t+26/11)+4/3 *Sin(36 *t+25/18)-6956/53) *theta(15 *Pi-t) *theta(t-11 *Pi)+(4337/36 *Sin(t+45/29)+265/18) *theta(11 *Pi-t) *theta(t-7 *Pi)+(-23/21 *Sin(31/61-t)-1152/11) *theta(7 *Pi-t) *theta(t-3 *Pi)+(3314/27 *Sin(t+30/31)+65/31 *Sin(2 *t+26/23)-1467/5) *theta(3 *Pi-t) *theta(t+Pi)) *theta(Sqr(Sgn(Sin(t/2))))
y = ((-9/23 *Sin(38/25-6 *t)-67/38 *Sin(36/23-3 *t)+31/30 *Sin(t+14/9)+409/9 *Sin(2 *t+74/47)+493/141 *Sin(4 *t+85/54)+14/17 *Sin(5 *t+75/16)+5/46 *Sin(7 *t+21/13)+33/23 *Sin(8 *t+74/47)+14536/41) *theta(71 *Pi-t) *theta(t-67 *Pi)+(-89/29 *Sin(59/38-17 *t)-5/11 *Sin(14/9-16 *t)-99/40 *Sin(58/37-15 *t)-59/7 *Sin(25/16-11 *t)-2/35 *Sin(8/41-10 *t)-381/26 *Sin(25/16-9 *t)-67/21 *Sin(17/11-8 *t)-1706/37 *Sin(36/23-5 *t)-29/9 *Sin(29/19-4 *t)-851/29 *Sin(58/37-3 *t)+1991/30 *Sin(t+96/61)+528/17 *Sin(2 *t+85/54)+89/67 *Sin(6 *t+37/24)+102/13 *Sin(7 *t+80/17)+17/16 *Sin(12 *t+91/58)+35/12 *Sin(13 *t+37/23)+127/27 *Sin(14 *t+27/17)-26576/29) *theta(67 *Pi-t) *theta(t-63 *Pi)+(-29/14 *Sin(47/33-16 *t)-35/22 *Sin(75/52-15 *t)-236/63 *Sin(16/11-14 *t)-41/6 *Sin(34/23-13 *t)-236/29 *Sin(46/31-12 *t)-167/28 *Sin(55/37-11 *t)-259/33 *Sin(76/51-10 *t)-414/73 *Sin(56/37-9 *t)-121/28 *Sin(17/11-7 *t)-177/32 *Sin(61/41-6 *t)-1499/41 *Sin(48/31-5 *t)-647/23 *Sin(25/16-3 *t)+610/13 *Sin(t+30/19)+1474/31 *Sin(2 *t+30/19)+807/41 *Sin(4 *t+41/26)+208/31 *Sin(8 *t+43/27)-16147/17) *theta(63 *Pi-t) *theta(t-59 *Pi)+(-12/41 *Sin(1/4-28 *t)-11/43 *Sin(9/14-26 *t)-17/41 *Sin(14/13-24 *t)-22/31 *Sin(17/67-22 *t)-7/10 *Sin(64/63-19 *t)-69/41 *Sin(39/31-14 *t)-86/25 *Sin(22/41-12 *t)-87/52 *Sin(31/27-9 *t)-23/15 *Sin(13/33-7 *t)-25/17 *Sin(22/25-3 *t)+159/28 *Sin(t+249/248)+571/20 *Sin(2 *t+23/26)+109/36 *Sin(4 *t+29/18)+161/58 *Sin(5 *t+31/23)+147/26 *Sin(6 *t+31/19)+199/35 *Sin(8 *t+37/42)+96/19 *Sin(10 *t+17/47)+64/27 *Sin(11 *t+337/75)+15/7 *Sin(13 *t+157/44)+Sin(15 *t+101/33)+5/38 *Sin(16 *t+1/28)+11/56 *Sin(17 *t+23/37)+6/11 *Sin(18 *t+8/9)+91/136 *Sin(20 *t+3/19)+55/54 *Sin(21 *t+102/25)+15/16 *Sin(23 *t+118/31)+22/27 *Sin(25 *t+49/15)+3/8 *Sin(27 *t+27/8)+22/43 *Sin(29 *t+57/16)+10/19 *Sin(30 *t+50/83)+5/31 *Sin(31 *t+121/38)+2727/23) *theta(59 *Pi-t) *theta(t-55 *Pi)+(-41/31 *Sin(23/21-4 *t)-85/14 *Sin(17/32-t)+407/35 *Sin(2 *t+75/22)+21/10 *Sin(3 *t+41/14)+53/54 *Sin(5 *t+54/25)+31/61 *Sin(6 *t+124/27)+5/36 *Sin(7 *t+3/19)+19/31 *Sin(8 *t+144/31)+10393/23) *theta(55 *Pi-t) *theta(t-51 *Pi)+(-36/41 *Sin(5/18-6 *t)+83/35 *_
Sin(t+95/28)+43/37 *Sin(2 *t+66/17)+165/13 *Sin(3 *t+27/53)+79/19 *Sin(4 *t+9/17)+37/24 *Sin(5 *t+190/63)+57/58 *Sin(7 *t+267/100)+13545/31) *theta(51 *Pi-t) *theta(t-47 *Pi)+(-123/47 *_
Sin(19/15-18 *t)-59/29 *Sin(1/49-16 *t)-213/37 *Sin(29/22-13 *t)-381/40 *Sin(4/29-11 *t)-168/29 *Sin(6/11-10 *t)-1233/44 *Sin(3/19-3 *t)-711/7 *Sin(1/39-2 *t)-5171/26 *Sin(12/19-t)+2965/57 *Sin(4 *t+89/28)+347/21 *Sin(5 *t+23/93)+1087/69 *Sin(6 *t+4/31)+760/37 *Sin(7 *t+172/53)+333/19 *Sin(8 *t+7/13)+325/81 *Sin(9 *t+96/55)+53/17 *Sin(12 *t+138/49)+73/40 *Sin(14 *t+92/67)+47/31 *Sin(15 *t+81/19)+7/11 *Sin(17 *t+29/30)-3017/19) *theta(47 *Pi-t) *theta(t-43 *Pi)+(-713/27 *Sin(22/17-t)-36840/41) *theta(43 *Pi-t) *theta(t-39 *Pi)+(-675/23 *Sin(13/16-t)-17750/19) *theta(39 *Pi-t) *theta(t-35 *Pi)+(-39/29 *Sin(11/16-17 *t)-102/37 *Sin(8/49-11 *t)-95/34 *Sin(4/13-9 *t)-71/22 *Sin(7/12-8 *t)-194/17 *Sin(29/23-7 *t)-2531/25 *Sin(13/36-t)+601/19 *Sin(2 *t+264/61)+232/5 *Sin(3 *t+53/13)+309/40 *Sin(4 *t+29/10)+266/39 *Sin(5 *t+3/16)+71/95 *Sin(6 *t+50/37)+281/44 *Sin(10 *t+33/43)+29/15 *Sin(12 *t+105/29)+39/25 *Sin(13 *t+109/36)+24/11 *Sin(14 *t+51/38)+19/9 *Sin(15 *t+38/23)+43/29 *Sin(16 *t+4)+53/74 *Sin(18 *t+74/25)-45956/91) *theta(35 *Pi-t) *theta(t-31 *Pi)+(-25/32 *Sin(4/13-15 *t)-40/43 *Sin(11/19-13 *t)-12727/115 *Sin(83/84-t)+1762/31 *Sin(2 *t+66/29)+905/78 *Sin(3 *t+46/25)+209/25 *Sin(4 *t+104/37)+103/27 *Sin(5 *t+32/17)+121/60 *Sin(6 *t+143/37)+29/7 *Sin(7 *t+45/13)+41/36 *Sin(8 *t+271/58)+125/62 *Sin(9 *t+152/33)+118/79 *Sin(10 *t+56/25)+41/24 *Sin(11 *t+108/25)+22/45 *Sin(12 *t+116/41)+43/35 *Sin(14 *t+68/19)+1/15 *Sin(16 *t+26/11)+13/43 *Sin(17 *t+53/25)-29541/41) *theta(31 *Pi-t) *theta(t-27 *Pi)+(-235/21 *Sin(5/46-5 *t)-133/13 *Sin(3/29-4 *t)-437/37 *Sin(50/37-3 *t)-2785/19 *Sin(5/4-t)+724/17 *Sin(2 *t+68/29)+211/141 *Sin(6 *t+83/44)+41/14 *Sin(7 *t+135/32)+83/20 *Sin(8 *t+135/38)+123/62 *Sin(9 *t+136/33)+304/203 *Sin(10 *t+166/47)+59/44 *Sin(11 *t+5/29)+25/36 *Sin(12 *t+102/49)+13/12 *Sin(13 *t+101/41)+23/13 *Sin(14 *t+73/26)+5/32 *Sin(15 *t+85/27)+41/61 *Sin(16 *t+56/25)+1/7 *Sin(17 *t+10/17)+7/18 *Sin(18 *t+134/51)-8059/11) *theta(27 *Pi-t) *theta(t-23 *Pi)+(-32/23 *Sin(20/27-18 *t)-31/20 *Sin(19/17-17 *t)-89/38 *Sin(30/23-13 *t)-529/122 *Sin(22/15-10 *t)-151/35 *Sin(2/27-8 *t)-417/28 *_
Sin(43/29-4 *t)-851/35 *Sin(3/14-3 *t)-13229/88 *Sin(31/52-t)+425/12 *Sin(2 *t+37/18)+397/30 *Sin(5 *t+37/17)+299/31 *Sin(6 *t+122/41)+301/38 *Sin(7 *t+58/35)+240/43 *Sin(9 *t+118/27)+39/28 *Sin(11 *t+27/34)+82/165 *Sin(12 *t+58/27)+29/26 *Sin(14 *t+77/27)+47/19 *Sin(15 *t+7/4)+46/17 *Sin(16 *t+79/22)+46/35 *Sin(19 *t+43/21)+23/28 *Sin(20 *t+105/31)+27/23 *Sin(21 *t+184/41)-12036/55) *theta(23 *Pi-t) *theta(t-19 *Pi)+(-16/37 *Sin(42/43-19 *t)-21/23 *Sin(37/26-18 *t)-23/17 *Sin(25/56-17 *t)-46/61 *Sin(34/45-16 *t)-161/22 *Sin(1/2-6 *t)-472/43 *Sin(15/23-5 *t)-620/29 *Sin(43/60-3 *t)+2821/25 *Sin(t+167/39)+2605/88 *Sin(2 *t+89/30)+449/43 *Sin(4 *t+66/25)+37/24 *Sin(7 *t+37/33)+107/13 *Sin(8 *t+175/52)+341/128 *Sin(9 *t+188/41)+32/15 *Sin(10 *t+12/19)+208/43 *Sin(11 *t+44/73)+122/53 *Sin(12 *t+41/39)+69/40 *Sin(13 *t+9/32)+34/23 *Sin(14 *t+208/45)+19/11 *Sin(15 *t+11/36)+17/19 *Sin(20 *t+111/26)+4/15 *Sin(21 *t+26/25)-10055/37) *theta(19 *Pi-t) *theta(t-15 *Pi)+(-59/44 *Sin(173/172-36 *t)-73/31 *Sin(21/53-30 *t)-23/11 *Sin(13/12-29 *t)-133/50 *Sin(23/19-28 *t)-125/29 *Sin(108/77-24 *t)-122/33 *Sin(1/19-21 *t)-238/79 *Sin(4/7-16 *t)-141/16 *Sin(34/37-9 *t)-45/8 *Sin(16/27-7 *t)+11594/23 *Sin(t+1768/589)+1582/37 *Sin(2 *t+28/25)+771/38 *Sin(3 *t+107/31)+863/22 *Sin(4 *t+87/22)+485/29 *Sin(5 *t+63/25)+27/8 *Sin(6 *t+75/76)+106/19 *Sin(8 *t+20/23)+54/17 *Sin(10 *t+10/49)+206/61 *Sin(11 *t+106/29)+65/14 *Sin(12 *t+81/29)+80/11 *Sin(13 *t+49/43)+41/29 *Sin(14 *t+1/114)+17/38 *Sin(15 *t+97/43)+97/20 *Sin(17 *t+98/23)+77/30 *Sin(18 *t+49/19)+44/13 *Sin(19 *t+53/16)+44/19 *Sin(20 *t+95/23)+135/29 *Sin(22 *t+27/25)+243/121 *Sin(23 *t+23/17)+15/4 *Sin(25 *t+10/17)+50/13 *Sin(26 *t+75/32)+308/47 *Sin(27 *t+253/76)+65/19 *Sin(31 *t+7/15)+92/33 *Sin(32 *t+26/11)+17/15 *Sin(33 *t+74/23)+8/15 *Sin(34 *t+64/27)+17/27 *Sin(35 *t+215/72)+16757/30) *theta(15 *Pi-t) *theta(t-11 *Pi)+(1805/16 *Sin(t+1/303)+19936/43) *theta(11 *Pi-t) *theta(t-7 *Pi)+(374/65 *Sin(t+149/47)+11537/27) *theta(7 *Pi-t) *theta(t-3 *Pi)+(-15391/135 *Sin(35/71-t)+112/53 *Sin(2 *t+66/29)+13507/30) *theta(3 *Pi-t) *theta(t+Pi)) *theta(Sqr(Sgn(Sin(t/2))))
oVertexA(N).x = x*0.04
oVertexA(N).y = y*0.04
oColorA(N).r = 255 : oColorA(N).g = 0 : oColorA(N).b = 0
t = t + 0.01
N = N + 1
end while
terminate
"
' -- Pass the source
O2_Asmo src
' -- Check for errors
If Len(o2_error) Then
MsgBox 0, o2_error : Stop
End If
' -- Execute
o2_exec
End Function
It is also possible to define functions in oxygen, and call them from ThinBASIC, see thinBasic\SampleScripts\Oxygen\Examples\General\O2Functions.tBasic example.
Oxygen compiler is so fast, that you don't need to even create DLLs! (But you can, if you want)
Petr
Thanks Petr for the key post about using oxygen, i was worrying about how to connect the variables or if it is reciprocal or not (still to see this) it is much more easier than using outside dlls, i have interested in Dim oVertexA(30156) At #VertexA As TBGL_TVECTOR3F so this is the way we link the two variables, it seems Dim oVertexA(0)...Dim oColorA(0).. works also, seems it is expanding as necessary depending on the subsequent code .
i forget to ask regarding the calling freebasic dll, in the thinbasic code declaration there is:
Declare Sub TestUDT Lib "dll_udt_VertexArrays.dll" Alias "TestUDT@8" (ByRef lpUDT As Long, ByRef lpColorUDT As Long) '@4 is 4 bytes for UDT address so we need here 4*2=8
i am still confused about the TestUDT@8 : the addition of @8 even it is explained in the http://rapidq.phatcode.net/tutorial/Freebasic_DLL_tutorial.html search page with "mangled name" . is it the same thing we must use if the dll made by powerbasic ??
thanks Petr again for your precious code about oxygen usage.
Petr Schreiber
28-11-2015, 01:51
Hi Primo,
I am happy it helped :)
The DLLs made by PowerBASIC do not need the @ notation at all.
Petr
ErosOlmi
28-11-2015, 11:42
Thanks a lot Petr for Oxygen example.
Sometimes I forget this precious weapon we have in thinBasic arsenal able to burst execution of some part of slow scripts and reach execution speed of compiled applications.
Oxygen Just In Time Compiler module is a generous present of Charles Pegge.
Full info can be found in Charles web site at: http://www.oxygenbasic.org/ and his forum: http://www.oxygenbasic.org/forum/
Have fun