Better Error Code Detection

OGL should have better error code detection, even if it was something as simpal as returning false if a funtion fail and true if it went well. I just resently had an OGL problem with a a texture. glGetError sent back nothing. It would speed up error detection and prevent crashes if OGL had this.

What was your problem ?

And which error mechanism would you propose ?

Well I fixed my problem but what I would suggest is something like this

if(!glTexture2d(…))
{
cout << "texture loading failed
";
}

//or

switch(glTexture2d(…))
{
case WIDTH_WRONG:
cout << "wrong width size
";
break;

case BAD_DATA:
cout << "the data you sent was bad
";
break;

//and all the other errors there could be with gltexture2d
}

Something like that should be put in for most of the OGL funtions to help error detection.

At the moment, the specification could allow such error detection using glGetError. Though, this granularity is probably too advanced and would affect performance. Moreover, I fear the explosion of different error codes.

The other problem being that (almost) all functions would return an integer. It would yield an additional return value when most of the time you don’t use it (thus affect performance for nothing significant) and it could not be possible to implement this for functions that already return a value (like glGenLists). And at last, but not least, the return value could be discarded if the user “ignores” what the function returns. The scope of glGetError is clearly to get errors that “could ever happen since last time glGetError was called”. You can call 10 GL commands and then know what happened by querying a single glGetError. If the user had to check every single return value of the GL commands, I realize how annoying would it be.

Actually, I think that what ou want to do is already possible using the glGetError mechanism. In my application, I even use a macro when I want to test errors, which lacks of granularity but allows to test errors with a great ease.

[This message has been edited by vincoof (edited 02-05-2003).]

hmm I guess that raises a good point. glGetError dosnt always give me a good error though sometimes more info would be nice. It was just a thought I didnt think about all the extra memory it would take up.