Well, there are a couple of things that are... odd about this code.
First:
glDrawArrays(GL_TRIANGLES, 0, 2);
That will never actually draw anything. Triangles are made of 3 vertices and you told it to read 2.
I doubt that's causing the seg-fault, but it might be. Just change the 2 to 3.
Next:
const float vertexPositions[] = {
0.75f, 0.75f, 0.0f, 0.2f,
0.75f, -0.75f, 0.0f, 0.2f,
-0.75f, -0.75f, 0.0f, 0.2f,
};
Again I'm not sure how you copied that wrong, but the "0.2f" for the W component should be "1.0f".
The source of your segfault:
glEnableClientState(GL_VERTEX_ARRAY);
Why do you call this? OK, I know why you're calling it. You've somehow taken a tutorial that's supposed to be showing you how to do modern, shader-based OpenGL, and are adapting it to fixed-function stuff.
If you are, then you need to adapt it properly.
glVertexAttribPointer
is for setting up generic vertex attributes. You cannot use generic vertex attributes with fixed-function rendering. If you're going to do things in fixed-function, you need to actually do them in fixed function:
glBindBuffer(GL_ARRAY_BUFFER, positionBufferObject);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(4, GL_FLOAT, 0, 0);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
0x00000000
. For some reason on my linux machine gdb can't get a backtrace, complainingBacktrace stopped: previous frame inner to this frame (corrupt stack?)
. \$\endgroup\$