Results 1 to 5 of 5

Thread: TBGL- multiple displays

  1. #1
    thinBasic MVPs ReneMiner's Avatar
    Join Date
    Oct 2012
    Location
    Germany
    Age
    51
    Posts
    1,432
    Blog Entries
    1
    Rep Power
    158

    TBGL- multiple displays

    More than one TBGL-display quite easy to achieve - but needs UI-Canvas.

    Example shows how two different "scenes" can be displayed in two different canvas-controls at same time.
    Not using scene/entity-system here but is doable rendering different scenes to different output also.
    Even works in seperate dialogs.
    If displaying same scene from different points of view then camera-entity has to be placed according to the current view.

    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
    Last edited by ReneMiner; 06-09-2013 at 10:26.
    running thinBasic in HP Pavillon Desktop 590 a0xxx 8GB Ram AMD A6-9225 Radeon R4 5Compute Cores 2C+3G @2.6GHz

    OS: Windows 11 Enterprise x64 Build 22065 (21H2 pre-release)
    (says the systeminfo. anything else says it were Windows 10 - more or less insider - a lot of the system settings do not function - i could imagine it will not send feedback to microsoft since it always says i need a new app to open that feedback-hub-link. But hey: thinbasic runs well )

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,089
    Blog Entries
    5
    Rep Power
    725
    I will check during the weekend whether I can work around this limitation.


    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,089
    Blog Entries
    5
    Rep Power
    725
    Hmm,

    I don't see any problem changing LOC and SIZE property, could you please post failing example?


    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

  4. #4
    thinBasic MVPs ReneMiner's Avatar
    Join Date
    Oct 2012
    Location
    Germany
    Age
    51
    Posts
    1,432
    Blog Entries
    1
    Rep Power
    158
    I threw it all out and have not saved the "old" version.

    Maybe I did it wrong? The effect was the canvases did not correctly resize (used CONTROL SET RESIZE) and without that switch I did not try out. Maybe this switch interfered also when I used CONTROL SET LOC.

    That's also the reason why I tried to create multiple TBGL-displays at all: As long as Dialogs & Controls are not Objects with clearly defined Events, Methods and Properties they are way too cumbersome to handle and not applicable for a bigger project so I need to create own "Control-Objects"
    I already was that frustrated about UI-handling that I erased all I've written - and more than once - lots of hours thinking and typing just flushed down to neverland.
    Especially annoying that I can not use Dialogs nor Control-Properties directly, but always have to send them "TO" some local variable in advance with half a dozen parameters just to get some simple value out there and need always a few lines just for one simple action because the result is not returned directly.
    Also these make code so unreadable - I have some idea, start to write and get stuck when it comes to UI - always have to look up and down again - my code then is such chaos that I can not read myself what I wrote and loose overview of situation and used calls so it becomes impossible to continue and I have to stop and start all over.
    Last edited by ReneMiner; 05-09-2013 at 18:43.
    running thinBasic in HP Pavillon Desktop 590 a0xxx 8GB Ram AMD A6-9225 Radeon R4 5Compute Cores 2C+3G @2.6GHz

    OS: Windows 11 Enterprise x64 Build 22065 (21H2 pre-release)
    (says the systeminfo. anything else says it were Windows 10 - more or less insider - a lot of the system settings do not function - i could imagine it will not send feedback to microsoft since it always says i need a new app to open that feedback-hub-link. But hey: thinbasic runs well )

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,089
    Blog Entries
    5
    Rep Power
    725
    Hi Rene,

    I think CONTROL SET RESIZE could clash a bit with CONTROL SET LOC/SIZE - it is one or another.
    I agree the "TO syntax" is a bit impractical sometimes -that is why Eros added Control_GetHandle, Control_GetWidth, Control_GetHeight, Control_GetText and others... which behave like normal functions.


    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

Similar Threads

  1. TBGL+ multiple Dialogs?
    By ReneMiner in forum TBGL General
    Replies: 8
    Last Post: 07-02-2013, 21:16
  2. Does Multiple USES Cause Problems
    By peralta_mike in forum Core module
    Replies: 3
    Last Post: 04-05-2011, 16:46
  3. Execute multiple thinBundle
    By ErosOlmi in forum thinBundle bugs report
    Replies: 1
    Last Post: 21-02-2007, 13:43
  4. Multiple Conditions in IF/THEN Statements
    By catventure in forum thinBasic General
    Replies: 4
    Last Post: 14-11-2005, 22:59

Posting Permissions

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