Gldrawelements crash

When I call gldrawelements my program crashes.

When I comment out my shader code it works fine. The code is as follows:

vshader = glCreateShader(GL_VERTEX_SHADER);
fshader = glCreateShader(GL_FRAGMENT_SHADER);

glShaderSource(vshader, length,source, NULL);
glShaderSource(fshader, length,source2, NULL);


shaderprog = glCreateProgram();

loc = glGetAttribLocation(shaderprog, "Tangent");

Running a Radeon 9600 Pro, latest catalyst drivers. Anybody know what I’m doing wrong?

Originally posted by adamnation:
loc = glGetAttribLocation(shaderprog, “Tangent”);
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.	

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?

AdamNation :confused:

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.

Yes, it might something else than the vertex attrib binding.

Try a very simple shader, see what’s happening, or use GLIntercept, this will help to track down othe issues.

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.

One interesting note, after:


I have:

void* foo = NULL;

The value returned to foo is NULL, so looks like there’s trouble with glVertexAttribPointer.


This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.