3

I'm trying to find what is causing a segfault when glDrawArrays is called (as gdb says) in my simple program.

When I use the OpenGl calls directly, the program runs fine. But when I wrap them up into two classes (under construction, of vao and vbo) the program segfaults.

So, in my wrappers, I definitly disabled something or set something I'm not supposed to.

My question is, how do I get some diagnostics that will help me pinpoint the source of the problem ?

I'm looking for something similar to what glGetShaderiv does, but for vao and vbo s, that will tell me if I have..say.. unbound a buffer by mistake.

[I'm not posting the code here, but if any of you want to donate some time by testing a segfaulting example, here is a tar.gz of the source . You'll need working libraries of sfml-2.0rc, glew and gcc>=4.6 .]

genpfault
  • 51,148
  • 11
  • 85
  • 139
manasij7479
  • 1,665
  • 1
  • 14
  • 22

2 Answers2

4

Try out a program like GDEBugger: http://www.gremedy.com/

It allows you to easily check the state of OpenGL and give you good diagnostics.

Pubby
  • 51,882
  • 13
  • 139
  • 180
  • Seems interesting, I'll give it a try. (Also looks like it would be a wonderful tool for learning OpenGl smoothly!) – manasij7479 Jun 22 '12 at 01:43
  • I tried to get my program running in it for quite some time, but it wasn't cooperating much with my OS. (/usr/lib and /usr/lib64 issues, which a soft link didn't fix). I'll try to get it running the next time I run into a serious problem. – manasij7479 Jun 22 '12 at 14:06
2

Your VBO data must be alloocated when you call glVertexAttribPointer. But because you call it afterwards, the previously called glVertexAttribPointer will instruct VAO to point to invalid location - thus the crash during the drawing.

See how you are calling the code in your commented section - first the glBufferData, and only then glVertexAttribPointer.

Mārtiņš Možeiko
  • 12,733
  • 2
  • 45
  • 45
  • Thanks, that was the issue.(Along with the fact that I was calling glBindVertexArray with a zero argument , before I was done with all the operations on a VAO.) – manasij7479 Jun 22 '12 at 14:08