Re: FBGFX module for thinBasic, to handle 2D graphics
Hi,
thanks Eros. That might be better to do some of those functions straight to the module.
I still made it go faster (smaller loop):
[code=thinbasic]'Plasma-like effect with FBGFX
uses "FBGFX"
Dim w,h As Double
w=200
h=150
FBGFX_ScreenRes(w,h,32,2)
Dim x,y,page As Double
Dim c,t As Double
while FBGFX_InKey() <> "q" 'Program runs until "q" is pressed
t=t+1
For x = 0 To w step 3
For y = 0 To h step 3
c= (Sin((x+y+t)/100)+Cos((x-t)/100)+Cos((y-t)/100)+Cos((x-y+t)/100))*2+Sin(t/100)*15
FBGFX_Color(Rgb(Sin(c)*64+128,Cos(c)*64+128,Cos(-c/2)*64+128), 0)
FBGFX_Circle(x,y,3)
Next
Next
'pageflip
page=-page+1
FBGFX_Sync(1)
FBGFX_ScreenSet(page,-page+1)
wend[/code]
Also you guys can suggest some functions that I'll put to the module.
Thanks everyone,
misthema.
Re: FBGFX module for thinBasic, to handle 2D graphics
eh :D
smaller loops are a trick. But I'm sure that with module functions you will get some real boost.
The key point to decide to have a module function is if that function can be enough general to be used also in other scripts.
If yes, than go with module function. You will have a better module and faster scripts.
Ciao
Eros
Re: FBGFX module for thinBasic, to handle 2D graphics
change from double to single you dont need the precision should make it faster.
If you want some ideas just google 2d librarys and see what they do and recreate them.
Re: FBGFX module for thinBasic, to handle 2D graphics
Hi,
I created new thread for assembler optimization of plasma code, to not break high-level structure of samples in this thread.
I did first optimization of one expression, just 1.3-1.5 faster - not bad sign for thinBASIC parsing engine :).
But it gives me 3FPS instead of 2, which is thing many would die for ... or at least someone ... hey ... anyone ? :D
Petr
1 Attachment(s)
Re: FBGFX module for thinBasic, to handle 2D graphics
And here my version with an external DLL written in Power Basic implementing the two functions I mentioned.
I get a speed incremented by 3/4 times the original speed.
Ciao
Eros
Re: FBGFX module for thinBasic, to handle 2D graphics
Cool demo Petr and Eros. The one in Eros's post is significantly faster than the copy and paste one from Petr's. In both however, I can't close the window in any standard way and have to use the TaskManager to kill the running app.
Other than that, those kind of nice smooth color changes always impress me!
Re: FBGFX module for thinBasic, to handle 2D graphics
Kent,
you have to press "q" key to close the window.
You can get it from the main WHILE/WEND loop.
Ciao
Eros
Re: FBGFX module for thinBasic, to handle 2D graphics
Quote:
Originally Posted by kryton9
In both however, I can't close the window in any standard way and have to use the TaskManager to kill the running app.
I have to use the "q" key, becouse I haven't figured out how can I use ESCAPE in FBGFX_InKey function. Maybe I'll make it work with scancodes and make equates for them.
Bye,
misthema.
Re: FBGFX module for thinBasic, to handle 2D graphics
Thank for this module. Is there a way to make it work with thinBasic windows?
Re: FBGFX module for thinBasic, to handle 2D graphics
Michael,
I don't think so, becouse FBGFX creates its own window and viewport where it draws everything.
Or did I miss what you ment?
Bye,
misthema.