Sign in to follow this  
rick_appleton

Problem with glGetInfoLogARB and auto_ptr

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this