Results 1 to 10 of 18

Thread: vertex buffer objects for OpenGl 1.5

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    vertex buffer objects for OpenGl 1.5

    Hi Petr
    i want to implement this VBO code in
    https://en.wikipedia.org/wiki/Vertex...ing_OpenGL_2.1
    for opengl 1.5 to 2.1
    i have added #Include "%app_includepath%\thinBasic_GLEXT.inc"
    but i get errors about the function glGenBuffers:
    A general declared function or sub has no process address. See DECLARE SET ADDRESS help for more info.
    i have searched the file "thinBasic_GLEXT.inc" and the glGenBuffers is declared like:
    DECLARE SUB glGenBuffers ( BYVAL Par1 AS GLsizei, BYREF Par2 AS GLuint)
    so what is the mystery?
    i have searched for glGenBuffers inside opengl32.dll which is located my windows xp32 system folder and can't find the glGenBuffers inside the DLL, the only place i find it is inside my nvidea card driver software. i also find it in mesa opengl32.dll https://fdossena.com/?p=mesa/index.frag in which its opengl32.dll have big size > 16MB and seems to contains all extensions.
    best regards
    Uses "tbgl", "MATH"
         
    #Def %GL_GLEXT_PROTOTYPES
    #Include "%app_includepath%\thinbasic_gl.inc"
    #Include "%app_includepath%\thinbasic_glu.inc"
    #Include "%app_includepath%\thinbasic_WGL.inc" 
    #Include "%app_includepath%\thinBasic_GLEXT.inc"
    
    Dim HglGenBuffers As DWord = TBGL_GetProcAddress("glGenBuffers") 
    Declare Set Address glGenBuffers, HglGenBuffers 
         
      Dim hwnd As DWord 
           
      hwnd = TBGL_CreateWindowEx("glDrawArrays example - esc to exit", 600, 600, 32, 0)
      TBGL_ShowWindow
      TBGL_ResetKeyState()
       
    'try float data[] = {0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0}
    Global data(9) As Single
    Array Assign data = 1.0, 0.0, 1.0, 0.0, 0.0, -1.0, -1.0, 0.0, 1.0
    
    'Create a New VBO And use the variable id To store the VBO id  
    Global triangleVBO As DWord
    glGenBuffers(1, VarPtr(triangleVBO)) ' //Make the New VBO active
    glBindBuffer(%GL_ARRAY_BUFFER, triangleVBO)
    'Upload vertex data To the video device 
    glBufferData(%GL_ARRAY_BUFFER, SizeOf(data), data, %GL_STATIC_DRAW)
    'Make the New VBO active. Repeat here incase changed since initialisation
    glBindBuffer(%GL_ARRAY_BUFFER, triangleVBO)
      
      While TBGL_IsWindow(hwnd)
         TBGL_ClearFrame
         
        display
        TBGL_DrawFrame
        If TBGL_GetWindowKeyState( hwnd, %VK_ESCAPE) Then Exit While
      Wend
         
      TBGL_DestroyWindow
     
    '=================================================================================
     
    '--------------------------------------------------------
    '--------------------------------------------------------   
    Sub display()
     
    glMatrixMode(%GL_PROJECTION)
    glLoadIdentity()
    gluPerspective(60.0, 800/600, 1.0, 100.0)
    glMatrixMode(%GL_MODELVIEW)
    'glTranslatef(0, 0, -40)
    glShadeModel(%GL_SMOOTH) 
    glEnable(%GL_DEPTH_TEST)
    gluLookAt( 0, 1, 1,
               0,  1, 0,
                0, 1,  0 ) 
        glclear(%gl_color_buffer_bit)
           
        TBGL_Rotate GetTickCount/30,0,1,0
          
    'Initialise VBO - do only once, at start of program
    'Create a variable To hold the VBO identifier GLuint triangleVBO;
    'Vertices of a triangle (counter-clockwise winding)  
    
    'Draw Triangle from VBO - Do Each time Window, view point Or data changes 
    'Establish its 3 coordinates per vertex With zero stride In This Array; necessary here
     glVertexPointer(3, %GL_FLOAT, 0, NULL)
    'Establish Array Contains vertices (Not normals, colours, texture coords etc)
     glEnableClientState(%GL_VERTEX_ARRAY)
    'Actually Draw the triangle, giving the Number of vertices provided
     glDrawArrays(%GL_TRIANGLES, 1, 9)
     'Force display To be drawn Now
     'glFlush; 
            
     glClear(%GL_COLOR_BUFFER_BIT Or %GL_DEPTH_BUFFER_BIT)
     glClearColor(1, 1, 1, 1)
    
     glDisableClientState(%GL_VERTEX_ARRAY)  
      '**************************************************
           
       
      End Sub
    
    Edit: i have added :
    Dim HglGenBuffers As DWord = TBGL_GetProcAddress("glGenBuffers") 
    Declare Set Address glGenBuffers, HglGenBuffers
    
    but still can't access glGenBuffers

    Edit2:
    my Last try, but still can't access the glGenBuffers
    my card support VBO as i can run the VBO examples in other languages.
    Uses "tbgl"
    
    #Def %GL_GLEXT_PROTOTYPES
    #Include "%app_includepath%\thinbasic_gl.inc"
    #Include "%app_includepath%\thinbasic_glu.inc"
    #Include "%app_includepath%\thinBasic_GLEXT.inc"
    #Include "%app_includepath%\thinbasic_WGL.inc" 
    
    Declare Set Address glGenBuffers,   wglGetProcAddress("glGenBuffers")   
    Declare Set Address glBindBuffer,   wglGetProcAddress("glBindBuffer") 
    Declare Set Address glBufferData,   wglGetProcAddress("glBufferData")  
      
    Dim hwnd As DWord
    
    hwnd = TBGL_CreateWindowEx("glDrawArrays example - esc to exit", 600, 600, 32, 0)
    TBGL_ShowWindow
    TBGL_ResetKeyState()
    
    'try float data[] = {0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0}
    Global data(9) As Single
    Array Assign data = 1.0, 0.0, 1.0, 0.0, 0.0, -1.0, -1.0, 0.0, 1.0
    
    'Create a New VBO And use the variable id To store the VBO id 
    Dim triangleVBO As DWord
    glGenBuffers(1, triangleVBO) ' //Make the New VBO active
    glBindBuffer(%GL_ARRAY_BUFFER, triangleVBO)
    'Upload vertex data To the video device 
    glBufferData(%GL_ARRAY_BUFFER, SizeOf(data), data, %GL_STATIC_DRAW)
    'Make the New VBO active. Repeat here incase changed since initialisation
    glBindBuffer(%GL_ARRAY_BUFFER, triangleVBO)
    
    While TBGL_IsWindow(hwnd)
    TBGL_ClearFrame
    
    display
    TBGL_DrawFrame
    If TBGL_GetWindowKeyState( hwnd, %VK_ESCAPE) Then Exit While
    Wend
    
    TBGL_DestroyWindow
    
    '=================================================================================
    
    Sub display()
    
    glMatrixMode(%GL_PROJECTION)
    glLoadIdentity()
    gluPerspective(60.0, 800/600, 1.0, 100.0)
    glMatrixMode(%GL_MODELVIEW)
    'glTranslatef(0, 0, -40)
    glShadeModel(%GL_SMOOTH) 
    glEnable(%GL_DEPTH_TEST)
    gluLookAt( 0, 1, 1,
    0, 1, 0,
    0, 1, 0 ) 
    glclear(%gl_color_buffer_bit)
    
    TBGL_Rotate GetTickCount/30,0,1,0
    
    'Initialise VBO - do only once, at start of program
    'Create a variable To hold the VBO identifier GLuint triangleVBO;
    'Vertices of a triangle (counter-clockwise winding) 
    
    'Draw Triangle from VBO - Do Each time Window, view point Or data changes 
    'Establish its 3 coordinates per vertex With zero stride In This Array; necessary here
    glVertexPointer(3, %GL_FLOAT, 0, NULL)
    'Establish Array Contains vertices (Not normals, colours, texture coords etc)
    glEnableClientState(%GL_VERTEX_ARRAY)
    'Actually Draw the triangle, giving the Number of vertices provided
    glDrawArrays(%GL_TRIANGLES, 1, 9)
    'Force display To be drawn Now
    'glFlush; 
    
    glClear(%GL_COLOR_BUFFER_BIT Or %GL_DEPTH_BUFFER_BIT)
    glClearColor(1, 1, 1, 1)
    
    glDisableClientState(%GL_VERTEX_ARRAY) 
    '**************************************************
    
    End Sub
    
    Last edited by primo; 03-12-2019 at 21:02.

Similar Threads

  1. Replies: 4
    Last Post: 31-10-2012, 19:31
  2. stencil buffer question
    By largo_winch in forum TBGL module by Petr Schreiber
    Replies: 16
    Last Post: 13-09-2011, 11:41
  3. how to make "smooth openGL objects"?
    By Lionheart008 in forum TBGL General
    Replies: 8
    Last Post: 16-11-2010, 11:34
  4. How to read the keyboard buffer?
    By Michael Hartlef in forum thinBasic General
    Replies: 7
    Last Post: 18-05-2009, 08:47
  5. PowerBasic: 6th post from Bob about objects
    By ErosOlmi in forum Power Basic
    Replies: 2
    Last Post: 08-08-2008, 17:30

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
  •