Ramy Al Zuhouri
Ramy Al Zuhouri

Reputation: 21966

GLSL 1.20: sending attribute causes segmentation fault

I need to pass an attribute variable to the shader, to know how to compute gl_Position. This value should be different for any object drawn. This is the declaration:

attribute int drawText;

According to it's value I decide how to compute gl_Position. This is hot I pass it in the c++ program:

// Pass some uniforms
GLint location= glGetAttribLocation(program_id, (char*)"drawText");
glEnableVertexAttribArray(location);
glVertexAttribI1i(location,1);
glutSolidCube(15);
glDisableVertexAttribArray(location);

But I get segmentation fault. I tried to comment the line where I send the attribute (glVertexAttribI1i), and the program doesn't crash in this case. What could the problem be?

Upvotes: 0

Views: 241

Answers (2)

sbabbi
sbabbi

Reputation: 11181

Integer vertex attributes requires OpenGL 3.0 and GLSL >= 1.30.

Maybe you are using GLEW? You should check that (void*)(glVertexAttribI1i) != 0 before using it.

Moreover, when an attribute has the same value for each vertex, like in the snippet you posted, you should use uniforms.

Upvotes: 1

Yong Li
Yong Li

Reputation: 266

Check the data type is the same, or the attribute name "drawText" is correct.

Upvotes: 0

Related Questions