PDA

View Full Version : Non-standard error behavior in glClearBuffer* on OS X



Andon13
10-25-2013, 01:55 PM
In answering a question on Stack Overflow, it came to my attention that glClearBuffer (...) does not define an error when draw buffers are all GL_NONE and GL_COLOR is used. The implementation on OS X generates an Invalid Operation error, which according to the official OpenGL specification, glClearBuffer (...) is never supposed to do. Logically, raising GL_INVALID_OPERATION seems like the proper thing to do in this situation, but the specification does not mention any such behavior.

Is this an oversight in the specification and/or is Apple doing something wrong?

thokra
10-28-2013, 03:54 AM
Well, it's not specified and therefore undefined behaviour - Apple obviously determined that generating an INVALID_OPERATION is appropriate. If you want, you can file request for clarification in the OpenGL spec bugzilla (http://www.khronos.org/bugzilla/buglist.cgi?product=OpenGL&component=Specification&resolution=---) to get feedback and see if it's an oversight or intended.

Dan Bartlett
10-28-2013, 05:19 AM
OpenGL 4.4 specifies behavior for this, it says:

If the value of DRAW_BUFFERi is NONE, the command has no effect.
but previous versions didn't specify what should happen.

thokra
10-28-2013, 05:24 AM
Dan, I wanted to quote that too at first, but I think Andon meant invoking ClearBuffer() when there currently are no enabled draw buffers. Otherwise,


when draw buffers are all GL_NONE
doesn't make much sense. I might be wrong, however. :)

arekkusu
10-28-2013, 09:44 AM
In answering a question on Stack Overflow, it came to my attention that glClearBuffer (...) does not define an error when draw buffers are all GL_NONE and GL_COLOR is used. The implementation on OS X generates an Invalid Operation error

No, it doesn't. It no-ops.

The person asking this question on stackoverflow should verify their context is Core Profile. OS X will throw INVALID_OPERATION (per spec) when attempting to call a deprecated function in Core Profile. Also (because OS X provides static linkage) it will throw INVALID_OPERATION when attempting to call a Core-Profile function in a 2.1 Legacy Profile.

Andon13
10-30-2013, 10:36 PM
The person asking this question on stackoverflow should verify their context is Core Profile. [...] (because OS X provides static linkage) it will throw INVALID_OPERATION when attempting to call a Core-Profile function in a 2.1 Legacy Profile.

Spot on, this was precisely the problem. The description of the problem included some superfluous details and neglected to mention the context profile.