cginternals / globjects

C++ library strictly wrapping OpenGL objects.
https://globjects.org
MIT License
538 stars 59 forks source link

Add ARB_program_interface_query function calls and convenience methods #269

Closed mrzzzrm closed 9 years ago

mrzzzrm commented 9 years ago

Fixes #267

I've done some rough testing, so it (and especially the convenience methods) should be working fine.

mrzzzrm commented 9 years ago

Okay, early out is in. Also I'm not sure about modifying a strings data using data() (http://stackoverflow.com/a/14291203) so I went the safe route and used std::vector<char>.

mrzzzrm commented 9 years ago

About std::string Program::getResourceName(), there is another problem. If you query for a non-existing index, behaviour is undefined, i.e. you are not guaranteed to get nameLength==1 (although this value may still be returned for other interfaces/properties, I don't know). My system just returns some integer. I query glGetError() now before allocating.

mrzzzrm commented 9 years ago

(This has the downside that glGetError() will be cleared, so from the caller perspective of `getResourceName()`` there is no difference between a legal empty name and a non-existing name. Not sure what to do about this. Provide an optional additional bool-ptr parameter to let the user do error checking if he wants to, maybe?)

scheibel commented 9 years ago

The actual problem is, that glGetError is called internally during the glGetProgramResource call and if an error occurs, an exception is thrown (our typical usecase with enabled exceptions). So you wouldn't ever get the error code. If there is no other way with the OpenGL API to determine if the glGetProgramResource call will, the error should get propagated to the user.

mrzzzrm commented 9 years ago

Okay, I've removed that convenience method. I don't feel like I can come up with a satisfying solution for now. I can't even figure out what the standard defines about accessing access a non-existing index via glGetProgramResourceiv()... I might come up with a solution once I am a little more into the topic!