Results 1 to 5 of 5

Thread: TBGL - 3 things

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

    TBGL - 3 things

    (maybe I should have 3 separate posts?)

    These are minor things -- maybe just my misunderstanding.

    1) Placing the window in the screen Using TBGL_CreateWindowEx doesn't seem to work.
    Using the MoveWindow API does work.

    2) When using TBGL_RenderMatrix2D,
    TBGL_Line uses the coordinates in the TBGL_RenderMatrix2D statement.
    TBGL_PrintFont doesn't. Does it use screen coordinates?

    3) Are parentheses ever necessary or prohibited? Recommended or not?
    e.g. TBGL_UseLighting(%TRUE) or TBGL_UseLighting %TRUE

    The script below is commented, showing the issues
    Thanks for TB/TBGL!
      Uses "TBGL"
    
    Sub TBMain()                          
      Dim hWnd, hFont As DWord, Framerate As Long
      String s1 = "ESC to quit"                    
      '-- I want the window to be upper-left in the screen - doesn't work.
      hWnd = TBGL_CreateWindowEx(s1, 600, 600, 32, 
        %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX, 0, 0)
      hFont = TBGL_FontHandle("Courier New", 9)
      TBGL_BuildFont(hFont) 
      TBGL_SetLightParameter(%GL_LIGHT0, %TBGL_LIGHT_POSITION, 100, 100, 0, 1)
      TBGL_SetLightParameter(%GL_LIGHT0, %TBGL_LIGHT_DIFFUSE, 1, .5, .5, 1)
      TBGL_UseLightSource(%GL_LIGHT0, %TRUE)
      TBGL_UseVSync(1)
      TBGL_ShowWindow
      While TBGL_IsWindow(hWnd)                  
        Framerate = TBGL_GetFrameRate
        TBGL_ClearFrame      
        '-- A Viewport
        TBGL_Viewport( 40, 30, 400, 200, %TBGL_PARAM_PIXELS )
        '-- I want to print stuff in 2D mode 
        '-- in the bottom-left corner of the viewport.
        TBGL_RenderMatrix2D(0, 0, 400, 200) ' viewport coordinates
        TBGL_UseLighting(%FALSE) ' for printing             
        TBGL_Line(10,10,390,190) ' the 2D line gets inside the viewport (good)
        TBGL_PrintFont("Framerate=" & Framerate, 0, 0) ' but the print is outside
        TBGL_PrintFont2D("X=100 Y=0", 100, 0)
        '-- Printing in 3D mode works as expected.
        TBGL_RenderMatrix3D(%TBGL_CUSTOM, 400/200)
        TBGL_Camera(0, 0, 5, 0, 0, 0)              
        TBGL_UseLighting(%TRUE)         
        TBGL_Rect(-100, -100, -1, 100, 100, -1) ' the whole viewport
        TBGL_Sphere(1)         
        TBGL_UseLighting(%FALSE) ' for printing
        TBGL_PrintFont("X=0 Y=0 Z=2", 0, 0, 2) ' print in 3D - 
        TBGL_DrawFrame                                             
        If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While
      Wend
      TBGL_DestroyWindow
    End Sub
    

  2. #2
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,529
    Rep Power
    170
    hi dcromley,

    for the upper-left-thing- i discovered same issue when passing a 0, 0
    you should use 1,1 as a position, else (< 1) it's centered.

    To move window you could use TBGL_SetWindowed()-function...

    For RenderMatrix2d use TBGL_PrintFont2D to stay on the safe side.

    The RenderMatrix2d- awaits parameters in another order then usually:

    TBGL_RenderMatrix2D(Left, Bottom, Right, Top)


    Parenthesis can be omitted if the function does not have optional parameters in most cases... try out...
    Last edited by ReneMiner; 17-02-2016 at 21:37.
    I think there are missing some Forum-sections as beta-testing and support

  3. #3
    Member dcromley's Avatar
    Join Date
    Apr 2009
    Location
    Wyoming, USA
    Age
    86
    Posts
    80
    Rep Power
    23
    Rene,
    Thank you for the response.
    I see that 0,0 centers and 1,1 does indeed put it to the upper-left.

    > To move window you could use TBGL_SetWindowed()-function...
    I did not get this to work. I thought it would be
      String s1 = "ESC to quit"                    
      hWnd = TBGL_CreateWindowEx(s1, 600, 600, 32, %TBGL_WS_CLOSEBOX)
      TBGL_SetWindowed( hWnd, 600, 600, 32, %TBGL_WS_CLOSEBOX, 1, 1)
    
    But, as I said, the MoveWindow API does the deed.

    > For RenderMatrix2d use TBGL_PrintFont2D to stay on the safe side.
    I have the 2 statements, and neither get into the viewport:
        TBGL_PrintFont("Framerate=" & Framerate, 0, 0)
        TBGL_PrintFont2D("X=100 Y=0", 100, 0)
    
    But it's not that hard to add the viewport offsets to the x and y.

    > Parenthesis can be omitted if the function does not have optional parameters in most cases... try out...
    I'm going with using ()s. If there's a problem, I'll be back.

    Thanks again, Dave

  4. #4
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,529
    Rep Power
    170
    hi Dave,

    please check line 23 of your script again.

    Parameters for TBGL_RenderMatrix2d are to pass counter-clockwise starting left:

    TBGL_RenderMatrix2D( leftX, bottomY, rightX, topY )

    but
    not left, top, {width|right}, {height|bottom}


    have fun, keep on coding
    René
    Last edited by ReneMiner; 19-02-2016 at 11:23.
    I think there are missing some Forum-sections as beta-testing and support

  5. #5
    Member dcromley's Avatar
    Join Date
    Apr 2009
    Location
    Wyoming, USA
    Age
    86
    Posts
    80
    Rep Power
    23
    Yes, I see that since the viewport width/height is 400/200 I should have had
    TBGL_RenderMatrix2D(0, 0, 399, 199)
    
    but the TBGL_LINE still uses the viewport coordinates and the PrintFont and PrintFont2D still use screen coordinates, not viewport coordinates? I wanted 0,0 to be bottom-left.

    Changing to
    TBGL_RenderMatrix2D(0, 199, 399, 0)
    
    makes 0,0 the upper-left for the TBGL_LINE, but I still have to add the viewport offsets for the TBGL_PrintFont and TBGL_PrintFont2D to get into the viewport.

    Sorry if I'm being dense here. Thanks again.

Similar Threads

  1. Natural things -- TBGL -- geometry
    By RobbeK in forum TBGL General
    Replies: 3
    Last Post: 10-02-2015, 16:28
  2. Tim Berners-Lee: Developers Are Doing “Incredible Things”
    By Charles Pegge in forum Shout Box Area
    Replies: 0
    Last Post: 06-02-2013, 16:42
  3. Things could be a lot worse.
    By danbaron in forum Shout Box Area
    Replies: 0
    Last Post: 21-10-2010, 08:08
  4. to keep things organized
    By kryton9 in forum TBGL nmg_tankwars
    Replies: 0
    Last Post: 31-05-2008, 00:56

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
  •