crash on glBindFragDataLocation

My program crashes with

"unhandled exception at 0x00000000"

when i run the code:


ProgramName = createProgram( "flat-color.vert", "flat-color.frag");
glBindFragDataLocation(ProgramName, 0, "FragColor");

this is my fragment shader:

#version 130

precision mediump int;
precision highp float;

uniform vec4 Diffuse;
out vec4 FragColor;

void main()
{
	FragColor = Diffuse;
}

Most of the code up using is from the openGL 3.2 samples to get me up and running. Only different in the fragment shader is I and using version 130 since I cant run shaders 140-150;

glBindFragDataLocation is undefined with a bogus address of 0.

You need to get the address of this extension either manually (not recommended) or use one of the helper libraries – glew or GLee. Note, despite this glew reference http address, the latest glew version supports GL3.2! GLee may ot may not be so up to date.

I use glew – checkout the Basic usage Section to get started. It is a simple matter to just call glewInit and link to the glew library at compile time.

Yeah i’m using the latest glew.

GLenum err = glewInit();

Well, it clearly didn’t get the function pointer.

However, even if you do get one, your code won’t work. Presumably, your “createProgram” function actually links the program together, right? Well, that’s no good. glBindFragDataLocation, just like attribute binding, must be done before linking. Not after.

Yeah does seem like the function pointer is null.

I have my code layed out pretty much like the openGL 3 samples.

Ill look further into it.

thanks guys!