I am trying to write a simple OpenGL 3.2 (with GLSL 1.5) program using GLUT on Mac OS X (Mountian Lion), but I keep getting error from glValidateProgram:
'Validation Failed: Current draw framebuffer is invalid.'
What could cause this error to occur?
Like the OP i have encountered some code that uses this, and without knowing any better I implemented it immediately after the program link step. Got the same error.
I am no expert here but based on a few observations i thought I'd clarify what @robinjam seems to be saying (which echoes what the GL docs say about glValidateProgram).
The sample code I was using was Apple's iOS test OpenGL ES 2.0 demo project, and I haven't run this exact piece of code on a device yet but the Simulator gives me this Validation Failed: Current draw framebuffer is invalid. error. However, it is relevant to note that the method which runs this, - (BOOL)validateProgram:(GLuint)prog, is included in the ViewController.mm (not .m because I infected it with C++ early on) but there is no code provided with this sample code that actually calls it.
So the purpose of glValidateProgram is not to use it as an added "check" step after linking the program, because the GL and application state is hardly ready for actually using that program at this point, probably it's even before we get around to initializing the default framebuffer (its bitdepth, its multisample buffers, etc), and that's what the error hints at.
An appropriate place to call glValidateProgram would be right before you make a real render call.
It would be useful for debugging. It's an optional way for us to give a way for the driver to help us out when something seems to have gone wrong. It would be silly to call this every time we render in a non-debugging situation where everything is working smoothly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With