Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: NeHe Lesson18

  1. #1

    NeHe Lesson18

    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.
    Attached Images Attached Images
    Attached Files Attached Files
    Operating System: Windows 10 Home 64-bit
    CPU: Intel Celeron N4000 CPU @ 1.10GHz
    Memory: 4.00GB RAM
    Graphics: Intel UHD Graphics 600

  2. #2

    Re: NeHe Lesson18

    Thanks Matthew, but.... where is lesson 17 ?

  3. #3

    Re: NeHe Lesson18

    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

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: NeHe Lesson18

    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

  5. #5
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: NeHe Lesson18

    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

  6. #6
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: NeHe Lesson18

    Quote Originally Posted by Psch
    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
    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.

    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

  7. #7

    Re: NeHe Lesson18

    @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

  8. #8
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: NeHe Lesson18

    To make it run at a viewable rate I've tried changing the timing can someone try it.

    thanks


    Attached Files Attached Files
    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

  9. #9
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: NeHe Lesson18

    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
    Attached Files Attached Files
    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

  10. #10

    Re: NeHe Lesson18

    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?

Page 1 of 3 123 LastLast

Similar Threads

  1. NeHe lessons
    By Michael Clease in forum TBGL General
    Replies: 1
    Last Post: 26-06-2008, 13:24
  2. NeHe Lesson 01
    By matthew in forum TBGL Tutorials
    Replies: 1
    Last Post: 16-03-2007, 06:38
  3. More NeHe Lessons...
    By matthew in forum TBGL Tutorials
    Replies: 5
    Last Post: 15-03-2007, 22:57

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •