Hello, hope this is the place for the question.
Basically im trying to load a fragment shader into openGL and apply it to a mesh…
Shader Code:
void main()
{
gl_FragColor = vec4(0.4,0.4,0.8,1.0);
}
Loading Shader: (I’ve put a cout<<glGetError<<endl;
after each line and they all seem to succeed)
const char *shaderArray = &file_string;
shader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource( shader, 1, &shaderArray, NULL );
glCompileShader( shader );
program = glCreateProgram();
glAttachShader( program, shader );
glLinkProgram( program );
Then after the glUseProgram a GL_INVALID_OPERATION is generated…
if( glIsProgram( program ) )
{
glUseProgram( program );
cout<<"Error Code: "<<glGetError()<<endl;
}
I’m assuming its due to:
“GL_INVALID_OPERATION is generated if program could not be made part of current state.”
OpenGL Reference Manual
But I can’t see why this is - the use Program is called once GL is initiated and everything…
I’m sure its some silly mistake, but any help would be greatly appreciated.
Thanks in Advance
- Jorj