Originally posted by adamnation:
loc = glGetAttribLocation(shaderprog, “Tangent”);
glEnableVertexAttribArray(loc);
glVertexAttribPointer(loc,3,GL_FLOAT,GL_FALSE,0,tangents);
it’s non sense. Write instead :
glBindAttribLocationARB(program, 6, "Tangent"); // Use attrib 6 (reserved for tangents - see glTangentPointerEXT).
glLinkProgramARB(program); // Need to link a second time.
glVertexAttribPointer(6,3,GL_FLOAT,GL_FALSE,0,tangents);
What about what I wrote is non-sense? Exactly how is that not the proper way to send vertex attributes to a shader?
What benefit is derived from using location six for tangents? Its just a vec3 in the shader anyways. Why is glBind AttribLocations being used instead of what I have?
Dont worry. You can ask for the attribute location AFTER the program was linked, instead of assign manually the slot.
A crash at a glDrawxxxx call, is caused usually by a bad initialization of the used arrays. You probably forgot to disable any array that was previoulsly enabled but is not used, or some of the used arrays are smaller than they should be (perhaps because you are setting up a vec3 vector and passing an array of vec2 vectors), or you are using an invalid pointer… There are a lot of possibilites.
Okay, I’m using glBindAttribLocation as well as gldrawarrays now, I’ve also made sure that all the data was where it was supposed to be, so there’s no missing values, or too-short arrays or anything like that.
Still its crashing. Now when I comment all the shader code out, it runs fine.