LWJGL Forum

Programming => OpenGL => Topic started by: mikage on December 11, 2009, 15:59:42

Title: glGenBuffers is not supposed to create the buffer
Post by: mikage on December 11, 2009, 15:59:42
It seems to me that the method glGenBuffers of LWJGL does more than it should do. According to the OpenGL spec, this method should return valid buffer ids without associating them to a buffer object. This is best explained in the definition of glIsBuffer :

http://www.opengl.org/sdk/docs/man/xhtml/glIsBuffer.xml (http://www.opengl.org/sdk/docs/man/xhtml/glIsBuffer.xml)

Yet, this sample code returns true :


int bufferId;
IntBuffer intBuffer = IntBuffer.allocate(1);
GL15.glGenBuffers(intBuffer);
bufferId = intBuffer.get(0);
System.out.print(GL15.glIsBuffer(bufferId));


Can someone please explain if I'm wrong here ?

Thanks
mikage
Title: Re: glGenBuffers is not supposed to create the buffer
Post by: Kai on December 11, 2009, 16:25:51
This seems to be no bug in LWJGL.

I tested this with a simple C/GLEW-example and it gave me the exact same results that you get with LWJGL.

Besides, LWJGL really does not do anything else than forwarding the call to the C library :-)
Title: Re: glGenBuffers is not supposed to create the buffer
Post by: delt0r on December 11, 2009, 16:31:59
You are misunderstanding what the return number is.

Its a handle to a buffer as a int. The isBuffer just checks to see if this handle is a buffer handle. No data is yet associated with it.
Title: Re: glGenBuffers is not supposed to create the buffer
Post by: Kai on December 11, 2009, 16:36:04
QuoteYou are misunderstanding what the return number is.
I don't think that mikage is misunderstanding the meaning of that method.

As stated by the spec:
QuoteA name returned by glGenBuffers, but not yet associated with a buffer object by calling glBindBuffer, is not the name of a buffer object.
a name returned by glGenBuffers should not return TRUE for glIsBuffer.

So, I guess that the OpenGL implementation in the driver is wrong, at this part.
Title: Re: glGenBuffers is not supposed to create the buffer
Post by: delt0r on December 11, 2009, 17:03:05
indeed Kai, you are correct. It seems perhaps the driver author had a similar misunderstanding...
Title: Re: glGenBuffers is not supposed to create the buffer
Post by: mikage on December 11, 2009, 17:25:19
So it seems to be a driver problem then. Thanks for the help  :).
(for info  I'm testing this on an NVidia 8400GS with the Nvidia 177.82 driver in Ubuntu 8.10.)