Thanks Matthew, but.... where is lesson 17 ?
NeHe Lesson18 will allow you to toggle between many different Shapes, toggle the lighting and Texture Quality and show you how to use Glu in your Programmes.
Keyboard Controls...
l - Toggle Lighting
f - Toggle Filter (Quality of Texture)
SpaceBar - Toggle Between Shapes
Shapes - Cube, Cylinder, Disk, Sphere, Cone and Partial Disk.
Cursor Key Up - Tilt Up
Cursor Key Down - Tilt Down
Cursor Key Left - Rotate Left
Cursor Key Right - Rotate Right
PgUp - Zoom Out
PgDn - Zoom In
Update
This is the New Version which includes the Keyboard Handling Routine that Petr mentions later in the thread. Now the programme can detect if any of the Keys have been released.
New Update
This version was updated on 29th June 2007 and the Code should be much clearer.
Operating System: Windows 10 Home 64-bit
CPU: Intel Celeron N4000 CPU @ 1.10GHz
Memory: 4.00GB RAM
Graphics: Intel UHD Graphics 600
Thanks Matthew, but.... where is lesson 17 ?
I'm doing all the simple lessons first.
The Lessons which involve messing about with Text or Reading Data from Files I'm going to do last.
Operating System: Windows 10 Home 64-bit
CPU: Intel Celeron N4000 CPU @ 1.10GHz
Memory: 4.00GB RAM
Graphics: Intel UHD Graphics 600
Very nice lesson again!,
it runs too fast on my PC
I modified spacebar to be less sensitive using:
[code=thinbasic]
' Put before WHILE
dim SpaceBarReleased as long = 1
' Put in keychecking code
if tbgl_getasynckeystate(%vk_space) = 0 then SpaceBarReleased = 1
if tbgl_getasynckeystate(%vk_space) and SpaceBarReleased = 1 then
SpaceBarReleased = 0
Object +=1
end if
[/code]
Maybe better would be something like TBGL_GetAsyncKeyOnce or something like that to do the dirty job for you, I will include it in next release if everything will go ok.
Thanks again,
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 Mathew another awesome lesson. Using GLU as you did adds to the beauty of this lesson and understanding more of how openGL works. Thanks again, Very nice!!
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
Yep it would be very useful to have such a command Petr, not only in tbgl but regular thinBasic too. This way you can check for it once or use the standard control the way it is now.Originally Posted by Psch
As a quick remedy this is what I use, for the example I used the up arrow. All on one line and no extra variables to keep track of.
[code=thinbasic]
if tbgl_GetAsyncKeyState(%VK_up) then Xspeed -= 1: sleep 100: end if
[/code]
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
@kryton9 - Thank's...
@Psch - I've updated the Download so it now detects if the SpaceBar or L and F Keys have been released. TBGL_GetAsyncKeyOnce would be a useful Command to have.
Operating System: Windows 10 Home 64-bit
CPU: Intel Celeron N4000 CPU @ 1.10GHz
Memory: 4.00GB RAM
Graphics: Intel UHD Graphics 600
To make it run at a viewable rate I've tried changing the timing can someone try it.
thanks
Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370
Hi Abraxas,
thanks for update!
I tweaked even your improved version :P
Your code for calculating framerate:
[code=thinbasic]
framecounter = framecounter +1
ctime = gettickcount
dtime = ctime - stime
if dtime >= 1000 then
FrameRate = framecounter
framecounter = 0
stime = ctime
endif
[/code]
... can be replaced with single line:
[code=thinbasic]
FrameRate = tbgl_GetFrameRate
[/code]
Problem could occur with your framerate dependant code:
[code=thinbasic]
if tbgl_GetAsyncKeyState(%VK_left) then Yspeed -= FrameRate/1000000
[/code]
With higher framerate we need to make smaller steps, but your code does opposite.
It is enough to divide by framerate:
[code=thinbasic]
if tbgl_getWindowkeystate(hWnd, %VK_left) then Yspeed -= 1/FrameRate
[/code]
Attached version makes use of tbgl_GetWindowKeyOnce, which is new in TBGL 0.2.0.0.
So instead of:
[code=thinbasic]
if tbgl_getasynckeystate(%vk_space) = 0 then SpaceBarReleased = 1
if tbgl_getasynckeystate(%vk_space) and SpaceBarReleased = 1 then
SpaceBarReleased = 0
Object +=1
end if
[/code]
... can now be used again just one liner:
[code=thinbasic]
if tbgl_getwindowkeyOnce(hWnd, %vk_space) then Object +=1
[/code]
I am sorry to do "correction" of you code like an annoying school teacher :-[, but I think it can give better performance and save you some gray hair in future.
Bye,
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
Petr, when you want to display the FPS, I use the same method to calculate it like Abraxas does. This way you see the numbers and not just a mess.
Btw, how does TBGL_GetFrameRate work internally?
Bookmarks