Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Space bar echoes ?

  1. #1

    Space bar echoes ?

    Hi Petr, (or any one else who knows)

    Because of the complex view and a clearer look in 2D, I tried to make a switch via the space-bar.
    Seems only a very short touch works (the keystate is reset in the loop - program a delay ?? ).
    (program uses the arrow keys for rotations, and PgUp/Dn for changing the parameters)

    Thanks in advance

    Rob
    Attached Files Attached Files
    Last edited by RobbeK; 09-10-2013 at 16:22.

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

    I have two tips for you:
    • move tbgl_resetKeyState before while loop
    • use TBGL_GetWindowKeyOnce instead of TBGL_GetWindowKeyState



    Let me know,
    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

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    And one more tip - I noticed you add to the variables like:
    If TBGL_GetWindowKeyState(hWnd, %VK_LEFT) Then rx=rx-3
    
    Coding this way in while cycle will result in different speed on different PCs.
    The basic way around this is to think - how much I want the value to change over 1 second?

    Let's say we want the rotation to be 360 degress per second. All you need to do is to scale the addition relatively to current framerate:
    If TBGL_GetWindowKeyState(hWnd, %VK_LEFT) Then rx=rx-360/FrameRate
    
    ' -- Alternative
    
    If TBGL_GetWindowKeyState(hWnd, %VK_LEFT) Then rx -= 360/FrameRate
    
    This will make your graph rotate at the same speed on PCs with different performance.


    Petr

    P.S. The script producess really impressive visualization, very nice!
    Last edited by Petr Schreiber; 09-10-2013 at 20:38.
    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

  4. #4
    Thanks Petr,

    TBGL...once works ! (with ..reset.. outside the loop).
    Framerate : thanks, I will remember .. but on my old 'puter I take all the speed I can get (at least for these kind of programs).
    There's something else , this programs uses the same method both for 2D and 3D - only the z=0 for 2D. The matrix contains exactly the same number of coordinates, yet rotations seem to go faster in the pseudo-2D - seems some filtering is done (at pixel level) - is that a TBGL or an (open)GL mechanism ??
    It doesn't matter much here, it's a dynamic model any way - but for static objects (without "inbetween" calculations), I intended to write some algorithms filtering duplicate data - but if TB/Open GL already does so, there's no need.
    These quadratic mappings are rather tricky , a certain point (x,y) may have several z values ... and even worse , points can start generating closed curves and repeating themselves - (at pixel level)

    Thanks again, Rob

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

    that is interesting observation you have, it makes me suspicious regarding your OpenGL drivers.
    Could you please check this thread:
    TBGL Troubleshooting

    and download & run the OpenGL_GetInfo.tBasic from there, and post the results please?


    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

  6. #6
    Hi Petr,

    Software emulation :-( .. started when installing Win7, also used the recovery partition for a Linux distribution.
    (it's an old recycled computer, on the one I have for the job, everything runs much smoother ).

    best
    Rob

  7. #7
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Okay - that means you use Microsoft OpenGL implementation, all computed on CPU.
    Try to find out the name of your graphic card/accelerator - you will see that after installing the proper driver, which I will help you to find, the speed will boost up significantly, even if you have Intel GPU.


    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

  8. #8
    Dobri Den ! (IIRC - been a while since been in CZ republic - for a while I have been working for a Russian chemical Cy)
    Thanks again ( I think I'm some Urquell's in debt now ;-)

    I used a nice little program to investigate the architecture of the computer (I attached it , it can be at use for you when digging into computers).
    Went to the Intel site, but no drivers above XP available.
    After some googling, found other people with a similar problem - and it seems someone made a hack for Win7.
    Works perfectly (though, I had to change some settings before Win7 wanted to run it).
    All sunshine now .. Your program outputs .. OpenGL correct installed ;-)

    No slow-downs ani more, everything runs at a constant speed (though 64 Mb is nothing compared against what is exhibited here -- never mind, forces me into smart programming ;-)

    (btw : do not know you have a mathematical background -- but in case of the twin primes , after some thinking about them, I found their sum is always (except the first one) a multiple of 12 (or 12) - this knowledge speeds up calculations 6x. The proof is very easy, but one has to look for such things ... )

    thanks again Rob
    Attached Files Attached Files
    Last edited by RobbeK; 12-10-2013 at 12:33.

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

    thank you for good news, I am happy OpenGL now runs as designed! 64 MB is actually lot of memory, I remember beautiful game called Giants: Citizen Kabuto used just 16MB, if I am not mistaken, and yet it looked amazing.

    I didn't knew the feature of primes you mention, interesting indeed. When I need prime numbers in range, I usually go the dirty way - going in the range and testing with IsPrime, but that is the approach of the lazy one


    Petr
    Last edited by Petr Schreiber; 13-10-2013 at 00:41.
    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
    Hi Petr,

    The speed-up comes from the fact that when the sum of two twin primes is a multiple of 12, the "parent" (the number between them) is a multiple of 6, and you only have to test these.
    n + (n+2) = k.12
    2(n + 1) = k.12
    n+1 = k.6

    The difference in speed can be tested with the attached program.
    The speed of TB is good, after all one pixel-width represents 1000 numbers.

    best Rob
    Attached Files Attached Files

Page 1 of 2 12 LastLast

Similar Threads

  1. Space-Plates
    By Charles Pegge in forum Shout Box Area
    Replies: 10
    Last Post: 28-02-2012, 12:21
  2. create TBGL_Line in 3d space
    By largo_winch in forum TBGL module by Petr Schreiber
    Replies: 7
    Last Post: 16-08-2011, 16:41
  3. Space environment creator by kryton9
    By kryton9 in forum User tools
    Replies: 36
    Last Post: 08-02-2010, 07:04
  4. Space background images
    By ErosOlmi in forum Resources
    Replies: 4
    Last Post: 25-02-2007, 00:20
  5. Execution of script with space inside name
    By ErosOlmi in forum thinAir General
    Replies: 1
    Last Post: 26-10-2005, 13:17

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
  •