Results 1 to 4 of 4

Thread: Trouble with TBGL_MouseGetLButton ?

  1. #1
    Member dcromley's Avatar
    Join Date
    Apr 2009
    Location
    Wyoming, USA
    Age
    86
    Posts
    80
    Rep Power
    24

    Trouble with TBGL_MouseGetLButton ?

    Hello again,

    When I run this script and hit the left mouse button every second or so, it hangs up after 5 or so seconds. "Not responding". The "close" box turns red; I'm at 1.9.16.16, Windows 10. Thanks in advance, Dave

        Uses "TBGL"
    
      Global hWnd, hFont As DWord
      Global s1 As String      
      
      s1 = "ESC to exit"
      hWnd = TBGL_CreateWindowEx( _
        s1, 1024, 742, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX) 
      TBGL_UseVSync 1
      hFont = TBGL_FontHandle("Courier New", 12) 
      TBGL_BuildFont hFont
      TBGL_ShowWindow 
      TBGL_UseLighting %FALSE
      TBGL_UseLightSource %GL_LIGHT0, %TRUE
      TBGL_ResetKeyState() 
      Do While TBGL_IsWindow(hwnd)
        If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Stop
        TBGL_ClearFrame
        TBGL_Camera 1,1,5, 0,0,0            
        TBGL_Color 255,255,255                        
        TBGL_UseLighting %FALSE
        TBGL_PrintFont TBGL_MouseGetLButton, -1,1,0
        TBGL_DrawFrame
      Loop
    

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,146
    Rep Power
    735
    Hello, dear mister bug hunter!

    This sure looks like an issue. I think it is related to the DO WHILE ... LOOP, because when you refactor the code to this equivalent, the problem is gone:
     Uses "TBGL"
     
    Global hWnd, hFont As DWord
    Global s1 As String     
     
    s1 = "ESC to exit"
    hWnd = TBGL_CreateWindowEx( _
      s1, 1024, 742, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX) 
      
    TBGL_UseVSync 1
    
    hFont = TBGL_FontHandle("Courier New", 12) 
    TBGL_BuildFont hFont
    TBGL_ShowWindow
    
    TBGL_UseLighting %FALSE
    TBGL_UseLightSource %GL_LIGHT0, %TRUE
    
    TBGL_ResetKeyState() 
    
    While TBGL_IsWindow(hwnd)
      If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Stop
      TBGL_ClearFrame
      TBGL_Camera 1,1,5, 0,0,0            
      TBGL_Color 255,255,255                        
      TBGL_UseLighting %FALSE
      TBGL_PrintFont TBGL_MouseGetLButton, -1,1,0
      TBGL_DrawFrame
    Wend
    

    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
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,814
    Rep Power
    10
    Ciao

    I think the problem is related to the fact that main loop does not give any time to process events.

    There are two ways to solve:
    1. Add a DoEvents inside the loop
      Do While TBGL_IsWindow(hwnd)
        ...
       DoEvents
      Loop
      
    2. Use WHILE/WEND instead of DO/LOOP. WHILE/WEND has an automatic DoEvents inside it:
      While TBGL_IsWindow(hwnd)
      ...
      Wend
      


    I think the best is to use WHILE/WEND in all situations where a unknown loop (a loop where is not known how many cycles will be executed) is needed.
    I will add into manual some indications about this behave.


    PS: Petr, we posted quite the same time.
    Last edited by ErosOlmi; 22-03-2016 at 08:22.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  4. #4
    Member dcromley's Avatar
    Join Date
    Apr 2009
    Location
    Wyoming, USA
    Age
    86
    Posts
    80
    Rep Power
    24
    Thanks again. You guys are Johnny-on-the-spot.

Similar Threads

  1. Trouble in (my) Paradise
    By LCSims in forum Core module
    Replies: 24
    Last Post: 04-07-2013, 21:58
  2. Big trouble with FILE module
    By Petr Schreiber in forum thinBundle bugs report
    Replies: 3
    Last Post: 19-03-2007, 20:34

Members who have read this thread: 0

There are no members to list at the moment.

Tags for this Thread

Posting Permissions

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