Dear visitors,
I would like to recommend you to download latest release of thinBASIC, version 1.6.0.9.
Besides improvements in TBGL ( like tweaks and new commands ) it also brings some important features every script can use.
3D programs usually operate with complex structures, which can be represented as variables of user defined type ( UDT ) in thinBASIC. Mentioned new release allows easier work with such a structures. Let me demonstrate you little before/after example :smile:
Lets consider following UDT and array of variables of this type:
TYPE TParticle
x AS DOUBLE
y AS DOUBLE
z AS DOUBLE
duration AS LONG
END TYPE
LOCAL Particle(10) AS TParticle
To assign to such a variables and reference this members you could use:
Before
Particle(1).x = 1
Particle(1).y = 2
Particle(1).z = 3
Particle(1).duration = 1000 - Particle(1).y
With latest release
WITH Particle(1)
.x = 1
.y = 2
.z = 3
.duration = 1000 - .y
END WITH
As you can see, even the simple assignment can be done now with less typing. You can reference members using easier way, which can enhance the speed you write and edit your code. Still, if you prefer the "old" way, you can use it too.
Second very important addition is new DOEVENT command, which allows to significantly decrease CPU usage of your programs.
If you design your main program loop as following:
WHILE TBGL_IsWindow(hWnd)
-- Code here --
WEND
... it is highly probable, that especially on single core CPUs you can make CPU occupied over 90%. This is good for benchmarks or application which run alone or need uncompromising speed.
But MS Windows is multitasked environment, so in most cases it is polite to let other processes use some of the CPU power. By simple change of main loop to:
WHILE TBGL_IsWindow(hWnd)
DOEVENTS
-- Code here --
WEND
... the CPU usage drops down to fair use of just 0 to 10% CPU resources. If you are afraid this modification will necessarily make your programs run slow, let me assure that on most computer you will be still able to reach framerates over 150 FPS, which is 2x more than most LCD monitors manage to display.
Hope you liked this little introduction to new ways you can enhance your simulation, game or simply visualization programs which use TBGL module.
For more details about new thinBASIC and TBGL module improvements please have a look inside help files, bundled with each thinBASIC installation.
Best regards,
Petr Schreiber