PDA

View Full Version : Segmentation Fault glGenBuffers



Karina
01-30-2011, 06:26 PM
Hi:

I'm a beginner programming in OpenGL. I need to create a POB (pixel Object Buffer), at time of compilation it has no errors, but at time of execution it presents a segmentation failure, my code is:

unsigned int width = 256;
unsigned int height = 256;
unsigned int size=width*height*4*sizeof(float);
GLuint vbo;

glewInit();
glGenBuffers(1,&vbo);
printf("vbo = %u\n", vbo);
printf("err = %u\n", glGetError());
glBindBuffer(GL_ARRAY_BUFFER,vbo); //bind object with vbo
glBufferData(GL_ARRAY_BUFFER,size,0,GL_DYNAMIC_DRA W);

Thanks

Tom Flynn
01-31-2011, 01:20 AM
Do you have a current GL context at the time this is called? If not, it'll segfault.

_arts_
01-31-2011, 11:09 AM
Or if you didn't previously got the function pointers.

mhagain
01-31-2011, 11:28 AM
First thing to do is to set a breakpoint at your first printf and check that glGenBuffers is non-zero. You can also check "if (GLEW_ARB_vertex_buffer_object)" to make sure that your 3D card actually does support VBOs (which is what you are creating here).