PDA

View Full Version : Stop the madness



azcoder
01-23-2006, 01:45 PM
I have an application that runs on Windows, Linux, and mac. I recently attempted to run it on a laptop running XP and I get an Access Violation during a glCallLists call. I am also switching to VS 2005.

I have boiled it down to a problem using the std:string andglCallLists.

This works:
glCallLists( 26, GL_BYTE, "This is simply too strange");

This causes a violation:
std::string s="This is simply too strange";
glCallLists( 26, GL_BYTE, s.c_str());


Any advice/tips greatly appreciated...
Is it the MS STL implementation - should I try STL Port? Or is it more likely a driver issue? (Card in question is an nvidia 7800 Go)

Thanks
Bob

FuzzCube
01-25-2006, 04:58 AM
This is really a shot in the dark:
The problem might be that c_str doesn't return (char*), or that it doesn't hold ascii codes.

I would check MSDN to verify it. It might also be related the the MBCS/UNICODE compilation flag.

If this is not the problem, the glCallLists might refuse to work with a anything which is not specifically a pointer.

Try doing something like this:
const char * gl_str = std::string s="This is simply too strange";
glCallLists( 26, GL_BYTE, gl_str);

Good luck.

moog
01-31-2006, 06:26 PM
I believe the problem is this line of code:

std::string s="This is simply too strange";

This is not the recommended way of initializing an std:string, rather you should do this:

std::string s("This is simply too strange");

It has to do with the allocation of the string literal and the assignment operator for std:string, offhand I can't remember the details.

But more importantly, I have a hard time understanding why you would use a string to hold your display list names, wouldn't a vector be more appropriate? Obviously this example is fictious, because glCallLists will look at the numeric value of these characters, unless this is the intent and you have mapped your display list values to ascii character values.

shelll
01-31-2006, 11:42 PM
i also had some strange experience with std::string. it was something with its allocation. moog is right, try his advice.

moog: why display lists names in chars? for displaying text ;)

moog
02-01-2006, 05:40 PM
Originally posted by shelll:
why display lists names in chars? for displaying text ;) Ahh, that's cool!