• Advertisement
Sign in to follow this  

Problem with glGetInfoLogARB and auto_ptr

This topic is 4645 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.
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?

Share this post


Link to post
Share on other sites
Advertisement
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());





Share this post


Link to post
Share on other sites
It's strange because that code did compile on Visual C++ Express Beta 2.

But your fix did work. I was just using the auto_ptr incorrectly. Thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement