Closed mrzzzrm closed 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>
.
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.
(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?)
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.
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!
Fixes #267
I've done some rough testing, so it (and especially the convenience methods) should be working fine.