PDA

View Full Version : NeHe Lesson09



matthew
16-03-2007, 20:36
NeHe Lesson09 will Draw 50 Stars on the Screen and Rotate them.

Keyboard Controls...

'T' - Toggle Twinkle

Cursor Key Up - Decrease Tilt
Cursor Key Down - Increase Tilt

'PgUp' - Zoom Out
'PgDn' - Zoom In

Update...
This is the New Download which is much faster than the Original. ;)

Update...
This is the New Version which includes a Keyboard Handling Routine to detect if a Key has been Released or not.

Petr Schreiber
16-03-2007, 22:13
Hi Mathew,

this was always my favourite lesson :)

It seems glColor4ub is a bottleneck on my PC, what about TBGL_ColorAlpha instead of it ? ;)
Maybe there is something wrong with my box, but using the glColor4ub I will get 12 FPS, with TBGL_COLORALPHA 80 FPS... That's quite noticable difference :)

When I use display lists I can get to 103 FPS.

Mathew, in my head grows evil idea :) - when you will finish your work on NeHe conversion, what about making "extreme edition" of each lesson ( well, #1 hard to beat :D ). It would show how to get maximmum possible performance while getting the same result via TBGL commands.

What do you think ?


Bye,
Petr

matthew
16-03-2007, 22:17
Hey, good idea I thought it was a bit slow. :P

It never occurred to me that I could have used 'TBGL_ColorAlpha' instead of 'glColor4ub'. :D

Michael Hartlef
16-03-2007, 22:19
Cool Matthew, thank you!

ErosOlmi
16-03-2007, 22:22
Matthew,

fantastic example but for some reason it is very slow.
I suppose the bottleneck is calling glColor4ub using a declare external statement compare with native module functions.
I need to have a look at calling dll functions. I should get more speed on this process.

In the meanwhile, I attach a demo from my library of thinBasic examples that maybe can give some idea on how to avoid using external dll functions calling.
Imagine who is the author? :D

Eros

ErosOlmi
16-03-2007, 22:24
Using TBGL_ColorAlpha is 10 times faster.
I need to have a look at dll calling :-[

matthew
16-03-2007, 22:26
Mathew, in my head grows evil idea :) - when you will finish your work on NeHe conversion, what about making "extreme edition" of each lesson ( well, #1 hard to beat :D ). It would show how to get maximmum possible performance while getting the same result via TBGL commands.

What do you think ?


Anything that makes them go faster is fine with me. :)

@MikeHart - Thank's, Mike. ;)

@ErosOlmi - I think I know who the Author is. :D

Update...
I've just tried changing the colour Command to TBGL_COLORALPHA. :o

It runs just as fast as the Original C++ version. 8)

The new version has been uploaded.

That Particle Tornado Demo looked really good. :)

Petr Schreiber
16-03-2007, 23:11
Hi,

thanks for updating it :)
Tornado ? 90 lines of code... could be optimized too :D


Bye and thanks,
Petr

kryton9
17-03-2007, 00:05
Geat come home and another cool lesson is finished and a neat demo from Petr too.

Thanks guys!

ErosOlmi
17-03-2007, 00:30
Did I say I had to check some code on dll functions calling?
So, I did it and found a weird bug on internal hashing storing. I was adding into an hash table the open DLL handle over and over and over ...

I amended thinCore and now Lesson09 using 'glColor4ub' originally executing at 35 FPS on my machine is executing at 240 FPS !!!!
So almost 8 times faster. This will speed up all script using external dll functions.
This fix will be present in next release.

Try to execute original Lesson09 using 'glColor4ub' and see the difference.

So thanks to all.
Eros

ADDED: thinCore.dll removed from this post because included into thinBasic preview version 1.3.0.1

matthew
17-03-2007, 01:12
Yeah, I just Downloaded and tried it, it's really Fast. :o

Petr Schreiber
17-03-2007, 11:43
Hi,

If I would not now Eros for so long time ago,
I would be surprised ;)

Perfect Eros !

Bye,
Petr

kryton9
17-03-2007, 21:03
It is a neat demo and very fast. It looks so cool and then you tilt and go WOW, that is neat and then you zoom in and you know it is a great demo then!!