Results 1 to 9 of 9

Thread: FrameRate comparisons

  1. #1

    FrameRate comparisons

    i want to compare the FrameRate in example Uses only "TBGL" with
    hWnd = TBGL_CreateWindowEx
    and another same example but Uses "UI", "TBGL" with the graphics displayed on a Label, and have a button
    the first example i got from official GBuffers_SimpleTriangle.tbasic
    the second i adapted it from an example in the forum https://www.thinbasic.com/community/...ghlight=lorenz

    it happened the first example result is about 60 fps _excellent
    the second example result is about 30 fps even it is only a one triangle.
    unless otherwise it seems a general phenomena in the windowed demos which have controls to have less FrameRates.
    '
    ' Simple example of rendering colorful triangle with GBuffers
    ' Petr Schreiber, 2010
    '
    
    Uses "TBGL"
    
    Function TBMAIN()
      Local hWnd      As DWord
      Local FrameRate As Double
      
      ' -- Create and show window
      hWnd = TBGL_CreateWindowEx("GBuffers with triangles - press ESC to quit", 640, 480, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX) 
      TBGL_ShowWindow   
      
      TBGL_BackColor 255,255,255
    
      ' -- Create 3D triangle buffer
      Dim gbTriangle As DWord = TBGL_GBufferCreate(%TBGL_Triangles, %TBGL_3D)
      
      ' -- Define data for it
      Dim VertexA(3) As TBGL_tVector3F
      Dim ColorA(3)  As TBGL_tRGB   
      
      ' -- Vertices
      VertexA(1).x = -1
      VertexA(1).y = -1
      VertexA(1).z = 0
      
      VertexA(2).x = 1
      VertexA(2).y = -1     
      VertexA(2).z = 0  
      
      VertexA(3).x = 0
      VertexA(3).y = 1
      VertexA(3).z = 0  
      
      ' -- Colors
      ColorA(1).r = 255
      ColorA(1).g = 0
      ColorA(1).b = 0
      
      ColorA(2).r = 0
      ColorA(2).g = 255
      ColorA(2).b = 0  
      
      ColorA(3).r = 0
      ColorA(3).g = 0
      ColorA(3).b = 255
      
      ' -- Create buffer dynamically linked to the arrays above
      TBGL_GBufferDefineFromArray(gbTriangle, %TBGL_Dynamic, 3, VertexA(1), ColorA(1))
      
      ' -- Resets status of all keys 
      TBGL_ResetKeyState()
    
      ' -- Main loop
      While TBGL_IsWindow(hWnd) 
        FrameRate = TBGL_GetFrameRate
        TBGL_SetWindowTitle(hWnd, FrameRate)
        TBGL_ClearFrame 
          TBGL_Camera(0, 0, 5, 0, 0, 0)
          
          ' -- Turn triangle
          TBGL_Rotate GetTickCount/30, 0, 1, 0
                                  
          ' -- Render it                              
          tbgl_GBufferRender(gbTriangle)   
             
          ' -- Modify the colors
          'ColorA(1).r = 128+Sin(GetTickCount/100)*127
          'ColorA(2).g = 128+Sin(GetTickCount/100+1)*127
          'ColorA(3).b = 128+Sin(GetTickCount/100+2)*127      
        TBGL_DrawFrame 
    
        ' -- ESCAPE key to exit application
        If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While 
    
      Wend         
      ' -- Destroying the buffer is not necessary,
      ' -- the garbage collector will take care of it
    
      ' -- Destroy window
      TBGL_DestroyWindow
    End Function
    
    example 2: opengl rendered with a Label
    Uses "UI", "TBGL"
    #Include "%app_includepath%\thinbasic_gl.inc"
    #Include "%app_includepath%\thinbasic_glu.inc"
    
    TBGL_BackColor 255,255,255
    
      ' -- Create 3D triangle buffer
      Global gbTriangle As DWord = TBGL_GBufferCreate(%TBGL_TRIANGLES, %TBGL_3D)
      
      ' -- Define data for it
      Global VertexA(3) As TBGL_TVECTOR3F
      Global ColorA(3)  As TBGL_TRGB   
      
      ' -- Vertices
      VertexA(1).x = -1
      VertexA(1).y = -1
      VertexA(1).z = 0
      
      VertexA(2).x = 1
      VertexA(2).y = -1     
      VertexA(2).z = 0  
      
      VertexA(3).x = 0
      VertexA(3).y = 1
      VertexA(3).z = 0  
      
      ' -- Colors
      ColorA(1).r = 255
      ColorA(1).g = 0
      ColorA(1).b = 0
      
      ColorA(2).r = 0
      ColorA(2).g = 255
      ColorA(2).b = 0  
      
      ColorA(3).r = 0
      ColorA(3).g = 0
      ColorA(3).b = 255
      
      ' -- Create buffer dynamically linked to the arrays above
      TBGL_GBufferDefineFromArray(gbTriangle, %TBGL_DYNAMIC, 3, VertexA(1), ColorA(1))
    
    
    ' -- ID numbers of controls
    Begin ControlID
      %lCanvas 
      %bClose 
      
      %myTimer 
    End ControlID
    
    Begin Const
      %MAIN_WIDTH   = 640
      %MAIN_HEIGHT  = 480
    
      %timeOut      = 20   ' -- Determines graphics refresh rate in milliseconds
    End Const
    
    Function TBMain()
    
      Global hDlg As DWord 
      Global sheep As Long
    
      Dialog New Pixels, 0, "Use arrow keys - Pg U/D   - LORENZ PEARLS",-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 Or %WS_THICKFRAME, 0 To hDlg
        
        ' -- Place controls here
        Control Add Label, hDlg, %lCanvas, "", 5, 5, %MAIN_WIDTH-10, %MAIN_HEIGHT-40
          Control Set Color hDlg, %lCanvas, %BLACK, %BLACK
          Control Set Resize hDlg, %lCanvas, 1, 1, 1, 1    
    
         
        Control Add Button, hDlg, %bClose, "Close", %MAIN_WIDTH-105, %MAIN_HEIGHT-30, 100, 25
          Control Set Resize hDlg, %bClose, 0, 1, 0, 1    
       
        Dialog Set Minsize hDlg, 320, 230
       
        Dialog Show Modal hDlg, Call dlgCallback
        
    End Function   
     
    CallBack Function dlgCallback()
      Static hCtrl As DWord
      
      Select Case CBMSG
        
        Case %WM_INITDIALOG
          'Dialog Set Timer CBHNDL, %myTimer, %timeOut, %NULL
          'Control Handle CBHNDL, %lCanvas To hCtrl
          Dialog Set Timer CBHNDL, %myTimer, %timeOut, %NULL
          Control Handle CBHNDL, %lCanvas To hCtrl
          
          ' -- Init OpenGL
          TBGL_BindCanvas(hCtrl)     
               
        Case %WM_SIZE, %WM_SIZING
          'TBGL_UpdateCanvasProportions(hCtrl)
          'RenderMyImage(hCtrl)
    
        Case %WM_TIMER
        
          RenderMyImage(hCtrl)
    
        Case %WM_CLOSE 
          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
    
    Function RenderMyImage( hCtrl As DWord )
      Static FrameRate As Double
      TBGL_BackColor 255,255,255
      If TBGL_CanvasBound(hCtrl) Then
       TBGL_ClearFrame
         
       FrameRate = TBGL_GetFrameRate
        TBGL_SetWindowTitle(hDlg, FrameRate)
        TBGL_ClearFrame 
          TBGL_Camera(0, 0, 5, 0, 0, 0)
          
          ' -- Turn triangle
          TBGL_Rotate GetTickCount/30, 0, 1, 0
                                  
          ' -- Render it                              
          TBGL_GBufferRender(gbTriangle)   
            
        TBGL_DrawFrame 
    
        ' -- ESCAPE key to exit application
        'If TBGL_GetWindowKeyState(hDlg, %VK_ESCAPE) Then Exit While 
    
      TBGL_DrawFrame  
        
      End If 
      
    End Function
    

  2. #2
    Member DirectuX's Avatar
    Join Date
    Oct 2018
    Location
    France
    Posts
    417
    Rep Power
    55
    Quote Originally Posted by primo View Post
    i want to compare the FrameRate in example Uses only "TBGL" with
    hWnd = TBGL_CreateWindowEx
    and another same example but Uses "UI", "TBGL" with the graphics displayed on a Label, and have a button
    the first example i got from official GBuffers_SimpleTriangle.tbasic
    the second i adapted it from an example in the forum https://www.thinbasic.com/community/...ghlight=lorenz

    it happened the first example result is about 60 fps _excellent
    the second example result is about 30 fps even it is only a one triangle.
    unless otherwise it seems a general phenomena in the windowed demos which have controls to have less FrameRates.
    Hi Primo,

    1/ have you a demand ?
    2/ second sample has one TBGL_DrawFrame call to much at line #144 or #139 and one TBGL_ClearFrame call to much at line #126 or #130
    3/ in second sample, if your target is your screen refresh rate : try %timeOut = 0 at line #56
    4/ in second sample, for maximum fps, I'd put RenderMyImage(hCtrl) at line #119 instead of #104
    5/ for reference : first sample : 1000 ~ 5000 fps ; second sample : 64 ~66 fps with bursts at +1000 or drops at 32. Moving mouse makes fps steady at 64 ~66 (this is normal as CallBack Function dlgCallback() is called for mouse move)
    6/ For information only, last week, I already told Petr about TBGL_GetFrameRate giving non steady values (bursts).



    Or/And you can try with Dialog Show MODELESS

    Here I get 64 fps steady.



    '---Script created on 12-20-2019 14:23:57 by 
    Uses "UI", "TBGL"
    #Include "%app_includepath%\thinbasic_gl.inc"
    #Include "%app_includepath%\thinbasic_glu.inc"
     
    TBGL_BackColor 255,255,255
     
      ' -- Create 3D triangle buffer
      Global gbTriangle As DWord = TBGL_GBufferCreate(%TBGL_TRIANGLES, %TBGL_3D)
       
      ' -- Define data for it
      Global VertexA(3) As TBGL_TVECTOR3F
      Global ColorA(3)  As TBGL_TRGB   
       
      ' -- Vertices
      VertexA(1).x = -1
      VertexA(1).y = -1
      VertexA(1).z = 0
       
      VertexA(2).x = 1
      VertexA(2).y = -1     
      VertexA(2).z = 0  
       
      VertexA(3).x = 0
      VertexA(3).y = 1
      VertexA(3).z = 0  
       
      ' -- Colors
      ColorA(1).r = 255
      ColorA(1).g = 0
      ColorA(1).b = 0
       
      ColorA(2).r = 0
      ColorA(2).g = 255
      ColorA(2).b = 0  
       
      ColorA(3).r = 0
      ColorA(3).g = 0
      ColorA(3).b = 255
       
      ' -- Create buffer dynamically linked to the arrays above
      TBGL_GBufferDefineFromArray(gbTriangle, %TBGL_DYNAMIC, 3, VertexA(1), ColorA(1))
     
    ' -- ID numbers of controls
    Begin ControlID
      %lCanvas 
      %bClose 
       
      %myTimer 
    End ControlID
     
    Begin Const
      %MAIN_WIDTH   = 640
      %MAIN_HEIGHT  = 480
     
      %timeOut      = 0   ' -- Determines graphics refresh rate in milliseconds
    End Const
     
    Function TBMain()
     
      Global hDlg As DWord
      Global sheep As Long
      global hCtrl as DWord
      Global x, y as dword
     
      Dialog New Pixels, 0, "Use arrow keys - Pg U/D   - LORENZ PEARLS",-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 Or %WS_THICKFRAME, 0 To hDlg
         
        ' -- Place controls here
        Control Add Label, hDlg, %lCanvas, "", 5, 5, %MAIN_WIDTH-10, %MAIN_HEIGHT-40
          Control Set Color hDlg, %lCanvas, %BLACK, %BLACK
          Control Set Resize hDlg, %lCanvas, 1, 1, 1, 1    
     
          
        Control Add Button, hDlg, %bClose, "Close", %MAIN_WIDTH-105, %MAIN_HEIGHT-30, 100, 25
          Control Set Resize hDlg, %bClose, 0, 1, 0, 1    
        
        Dialog Set Minsize hDlg, 320, 230
        
        Dialog Show MODELESS hDlg, Call dlgCallback
         
        Do
    
        DIALOG DOEVENTS
    
        DIALOG Get SIZE hDlg To x, x
    
        RenderMyImage(hCtrl)
        
      Loop While x 
    
    End Function  
      
    CallBack Function dlgCallback()
       
      Select Case CBMSG
         
        Case %WM_INITDIALOG
          'Dialog Set Timer CBHNDL, %myTimer, %timeOut, %NULL
          'Control Handle CBHNDL, %lCanvas To hCtrl
          Dialog Set Timer CBHNDL, %myTimer, %timeOut, %NULL
          Control Handle CBHNDL, %lCanvas To hCtrl
          ' Control Handle CBHNDL, %lCanvas To htest
          ' -- Init OpenGL
          TBGL_BindCanvas(hCtrl)     
                
        Case %WM_SIZE, %WM_SIZING
          'TBGL_UpdateCanvasProportions(hCtrl)
          'RenderMyImage(hCtrl)
     
        Case %WM_TIMER
         
     
        Case %WM_CLOSE
          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
     
    Function RenderMyImage( hCtrl As DWord )
      Static FrameRate As Double
      TBGL_BackColor 255,255,255
      If TBGL_CanvasBound(hCtrl) Then
          
       FrameRate = TBGL_GetFrameRate
       
        TBGL_SetWindowTitle(hDlg, "fps = " & Format$(round(FrameRate,0),"00000"))
        TBGL_ClearFrame
          TBGL_Camera(0, 0, 5, 0, 0, 0)
           
          ' -- Turn triangle
          TBGL_Rotate GetTickCount/30, 0, 1, 0
                                   
          ' -- Render it                              
          TBGL_GBufferRender(gbTriangle)   
             
        TBGL_DrawFrame
     
        ' -- ESCAPE key to exit application
        'If TBGL_GetWindowKeyState(hDlg, %VK_ESCAPE) Then Exit While 
         
      End If
       
    End Function
    
    Last edited by DirectuX; 20-12-2019 at 16:10. Reason: Added Sample
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  3. #3
    Thank you DirectuX, no i don't have a demand , it is i have noticed there is no official examples in which tbgl/opengl displayed while there is a button/ textbox ... on the form.
    these are a very nice advises, i have applied your suggestions one by one and when applying advice 4 i got a stable 60 fps, thats excellent for my Desktop computer with spec:
    i5-2500 3.30 GHz
    i never got more than 60 fps.
    the monitor is Led LG 22MP55HQ , refresh rate 60HZ. may be this is why i got 60fps at maximum in best situations.
    Edit i forgot to say my graphics card is Nvidia Geforce GT 640
    Regards
    Last edited by primo; 20-12-2019 at 17:33.

  4. #4
    Member DirectuX's Avatar
    Join Date
    Oct 2018
    Location
    France
    Posts
    417
    Rep Power
    55
    Quote Originally Posted by primo View Post
    i5-2500 3.30 GHz
    i never got more than 60 fps.
    Edit i forgot to say my graphics card is Nvidia Geforce GT 640
    If you want experience more than 60fps, did you try in your nvidia control panel :
    • setting you nvidia card as preferred 3d card for thinbasic.exe
    • disable vsync for thinbasic.exe

    ?
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  5. #5
    no i don't want to manipulate the defaults, i adjusted the screen for reading. since i have a poor vision.
    i have found a nice example in my hard disk (the code not by me) to get the fps by using glutget function, but it needs the glut32.dll from https://user.xmission.com/~nate/glut.html
    and glut.inc
    the following code display 60.3 fps, will try it later with other codes
    it runs in winXP32 havn't tested it yet in win7/x64.
    tested okay in TB 1.10.4 but in 1.11.1 it output error msg about glut.inc
    error.PNG
    Uses "tbgl"
      
      #INCLUDE "%app_includepath%\thinbasic_gl.inc"
      #Include "%app_includepath%\thinbasic_glu.inc"
      #Include "glut.inc"
      
      Dim hwnd As DWord 
      Global frameCount As Long
      Global previousTime As DWord
      Global timeInterval As DWord
      Global fpsGlut As Single
      Global currentTime As DWord
      
        
      hwnd = TBGL_CreateWindowEx("Geometrical Shapes - esc to exit", 500, 500, 32, 0)
      TBGL_ShowWindow
      TBGL_ResetKeyState()
    
      While TBGL_IsWindow(hwnd)
         TBGL_ClearFrame
        init
        display
        TBGL_DrawFrame
        If TBGL_GetWindowKeyState( hwnd, %VK_ESCAPE) Then Exit While  
      Wend
      
      TBGL_DestroyWindow
      
      Sub init()
        glclearcolor(0.0, 0.0, 0.0, 0.0)
        glcolor3f(0.0, 0.0, 1.0)
        glmatrixmode(%gl_projection)
        glloadidentity()
        glortho(-20.0, 20.0, -20.0, 20.0, -20.0, 20.0)
      End Sub
     
      Sub display() 
      frameCount = frameCount + 1
      '%GLUT_ELAPSED_TIME = 700 ' used only For glutget_(#GLUT_ELAPSED_TIME) Function
        'Get the Number of milliseconds since glutInit called
        '(Or first Call To glutGet(GLUT ELAPSED TIME)).
        currentTime = glutGet(%GLUT_ELAPSED_TIME)
     
        'Calculate time passed
        timeInterval = currentTime - previousTime
     
        If(timeInterval > 1000) Then
            'calculate the Number of frames per Second
            fpsGlut = frameCount / (timeInterval / 1000.0)
            TBGL_SetWindowTitle( hWnd, "FPS = "+Str$(fpsGlut))
            'Set time
            previousTime = currentTime
     
            'Reset Frame count
            frameCount = 0
        End If
        
        glclear(%gl_color_buffer_bit)
        glColor3f(1.0,1.0,0.0) 
        TBGL_PushMatrix
        TBGL_Translate 10, 0, 0
        TBGL_Rotate GetTickCount/10,0,1,0
        'glutWireTeapot(5)
        'glutWireTorus(GLdouble innerRadius, GLdouble outerRadius,GLint nsides, GLint rings);
        glutWireTorus(3.0,4.4,6,12)
        TBGL_PopMatrix
        
        
        TBGL_PushMatrix 
        glColor3f(0.0,1.0,0.0)
        TBGL_Translate -10, 0, 0
        TBGL_Rotate GetTickCount/10,0,1,0
        glScalef( 6.0, 6.0, 6.0)
        glutWireOctahedron()
        TBGL_PopMatrix
        
      End Sub
    
    i will test glutget from freeglut in another time
    Attached Files Attached Files

  6. #6
    Member DirectuX's Avatar
    Join Date
    Oct 2018
    Location
    France
    Posts
    417
    Rep Power
    55

    Question TBGL_GetFrameRate moving average

    yes, this should be steady as it average the value over 1000 frames.

    I wonder if TBGL_GetFrameRate averages too , but like a moving average over n frames ?
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  7. #7
    havn't seen your example DirectuX in https://www.thinbasic.com/community/...ll=1#post95211
    i also get 64 fps almost steady, with Dialog Show Modeless hDlg, Call dlgCallback ,strange
    i will test your example with a more complex wireframed graphics , will post soon

  8. #8
    using DirectuX example with Dialog Show Modeless hDlg, Call dlgCallback with a more stressing graphics using glDrawElements with indices
    when the number of points is 100x100 the fps is 64
    when it is 700x700 the fps is 32:
    graph.PNG
    when it is 1000x1000 the fps is 13, needs a few seconds to display and apparently the computer is stressed
    to experiment change the number of points in line 19

    '---Script created on 12-20-2019 14:23:57 by 
    Uses "UI", "TBGL"
    #Include "%app_includepath%\thinbasic_gl.inc"
    #Include "%app_includepath%\thinbasic_glu.inc"
      
    TBGL_BackColor 255,255,255
      
    Type Point3D
      x As Single
      y As Single
      z As Single
      red As Single
      green As Single
      blue As Single
       
    End Type
    
    Global indexSize As DWord
    Dim Nb As DWord =100 ' number of vertexes at each Horzontal line and Vertical line
    Dim Vertex(Nb,Nb) As Point3D 
    Dim indices(2 * Nb * Nb * 2) As DWord ' Can be also specified as UInt32
        
    ' fill the arrays with data     
    BuildScene()   
    ' -- ID numbers of controls
    Begin ControlID
      %lCanvas 
      %bClose 
        
      %myTimer 
    End ControlID
      
    Begin Const
      %MAIN_WIDTH   = 640
      %MAIN_HEIGHT  = 480
      
      %timeOut      = 20   ' -- Determines graphics refresh rate in milliseconds
    End Const
      
    Function TBMain()
      
      Global hDlg As DWord
      Global sheep As Long
      Global hCtrl As DWord
      Global x, y As DWord
      
      Dialog New Pixels, 0, "Use arrow keys - Pg U/D   - LORENZ PEARLS",-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 Or %WS_THICKFRAME, 0 To hDlg
          
        ' -- Place controls here
        Control Add Label, hDlg, %lCanvas, "", 5, 5, %MAIN_WIDTH-10, %MAIN_HEIGHT-40
          Control Set Color hDlg, %lCanvas, %BLACK, %BLACK
          Control Set Resize hDlg, %lCanvas, 1, 1, 1, 1    
      
           
        Control Add Button, hDlg, %bClose, "Close", %MAIN_WIDTH-105, %MAIN_HEIGHT-30, 100, 25
          Control Set Resize hDlg, %bClose, 0, 1, 0, 1    
         
        Dialog Set Minsize hDlg, 320, 230
         
        Dialog Show Modeless hDlg, Call dlgCallback
          
        Do
     
        Dialog DoEvents
     
        Dialog Get Size hDlg To x, x
     
        RenderMyImage(hCtrl)
         
      Loop While x 
     
    End Function 
       
    CallBack Function dlgCallback()
        
      Select Case CBMSG
          
        Case %WM_INITDIALOG
          'Dialog Set Timer CBHNDL, %myTimer, %timeOut, %NULL
          'Control Handle CBHNDL, %lCanvas To hCtrl
          Dialog Set Timer CBHNDL, %myTimer, %timeOut, %NULL
          Control Handle CBHNDL, %lCanvas To hCtrl
          ' Control Handle CBHNDL, %lCanvas To htest
          ' -- Init OpenGL
          TBGL_BindCanvas(hCtrl)     
                 
        Case %WM_SIZE, %WM_SIZING
          'TBGL_UpdateCanvasProportions(hCtrl)
          'RenderMyImage(hCtrl)
      
        Case %WM_TIMER
          
      
        Case %WM_CLOSE
          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
      
    Function RenderMyImage( hCtrl As DWord )
      Static FrameRate As Double
      'TBGL_BackColor 255,255,255
      If TBGL_CanvasBound(hCtrl) Then
           
       FrameRate = TBGL_GetFrameRate
        
        TBGL_SetWindowTitle(hDlg, "fps = " & Format$(Round(FrameRate,0),"00000"))
        TBGL_ClearFrame
          TBGL_Camera(0, 2, 4, 0, 0, 0)
            
          ' -- Turn triangle
    glMatrixMode(%GL_PROJECTION)
    glLoadIdentity()
    gluPerspective(65.0, 800/600, 1.0, 100.0)
    glMatrixMode(%GL_MODELVIEW)
    'glTranslatef(0, 1, -10)
    glShadeModel(%GL_SMOOTH) 
    glEnable(%GL_DEPTH_TEST)
           
     TBGL_Rotate GetTickCount/30,0,1,0  '*************************
       
     glClear(%GL_COLOR_BUFFER_BIT Or %GL_DEPTH_BUFFER_BIT)
     glClearColor(1, 1, 1, 1)
       
      glEnableClientState(%GL_VERTEX_ARRAY )
      glEnableClientState(%GL_COLOR_ARRAY)
      glVertexPointer(3, %GL_FLOAT,SizeOf(Point3D),VarPtr(Vertex(1,1)))
      glColorPointer(3, %GL_FLOAT, SizeOf(Point3D), VarPtr(Vertex(1,1).red))
       
      'glDrawElements(%GL_POINTS, CountOf(indices), %GL_UNSIGNED_INT, VarPtr(indices(1)))
      glDrawElements(%GL_LINES , CountOf(indices), %GL_UNSIGNED_INT, VarPtr(indices(1)))
      glDisableClientState(%GL_VERTEX_ARRAY)
      glDisableClientState(%GL_COLOR_ARRAY)
          
        ' -- ESCAPE key to exit application
        'If TBGL_GetWindowKeyState(hDlg, %VK_ESCAPE) Then Exit While 
      TBGL_DrawFrame     
      End If
        
    End Function
    
    '******************************************************
    Sub BuildScene()
      
    Dim a,b As DWord
       
    Dim xMin, yMin, zMin, xMax, yMax, zMax, range, step1, x, y, z As Single
    xMin = -2 : yMin = -2: zMin = -2: xMax = 2: yMax = 2: zMax = 2
    'xMin = -0.5 : zMin = -0.5 : xMax = 0.5: zMax = 0.5
      range = xMax - xMin
      step1 = range / Nb
      x = xMin: z = zMin : y = yMin  
       
      For b=1 To Nb
          
        For a=1 To Nb
           
          'y = Sin(10*(x^2+z^2))/10
          y = Cos(x*x+z*z)
          'y = 0
                   
          Vertex(a,b).x = x
          Vertex(a,b).y = y
          Vertex(a,b).z = z
             
          If y>=0 Then
            Vertex(a,b).red = 1.0 :Vertex(a,b).green = 0.0 :Vertex(a,b).blue = 0 
            Else
            Vertex(a,b).red = 0.0 :Vertex(a,b).green = 0.5 :Vertex(a,b).blue = 0.2
          EndIf
          If y>=0.8 Then
            Vertex(a,b).red = 0.0 :Vertex(a,b).green = 0.0 :Vertex(a,b).blue = 1 
          EndIf
               
          x = x + step1
             
        Next a
           
        x = xMin
        z = z + step1
      Next b
         
    '=================================================================================
    Dim i As DWord = 1
     
    Dim yy,xx As DWord
     
    'Grid Horizontal lines
    For yy = 1 To Nb
      For xx = 1 To Nb-1
        indices(i) = (yy-1) * Nb + xx -1 
        i+1
        indices(i) = (yy-1) * Nb + xx 
        i+1
      Next
    Next
     
    'Grid vertical lines
    For xx = 1 To Nb
      For yy = 1 To Nb-1
        indices(i) = (yy-1) * Nb + xx -1
        i=i+1
        indices(i) = (yy) * Nb + xx -1
        i+1
      Next
    Next
       
    
    End Sub
    

  9. #9
    Member DirectuX's Avatar
    Join Date
    Oct 2018
    Location
    France
    Posts
    417
    Rep Power
    55
    Now that's curious,

    with the intel graphic card I got 64 fps , and 32 with the nvidia.

    Nice teapot by the way
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

Similar Threads

  1. Idea for case-insensitive string comparisons
    By Robert Hodge in forum Suggestions/Ideas discussions
    Replies: 15
    Last Post: 21-06-2013, 22:49
  2. gamepad test comparisons
    By kryton9 in forum TBDI module. thinBasic Direct Input integration by MikeHart
    Replies: 18
    Last Post: 08-05-2007, 01:55

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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