TBGL_SpriteExists crashes
issueid=374 25-11-2012 16:39
thinBasic MVPs
Number of reported issues by ReneMiner: 92
TBGL_SpriteExists crashes

I tried this way to receive a free ID for a sprite. Instantly crashes.

Function Get_FreeSpriteID () As Long
  Local i As Long  
  
  Do
 
    Incr i 
    If TBGL_SpriteExists(i) = FALSE Then Return i
     
  Loop

End Function
Issue Details
Issue Number 374
Project TBGL
Category Unknown
Status Fixed
Priority Unknown
Affected Version Unknown
Fixed Version (none)
Users able to reproduce bug 0
Users unable to reproduce bug 1
Assigned Users (none)
Tags (none)




25-11-2012 21:51
Super Moderator
Hi Rene,

I think I will need more complex example from your side, just tried this and it works okay:
Uses "TBGL" 

Function TBMain()
  Local hWnd      As DWord
  
  ' -- Create and show window
  hWnd = TBGL_CreateWindowEx("TBGL script - press ESC to quit", 640, 480, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX) 
  TBGL_ShowWindow 
                     
  Long newSprite = Get_FreeSpriteID()                     
  
  TBGL_DestroyWindow
End Function 

Function Get_FreeSpriteID () As Long
  Local i As Long 
   
  Do
  
    Incr i
    If TBGL_SpriteExists(i) = FALSE Then Return i
      
  Loop
 
End Function
Petr

25-11-2012 23:39
thinBasic MVPs
What you wrote doesn't even show the window- I thought... I added a little bit,
if I start this by pressing F5 it instantly stops again. I see TBGL_Window for half a second, thats it...
' Empty GUI script created on 11-25-2012 22:28:04 by  (ThinAIR)
Uses "TBGL"
 
Function TBMain()
  Local hWnd      As DWord
  Local newSprite As Long
  
 
  
  ' -- Create and show window
  hWnd = TBGL_CreateWindowEx("TBGL script - press ESC to quit", 640, 480, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX)
  TBGL_ShowWindow
  
  TBGL_ResetKeyState() 
  
  
  While TRUE
  ' if comment following line out, program keeps running
    newSprite = Get_FreeSpriteID()                    
    
   ' If TBGL_SpriteExists(123) Then 
     ' just tested this, does not crash when this if-clause stays uncommented
   ' EndIf
   
    If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While
                 
  Wend   
  
  TBGL_DestroyWindow


End Function
 
Function Get_FreeSpriteID () As Long
  Local i As Long
    
  Do
   
    Incr i
    If TBGL_SpriteExists(i) = FALSE Then Return i
       
  Loop
  
End Function
Tried also using DWord instead of Long for Function, i and newSprite - crash also...

26-11-2012 00:34
thinBasic MVPs
Rene you don't need to see the window just start the debugger and set the break point on the command on the Get_FreeSpriteID () call then press F8 to step the program.

I have tested the above scripts and don't see any problem it works fine for me no crashing.

26-11-2012 13:03
thinBasic MVPs
then it might be a WinXP issue. I had those mysterious crashing problems already when I was very new to tB and tried my first 2D-program. Now I'm doing 3d with a little bit Sprite-UI, works fine so far, now I'm expanding it- make my Sprite-UI to an include-file so it can be multiple-used and that needs some flexibility in enumerating, but now I'm there where I was at the beginning :( Guess I got to make another Enumerating-Function

30-06-2017 21:57
Super Moderator
There was a bug! OMG, fixed after 5 years, but fixed.
ThinBASIC 1.10 contains the updated TBGL.


Petr

+ Reply