glGenBuffersARB problem

Started by
7 comments, last by Gumgo 15 years, 10 months ago
Hello. I'm having a problem with the function glGenBuffersARB. For some reason, it doesn't seem to assign an ID to the variable in the second parameter. Here is what I have:

struct VBO
{
	UINT id; // <- the ID of the vbo
	std::vector <vbochunk> DataChunk;
	int size;
	VBO();
	~VBO();
};

VBO::VBO() : size( 0 )
{
	glGenBuffersARB( 1, &id ); // <- this doesn't assign "id" with anything
	glBindBufferARB( GL_ARRAY_BUFFER, id );
	glBufferDataARB( GL_ARRAY_BUFFER, VBO_SIZE, NULL, GL_STATIC_DRAW );

	...
}

id remains uninitialized even after the glGenBuffersARB call (something like 0xCCCCCCCC). Any ideas as to why this function might not be working?
Advertisement
Check glGetError directly after.
There is no current GL context, so it does nothing.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
It reports GL_INVALID_OPERATION but I don't think I can rely on that because the error reporting function seems to always report GL_INVALID_OPERATION, even before OpenGL has been initialized.
Quote:Original post by Gumgo
It reports GL_INVALID_OPERATION but I don't think I can rely on that because the error reporting function seems to always report GL_INVALID_OPERATION, even before OpenGL has been initialized.

So you're saying it's an error in OpenGL that somehow no one else have ever noticed?

I think it's slightly more likely that you simply have a problem in your code which *causes* it to always report GL_INVALID_OPERATION
I'm not saying it is an error with OpenGL, but there is something weird with my setup/system/drivers that causes it to report that error even before I've initialized OpenGL or called any OpenGL related functions.

Anyway, thanks V-man, that turned out to be the problem! I had OpenGL initializing after the VBOs.
Quote:Original post by Gumgo
I'm not saying it is an error with OpenGL, but there is something weird with my setup/system/drivers that causes it to report that error even before I've initialized OpenGL or called any OpenGL related functions.


And.. what behavior are you expecting ? A crash ? A GL_NO_ERROR return ? No thanks, I'll take a GL_INVALID_OPERATION any day over those :)

Y.
Quote:Original post by Gumgo
It reports GL_INVALID_OPERATION but I don't think I can rely on that because the error reporting function seems to always report GL_INVALID_OPERATION, even before OpenGL has been initialized.


You're probably using the VBO class before initializing OpenGL, and i'm pretty sure you cant use extensions without initializing OpenGL...
Yep, as I mentioned, that did turn out to be the issue (I accidentally called the function to initialize OpenGL after the one to initialize the VBOs).

About the error thing... okay, so it does make sense that it would return GL_INVALID_OPERATION when called before initialization. But I read that calling glGetError() until all errors have been returned will reset the error flags. This code:
while (1){    if (glGetError() == GL_NO_ERROR)        break;}
Loops infinitely (always returning GL_INVALID_OPERATION) no matter where I put it in the program. If I understand, the GL_INVALID_OPERATION flag should be reset once it is returned. So I'm either doing something weird with glGetError() and THAT function is causing an error, or there is something wrong with my setup/system/drivers/etc.

This topic is closed to new replies.

Advertisement