Thanks Petr!
With the new TBGL module, you will be able to run this script with one of Stan Blank's algorithmic patterns.
I could not resist it, but please do not gaze upon the gyrating image for too long
Charles
Hi guys,
I talked here about new way of defining geometry in TBGL, so here is the preview version for you to comment and test. If no problems observed, it will be included in next thinBASIC.
GBuffers are simple, internally based on Vertex Arrays(dynamic ones) and Vertex Buffer Objects (static ones).
Here is the new DLL(please copy to thinBasic/Lib) and examples, which should give you idea "how it works".
Full documentation will come in next TB release.
I think this new approach could be of interest for example to Stan, as it allows rendering big numbers of points (but not only) in fast way, with predictable memory consumption.
Petr
Attachement removed, feature present in latest thinBASIC
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Thanks Petr!
With the new TBGL module, you will be able to run this script with one of Stan Blank's algorithmic patterns.
I could not resist it, but please do not gaze upon the gyrating image for too long
Charles
thanks Petr and Charles
Petr is this version of TBGL which you have refered to here http://community.thinbasic.com/index...24461#msg24461
ie: rendering in way the lines would be visible during computation.
and how to achieve this feat !.
regards
Hi Zak,
yes, it is!
I will hold back regarding examples using GBuffers till the ThinBASIC with them is out, to avoid confusion, but here is the version of the Stans example, at full detail:
[code=thinbasic]
' Example: Section 7.7 (page 222-224), Explorations with the Mandlebrot Set
' From Stan Blank's Book:
' "Python Programming in OpenGL
' "A Graphical Approach to Programming
' Converted by Stan Blank, this version is slightly downgraded in detail by Petr Schreiber
' Using the Predator-Prey framework by Michael Clease
' Last modified: February 28, 2010
' thinBasic does not use GLUT, we use instead tbgl
Uses "TBGL"
' insert Eros Olmi's new iComplex module
Uses "iComplex"
Function TBMain()
' Handle for our window
Local hWnd As DWord
Local Width As Long
Local Height As Long
Local n As Long
Local x,y, zz As Double
' Declare iComplex variables
Local z, c As tComplex
'# Initial values of width And height
width = 400
height = 400
'
' Create and show window
hWnd = TBGL_CreateWindowEx("Mandelbrot Set", Width, Height, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX Or %TBGL_WS_DONTSIZE)
TBGL_ShowWindow
' -- Set background from default black to white
TBGL_BackColor(0,0,0)
' -- Init OpenGl, like gluOrtho2D in example code
TBGL_RenderMatrix2D( -2, -1.5, 1, 1.5 )
TBGL_PointSize 1
' Resets status of all keys
TBGL_ResetKeyState()
Local percent As Double
' -- Create new GBuffer
Local gbMandelbrot As DWord = TBGL_GBufferCreate(%TBGL_POINTS, %TBGL_2D)
Local MandelbrotIndex As Long
Local MandelbrotVertex(160000) As tbgl_tVector2f ' -- TYPE from TBGL
Local MandelbrotColor (160000) As tbgl_tRGB ' -- TYPE from TBGL
' -- Fill it with data
For x = -2 To 1 Step 0.0075
For y = -1.5 To 1.5 Step 0.0075
Incr MandelbrotIndex
' Set complex points
c = iComplex_Set(x,y)
z = iComplex_Set(x,y)
n = 0
For n = 1 To 50
' Equation is z = z*z + c
z = iComplex_Mul(z,z)
z = iComplex_Add(z,c)
' Distance from origin to complex point
zz = iComplex_Abs(z)
' if distance is > 2.0, then point is NOT in the M-Set
' so plot it... the M-Set will be black
If zz > 2.0 Then
MandelbrotColor (MandelbrotIndex).R = 255
MandelbrotVertex(MandelbrotIndex).x = x
MandelbrotVertex(MandelbrotIndex).y = y
End If
Next
Next
' -- Write status
percent = (x-(-2))/3*100
TBGL_SetWindowTitle(hWnd, Format$(percent, "#.00")+"%, rendering full detail")
DoEvents
' -- Dynamically say to TBGL where the data are, this is just pointer gymnastics, no copy
TBGL_GBufferDefineFromArray(gbMandelbrot, %TBGL_DYNAMIC, MandelbrotIndex, MandelbrotVertex(1), MandelbrotColor(1))
' -- Redraw
TBGL_ClearFrame
TBGL_GBufferRender(gbMandelbrot)
TBGL_DrawFrame
' -- Escape sooner?
If TBGL_GetWindowKeyOnce(hWnd, %VK_ESCAPE) Then Exit For
Next
TBGL_SetWindowTitle(hWnd, "Behold - the Mandlebrot! ")
' Main loop
While TBGL_IsWindow(hWnd)
TBGL_ClearFrame
TBGL_GBufferRender(gbMandelbrot)
TBGL_DrawFrame
If TBGL_GetWindowKeyOnce(hWnd, %VK_ESCAPE) Then Exit While
Wend
TBGL_DestroyWindow
End Function
[/code]
You can see the GBuffer set as "dynamic" only look ups ThinBASIC variables, without making any expensive memory copy.
This way, once the data are linked together and their amount does not change, you can only change values in the arrays, and changes will be immediately visible after new render.
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
thanks Petr, i have the following notes:
the process of plotting keeps going on until it finished, after that i can move other windows or the tbgl scene; without deleting the finished scene,
but if during the plotting i put the cursor on the program icon on the taskbar 3 seconds as in the image below the scene will converted to white and the counter stop ,and it will not respond to ESC key, this is may be because it will recalculate again, but any way at the end the scene will rendered correctly. the problem to solve may be to continuasly storing the partialy finished scene so if we move anything the partialy scene will be refreshed again easily.
Thanks for bringing this up Zak,
I did not noticed this during the tests.
Solution?
DoEvents
I just updated the example above, let me know if it helped.
Thanks!,
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
magnificent, it is perfect, and i was thinking that it is recalculating from start i will read the GBuffer docs once the official release. this year 2010 is a big step for thinbasic, TBGL, and Oxygen.
regards
Oh wow... is this the '60's again?
I feel like I'm watching the closing sequence of 2001 when Bowman goes through the stargate...
Words fail me... just a darn good job Petr and Charles! Now when am I going to find time to learn all this new stuff? Every day brings something new and that's exciting.
Great work... and I know what I'm going to be doing this evening...
Cheers,
Stan
Originally Posted by Charles Pegge
Thanks Petr and Charles for the examples. I am running and viewing these on my notebook with an ati 9600 mobility radeon video card. I was able to run and see all of Petr's examples. Charles, I just see a black square on a white background. No textures. Does it take a while to render the texture should I let it sit longer than the 30 seconds or so that I wait?
Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server
Hi Kent,
mea culpa, it was wrong in original example.
I just tested on Radeon X1650 and same effect.
Just change:
[code=thinbasic]
TBGL_BackColor 255,255,255,0
[/code]
to
[code=thinbasic]
TBGL_BackColor 255,255,255,255
[/code]
It confused blending.
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Bookmarks