From: Allen A. <ak...@po...> - 2000-06-30 17:46:34
|
On Fri, Jun 30, 2000 at 10:06:08AM -0700, Daniel Vogel wrote: | | neither the specs nor the blue book mentions creating a GL_INVALID_VALUE | when you pass NULL to glReadPixels ... In most cases OpenGL doesn't check pointers for validity. For example, the spec doesn't require an implementation to generate an error if the app calls glVertex3fv(NULL), or if the argument pointer has incorrect alignment for the type of data it's supposed to reference, or if it points to memory with insufficient access permissions, etc. There are some cases where pointers will be checked -- in the case of glReadPixels, I imagine the pointer and destination image memory would be checked thoroughly if the driver decides to use DMA for transferring the image. But as far as I know, the OpenGL spec doesn't say what should happen in such cases, because they're too system-dependent or even data-dependent. | ... is it legal for Mesa to generate an | error in this case? I am wondering how much I can assume about error | checking, like can an implementation generate errors for things not | covered by the specs? Some implementations do generate errors for conditions that aren't mentioned in the spec, but in my experience, that's usually a strategy of desperation. For example, suppose there's a known bug in the hardware, and the driver chooses to generate an error rather than fall back to software rendering. The rendering will be incorrect, but the error gives the app developer a clue as to what caused the problem, and he can then consult the release notes for the driver to understand the situation. I guess the bottom line is that the implementation *is* free to generate errors under conditions not mandated by the spec, but it would be dangerous for apps to depend on it. A nice compromise is to use an OpenGL debugger to check for things like NULL pointers in inappropriate places, but I don't know if one of the existing *NIX or Win32 debuggers has been ported to Linux yet. That would be a good open-source project. Allen |