PDA

View Full Version : TBGL FAQ ( Frequently Asked Questions )



Petr Schreiber
01-07-2007, 17:17
TBGL FAQ
Updated 19th of January, 2008

This is list of solutions for quite common problems, I have splitted it to following categories to make search easier:

Frame rate and performance related
Texture related
Model related
Garbage collection

If you think there is something missing please tell me :)


Frame rate and performance related
Q: How to measure performance of my app ?
A: You can use built in statement to check framerate. To do this, just fill variable ( name it for example "FrameRate" ) from function once per frame:



' ...

DIM FrameRate AS NUMBER
while TBGL_IsWindow( hWnd)

FrameRate = tbgl_GetFrameRate ' <-

tbgl_ClearFrame

' -- Some rendering code here
' ...

tbgl_DrawFrame

' ...

wend



Q: All my scripts run at 60FPS ( 75FPS ) and I cannot get higher even with very basic scenes
A: Check your drivers and turn V-Sync ( vertical synchronisation ) to OFF.


Q: All my scripts run at unbelieveable low speed, what can I do ?
A: Please check this post (http://community.thinbasic.com/index.php?topic=668.msg3885#msg3885), you have probably wrong drivers


Q: As I get different FPS on different PCs, scene movements are faster/slower depending on computer
A: It is good practise to keep all movements scaled to actual performance.

Create variable "FrameRate"
At beginning of frame add following line



FrameRate = tbgl_GetFrameRate



Scale all calculations relative to FrameRate, for example to move ship by 5 m/s just add:



Ship.X += 5/FrameRate



Q: There are many ways to create geometry in TBGL, which one to use to get maximum performance
A:

"immediate mode" - ( TBGL_BeginPoly / TBGL_EndPoly ) is best to get the idea, but also slowest one
"display lists" - for static geometry it is wise to cache using display lists ( see TBGL_NewList, TBGL_EndList, TBGL_CallList in help file )
"model buffers, display lists" - for best performance for dynamic meshes ( game charcters, monsters, water surfaces ) model buffers are the right solution right now. They are continuously optimized in each release of TBGL.
For static geometry you can use model buffer too and than cache it using display lists. tbgl_m15DrawModel produces highly optimized GPU code, and it will even improve in future.



Texture related
Q: My texture looks weird!
A: You probably try to use texture which is not power of two (POT) sided. To ensure maximum compatibility and performance use just POT textures.
They can be both square sided ( 64x64, 128x128, 256x256, ... ) or rectangular ( 64x32, 512x64, ... )


Q: I loaded TGA texture but polygon is still not textured right
A: Make sure TGA is 32bit one - 24bits for RGB and 8bits for alpha



Model related
Q: I want to render points via model buffers
A: Create model as usual, but set PSTOP flag only to last vertex.
Make sure to call following function to make model look like points before rendering it:


tbgl_PolygonLook %GL_POINT




Garbage collection
Q: Do I have to delete somehow display lists and textures from memory before my application ends ?
A: No, it is done automatically.



Hope this list can help to solve classic problems,
Petr Schreiber

kryton9
01-07-2007, 22:11
Very nice Petr, a great idea to do this. I hope you add these to the next tbgl help.

Something else that would be very useful and you already sort of did it is skeleton setups.

1. Simplest, minimal code skeleton

2. Simplest skeleton where user sets, light, camera, blending

3. Like #2 but where the light, camera and blending could be modified with each drawframe

and then versions of the above using the gl commands from the headers or mixed with tbgl and gl commands.

One more thing to add to the QandA page, is what needs to be deleted by the user in tbgl. We used to have to delete display lists, but I know you wrote it is automatic now.

Thanks again for this.

Petr Schreiber
02-07-2007, 08:14
Hi,

thanks, I will prepare it and update ASAP :)


Bye,
Petr

ErosOlmi
07-05-2013, 10:36
Q. Where can I find the source to the TBGL extension DLL?
TBGL is not open source. It is Free.


Q. What language is TBGL it written in?
PowerBasic PB10x.

Petr Schreiber
07-05-2013, 15:35
Thanks Eros - yes, I can confirm these are the correct answers.


Petr