PDA

View Full Version : crash on glBindFragDataLocation



dlukeb
01-05-2010, 06:35 AM
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;

marshats
01-05-2010, 08:42 AM
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 (http://www.opengl.org/sdk/libs/GLEW/) or GLee (http://www.opengl.org/sdk/libs/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 (http://glew.sourceforge.net/basic.html) to get started. It is a simple matter to just call glewInit and link to the glew library at compile time.

dlukeb
01-05-2010, 03:38 PM
Yeah i'm using the latest glew.


GLenum err = glewInit();

Alfonse Reinheart
01-05-2010, 04:10 PM
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.

dlukeb
01-05-2010, 04:42 PM
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!