Results 1 to 5 of 5

Thread: glGenBuffers - basics

  1. #1
    Senior Member Regular Contributor
    Join Date
    May 2012

    glGenBuffers - basics

    Hi Forum,

    I am having trouble to create a buffer object . The buffer id is returning 0 . Is this a valid value?

    I checked in the funcion reference - glIsBuffer() that it returns false if the buffer id is 0.

    I am lost here, i am not aware of the reasons why you might have the buffer id 0 even after calling the function :

    Code :

    Some explanation over this issue would be very helpful, specially where to look into once you have this type of bug.


  2. #2
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Id 0 is a reserved object id that means "no object", for example to not bind any buffer to <target>: glBindBuffer(<target>, 0).
    Are you on windows? Are you dynamically loading OpenGL functions for 1.2+ correctly (see the wiki)?

  3. #3
    Senior Member Regular Contributor
    Join Date
    Oct 2009
    As well as checking you're loading the functions correctly, are you making the calls in a place where you have a current OpenGL context (ie. not trying to create a buffer object before the context is created, or from the wrong thread).

    Although it doesn't really help in this case, when a function is meant to return a value via a parameter and doesn't seem to be working correctly sometimes it's worth changing the default value passed in to see if it always returns the same value or is just leaving the value untouched.
    Code :
    GLuint bufferId = 42;
    glGenBuffers(1, &bufferId);

    If it returns 0 then it's setting it to that value, if bufferId remains 42 then the function isn't adjusting the value. Sometimes the difference between the the value being set or untouched can help identify the problem.

  4. #4
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    If the function pointers weren't being loaded I'd expect a crash when attempting to call glGenBuffers rather than return of 0.

    A possible cause - and here I'll freely admit that I'm just pulling ideas off the top of my head - is that you're actually loading something else in place of glGenBuffers, and that something else has the same function signature, possibly as a result of copy-and-paste code. E.g something like this:

    Code :
    glGenBuffers = (PFNGLGENBUFFERSPROC) wglGetProcAddress ("glDeleteBuffers");

    If that was the case, then the following code sequence would be expected to return 0:

    Code :
    GLuint bufferid = 0;
    glGenBuffers (1, &bufferid);

  5. #5
    Senior Member Regular Contributor
    Join Date
    May 2012
    Thanks Folks for all the hint. I shall elaborate more on this issue. Basically the problem arose in whiling working with OpenSceneGraph System which uses OpenGL down the pipeline. I am working on Ubuntu Linux with NVIDIA GTX 560M and OSG is dynamically loading the OpenGL functions. I have made sure from the OSG that the application is single-threaded. OSG is loading the OpenGL functions through function pointer and while doing that the application is not crashing.

    Is that anything to do with OpenGL context. I am also making the context current.

    I am creating an OpenCL plugin for the OpenSceneGraph . OpenSceneGraph already has the CUDA plugin. glGenBuffers() works fine with one of its CUDA example . But it not behaving with the OpenCL attachment that i am trying to create here.

Similar Threads

  1. glGenBuffers
    By ctrlf5 in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 12-14-2018, 07:35 AM
  2. glGenBuffers returns 0
    By Blakeasd in forum OpenGL: macOS
    Replies: 2
    Last Post: 07-24-2013, 10:49 AM
  3. glGenBuffers execution error
    By sam_thedancer in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 09-28-2012, 01:51 PM
  4. glGenBuffers not exist
    By Dennis in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 09-11-2011, 08:05 AM
  5. glGenBuffers segfault
    By nospoon in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-22-2010, 06:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean