Uses "UI", "TBGL"
' -- ID numbers of controls
Begin ControlID
%lCanvas1
%lCanvas2
%bClose
%myTimer
End ControlID
Begin Const
%MAIN_WIDTH = 640
%MAIN_HEIGHT = 480
%timeOut = 20 ' -- Determines graphics refresh rate in milliseconds
End Const
Function TBMain()
Local hDlg As DWord
Dialog New Pixels, 0, "Dialog with TBGL",-1,-1, %MAIN_WIDTH, %MAIN_HEIGHT, _
%WS_POPUP Or %WS_VISIBLE Or _
%WS_CLIPCHILDREN Or %WS_CAPTION Or _
%WS_SYSMENU Or %WS_MINIMIZEBOX Or %WS_MAXIMIZEBOX, 0 To hDlg
' -- Place controls:
Control Add Label, hDlg, %lCanvas1, "", 5, 5, %MAIN_WIDTH/2-10, %MAIN_HEIGHT-40
Control Set Color hDlg, %lCanvas1, %BLACK, %BLACK
Control Add Label, hDlg, %lCanvas2, "", %Main_Width/2+5, 5, %MAIN_WIDTH/2-10, %MAIN_HEIGHT-40
Control Set Color hDlg, %lCanvas2, %BLACK, %BLACK
Control Add Button, hDlg, %bClose, "Close", 5, %MAIN_HEIGHT-30, %MAIN_WIDTH - 10, 25
Dialog Show Modal hDlg, Call dlgCallback
End Function
CallBack Function dlgCallback()
Static hCtrl As DWord
Select Case CBMSG
Case %WM_INITDIALOG
' just init timer
Dialog Set Timer CBHNDL, %myTimer, %timeOut, %NULL
Case %WM_TIMER
Control Handle CBHNDL, %lCanvas1 To hCtrl
RenderMyImage(hCtrl, %lCanvas1)
Control Handle CBHNDL, %lCanvas2 To hCtrl
RenderMyImage(hCtrl, %lCanvas2)
Case %WM_CLOSE
Control Handle CBHNDL, %lCanvas1 To hCtrl
If TBGL_CanvasBound(hCtrl) Then TBGL_ReleaseCanvas(hCtrl)
Control Handle CBHNDL, %lCanvas2 To hCtrl
If TBGL_CanvasBound(hCtrl) Then TBGL_ReleaseCanvas(hCtrl)
Dialog Kill Timer CBHNDL, %myTimer
Case %WM_COMMAND
Select Case CBCTL
Case %bClose
If CBCTLMSG = %BN_CLICKED Then Dialog End CBHNDL
End Select
End Select
End Function
Sub RenderMyImage( ByVal hCtrl As DWord, ByVal ID_Canvas As Long )
TBGL_BindCanvas(hCtrl) ' no need to update canvas-proprtions...
If TBGL_CanvasBound(hCtrl) Then
TBGL_UseLighting(%TRUE)
TBGL_UseLightSource(%GL_LIGHT0, %TRUE)
TBGL_SetLightParameter(%GL_LIGHT0, %TBGL_LIGHT_POSITION, 15, 10, 15, 1)
TBGL_ClearFrame
TBGL_Camera(5, 5, 5, 0, 0, 0)
If ID_Canvas = %lCanvas1 Then
' show "scene 1"
TBGL_Box(1, 1, 1)
Else
' show "scene 2"
TBGL_Sphere(1)
EndIf
TBGL_DrawFrame
EndIf
End Sub
Edit: limitation removed
Bookmarks