Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: glGenBuffers - basics

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2013
    Posts
    15

    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 :
    glGenBuffers(1,&bufferId);

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

    Thanks
    Sajjadul

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    645
    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
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    433
    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.
    Eg.
    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
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,138
    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
    Junior Member Newbie
    Join Date
    Feb 2013
    Posts
    15
    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.

Posting Permissions

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