PDA

View Full Version : help: problem with glGenVertexArrays()



bootstrap
12-26-2012, 10:08 PM
I just installed a new video card (GTX 680) in my computer (64-bit ubuntu linux v12.04) and installed the latest nvidia driver (v310.19) and updated my GLEW files to v190. I updated my GL and GLX include files from the nvidia driver, and updated my GLEW include and source files from the new GLEW files.

Now my 3D engine doesn't work. BTW, it did run on the new graphics card before I updated the drivers and GLEW (I'm about 99% sure of that).

The problem is, the OpenGL function glGenVertexArrays(1, &vaoid) always returns a value of zero no matter how many times I call the function, and no matter how many VAO identifiers I ask the function to generate.

Does anyone know what this problem is... or might be?

I cut and paste the section of code where the problem occurs. Note that I just added all those glGetError() calls to debug what's happening. Note that ALL of the glGetError() calls return zero, indicating no errors. However, it seems to me that glGetVertexArrays() returning a value of zero IS an error (at least on its part).

Note that it does return valid identifiers for the IBO and VBO (values == 1 and 2).

Note that this error is happening the first time glGetVertexArrays() is being called after my program starts up. Also note that the same problem happens whether I compile the program into a 32-bit executable or a 64-bit executable (both of which ran before).

My current code is OpenGL v3.20 level. I upgraded my GPU to update my engine to OpenGL and GLSL v4.30 level.

Hmmmm. During startup I print out a whole pile of xwindows, GLX and GL values, and I notice the following string prints out for glGetString(GL_VERSION):

2.1.2 NVIDIA 313.09

What is the 2.1.2 supposed to be? The version of OpenGL? If so, that appears to be a version before the VAO was supported. If so, is there some new call that's now required to specify what version of OpenGL my program intends to access... and maybe it defaults to v2.12 if nothing is specified? (Of course, I don't think there ever was a version 2.12 of OpenGL).

Also, what is the 313.09 supposed to be? The driver was supposed to be 310.19 on the nvidia website (and that is still the version on their website today, so I don't think v313.09 even exists yet).




u32 vaoie = 0;
u32 vaoif[4];
vaoif[0] = 0;
vaoif[1] = 0;
vaoif[2] = 0;
vaoif[3] = 0;

error = glGetError();
error = glGetError();
glGenBuffers (1, (GLuint*)&iboid); // OpenGL - create IBO identifier
error = glGetError();
glGenBuffers (1, (GLuint*)&vboid); // OpenGL - create VBO identifier
error = glGetError();
glGenVertexArrays (1, (GLuint*)&vaoid); // OpenGL - create VAO identifier
error = glGetError();
glGenVertexArrays (1, (GLuint*)&vaoie);
error = glGetError();
glGenVertexArrays (4, (GLuint*)&vaoif[0]);
error = glGetError();
if (iboid <= 0) { return (CORE_ERROR_INTERNAL); } // error - invalid IBO identifier
if (vboid <= 0) { return (CORE_ERROR_INTERNAL); } // error - invalid VBO identifier
if (vaoid <= 0) { return (CORE_ERROR_INTERNAL); } // error - invalid VAO identifier


------------------------------------------------------------------------------

Dark Photon
12-27-2012, 02:42 PM
The problem is, the OpenGL function glGenVertexArrays(1, &vaoid) always returns a value of zero no matter how many times I call the function, and no matter how many VAO identifiers I ask the function to generate.
Sounds like you don't have a valid context or something else is wrong before this call.

First, you aren't checking for GL errors properly. You're querying for them, but then not doing anything with them. Replace all of your statements calling glGetError with a call to this function (for starters):


void CheckGLErrors()
{
GLenum err ;

while ( (err = glGetError()) != GL_NO_ERROR )
fprintf( stderr, "OpenGL Error: %s\n", gluErrorString ( err ) );
}

bootstrap
12-27-2012, 07:31 PM
I'm almost certain you are correct (the problem is getting OpenGL v4.30 context, not default OpenGL v2.10 context). Therefore, to keep forum messages consistent with their titles, I will start a new thread. Please join me there. Thanks.