PDA

View Full Version : why this code cause glerror invalid enumerant?



EvilNando
05-30-2011, 12:11 PM
// Vertex data
if ( vertex_buffer == NULL )
{
// Create vertex buffer
glGenBuffers(1, &vertex_buffer);
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);

// Copy data
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_DYNAMIC_DRAW);

GLenum _error_check_value = glGetError();
if ( _error_check_value != GL_NO_ERROR )
{
ShowMessage("Quad::Load() Error! %s", gluErrorString(_error_check_value));
}
}

this causes an invalid enumerant error code why?

Alfonse Reinheart
05-30-2011, 12:41 PM
Who's to say that any of that code caused the error? It could have been caused by any code before this. OpenGL retains errors until you glGetError them.

McLeary
05-30-2011, 12:42 PM
Does vertex_buffer a pointer?
If it is, you are trying to write a value in a NULL pointer, which can generate this error. BTW, if vertex_buffer is a pointer, how glGenBuffers do not generate any compiler errors?

EvilNando
05-30-2011, 02:10 PM
yes you are correct

the error is being caused at the SDL initialization, sadly since that code isnt mine I really have no idea whats going on

It could be SDL or Glew init routines :S

Aleksandar
05-30-2011, 02:13 PM
Cross-posting is easy to control inside a single forum, but it is much harder across several different sites. :)

As I've already said, debug_output is so far the best solution to locate the problem.

Alfonse Reinheart
05-30-2011, 02:54 PM
the error is being caused at the SDL initialization, sadly since that code isnt mine I really have no idea whats going on

Just ignore it. Call glGetError after SDL initialization until it comes up with GL_NO_ERROR.