int infoLogLength = 0;
glGetObjectParameterivARB(shaderID, GL_OBJECT_INFO_LOG_LENGTH_ARB, &infoLogLength);
// This works
char *buffer = new char[infoLogLength];
glGetInfoLogARB(shaderID, infoLogLength, 0, buffer);
// This crashes
std::auto_ptr<char> buffera = new char[infoLogLength];
glGetInfoLogARB(shaderID, infoLogLength, 0, buffera.get());
I would like to use the second piece, but it crashes somewhere in my ATI driver. The first piece works like it should, but could leak memory if something goes wrong.
It's probably something to do with the auto_ptr, but since I don't have a lot of experience with them, I haven't been able to fix this.
Any ideas?
Problem with glGetInfoLogARB and auto_ptr
I'm trying to read a log from a compilation of a GLSL shader. Using a normal buffer, this works fine. However, since I am using exceptions, I'd like to make the function atomic, and to do this, I've tried to use a std::auto_ptr to retrieve the log.
I don't see why that should not work. Except that it should be:
std::auto_ptr<char> buffera(new char[infoLogLength]);
As you posted it, it does not compile.
Try using a vector and see if that works, like:
std::vector<char> buffera;
buffera.resize(infoLogLength);
glGetInfoLogARB(shaderID, infoLogLength, 0, &*buffera.begin());
std::auto_ptr<char> buffera(new char[infoLogLength]);
As you posted it, it does not compile.
Try using a vector and see if that works, like:
std::vector<char> buffera;
buffera.resize(infoLogLength);
glGetInfoLogARB(shaderID, infoLogLength, 0, &*buffera.begin());
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement