문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top