Uses "Console", "UI", "TBGL", "Math"
Global hwnd, hfont As Long, iOpt As Long
Global gCount As Long
iOpt = InputBox$(0, "1 for 200ms, 2 for 2000ms, 3 for MsgBox")
hwnd = TBGL_CreateWindowEx("Esc to Exit", 1024, 768, 32, _
%TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX)
TBGL_ShowWindow
TBGL_ResetKeyState()
hfont = TBGL_FontHandle("Courier New", 12)
TBGL_BuildFont(hfont) ' for print
TBGL_PeriodicBindFunction(hwnd, "TBGLLoop", 1000)
TBGL_ProcessPeriodicFunction(hwnd)
TBGL_DestroyWindow
Sub TBGLLoop()
If TBGL_GetWindowKeyOnce(hwnd, %VK_ESCAPE) Then
TBGL_PeriodicUnBindFunction(hwnd)
Exit Function
End If
TBGL_ClearFrame
TBGL_Camera(0,0,4, 0,0,0)
Incr gCount
If gCount = 5 Then
TBGL_PeriodicChangeInterval( hWnd, 60000) ' 1 minute
TBGL_PrintFont "Interval changed to 60sec. Hit CLOSE to end", 0,0,0
End If
Select Case iOpt
Case 1
DrawStuff1(gCount) ' normal, 200ms
Case 2
DrawStuff2(gCount) ' slow, 2000ms
Case 3
DrawStuff3(gCount) ' MsgBox
Case Else
TBGL_PeriodicUnBindFunction(hwnd)
Exit Function
End Select
TBGL_DrawFrame
End Sub
Sub DrawStuff1(num As Long) ' normal 200ms processing
Local hCWin As Long
DrawLine()
TBGL_PrintFont("Sleeping for 200ms; # " & num, 0,.2,0)
hCWin = Canvas_Window("Window", 100,100, 200,50)
Canvas_Attach(hCWin, 0)
Sleep 200
Canvas_Window End
End Sub
Sub DrawStuff2(num As Long) ' routine takes 2000ms
Local hCWin As Long
DrawLine()
TBGL_PrintFont("Sleeping for 2000ms; # " & num, 0,.2,0)
hCWin = Canvas_Window("Window", 100,100, 200,50)
Canvas_Attach(hCWin, 0)
Sleep 2000
Canvas_Window End
End Sub
Sub DrawStuff3(num As Long) ' routine issues MsgBox
Local hCWin As Long
DrawLine()
TBGL_PrintFont("Issuing MsgBox # " & num, 0,.2,0)
hCWin = Canvas_Window("Window", 100,100, 200,50)
Canvas_Attach(hCWin, 0)
MsgBox(0, "This is msgbox # " & num)
Canvas_Window End
End Sub
Sub DrawLine()
Local x, y, cosa, sina, ang As Single
ang = Frac(Timer/60)*2*Pi ' like a clock?
cosa = Cos(ang): sina = Sin(ang)
x = cosa - sina
y = sina + cosa
TBGL_Line(0,0,0, x,y,0)
End Sub
Bookmarks