Hello,

I'm learning to use modern OpenGL functionnalities (like Shaders and VBOs) at my university but I have some problems.

First of all I'm using Ubuntu and this is what the command glxinfo | grep version show :
Code :
server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.4
OpenGL version string: 1.4 Mesa 8.0.2

glxinfo | grep GL_ARB_VERTEX outputs the following :
Code :
 GL_ARB_vertex_program, GL_ARB_vertex_shader, GL_ATI_draw_buffers, 
    GL_ARB_texture_non_power_of_two, GL_ARB_vertex_buffer_object, 
    GL_APPLE_object_purgeable, GL_ARB_vertex_array_object,
so I have the ARB extensions allowing me to use VBOs.

The problem now : the following code
Code :
#include <GL/glew.h>
#include <GL/glut.h>
#include <iostream>
 
class Vec3{
public:
	float m_x;
	float m_y;
	float m_z;
 
	Vec3(){}
	Vec3(float x, float y, float z){
		m_x=x;
		m_y=y;
		m_z=z;
	}
};
 
GLuint VBO;
 
static void CreateVertexBuffer()
{
	Vec3 vertices[1];
	vertices[0] = Vec3(0.0f, 0.0f, 0.0f);
 
	glGenBuffersARB(1, &VBO);
	glBindBufferARB(GL_ARRAY_BUFFER, VBO);
	glBufferDataARB(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
}
 
static void renderScene(){
	glClear(GL_COLOR_BUFFER_BIT);
	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3, GL_FLOAT, 0, 0);
	glDrawArrays(GL_POINTS, 0, 1);
	glDisableClientState(GL_VERTEX_ARRAY);
	glutSwapBuffers();
 
}
int main(int argc, char **argv) {
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
	glutInitWindowSize(400, 400);
	glutInitWindowPosition(50, 50);
	glutCreateWindow("Tutorial 2");
	glutDisplayFunc(renderScene);
	GLenum err = glewInit();
	if (err != GLEW_OK){
		std::cerr << "Error : " << glewGetErrorString(err) << std::endl;
		return -1;
	}
 
	glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
	CreateVertexBuffer();
	glutMainLoop();
	return 0;
}

Works fine, but if I replace the lines
Code :
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, 0);
glDrawArrays(GL_POINTS, 0, 1);
glDisableClientState(GL_VERTEX_ARRAY);

with the following :
Code :
glEnableVertexAttribArrayARB(0);
glVertexAttribPointerARB(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glDrawArrays(GL_POINTS, 0, 1);
glDisableVertexAttribArrayARB(0);

I get a Segmentation fault. Anybody knows why ?