PDA

View Full Version : Unknown problem :S



JohnnyKPL
05-19-2015, 01:36 PM
Here a part of my game enigne, it should read two files with the same fstream. It gave me runtime errors like "ndvoglv64.dll unhandled exception" or my application "start a breakpoint" (I don't know how can I translate it in english, sorry :p). Anyway, here's the code:

Oh, I forgot. I save the data contains in the two file in two struct one for each. I tried to delete the part of code where I save the data and the runtime compiler doesn't give me any error.
So, i think that i send too many operation to the cpu D:



std::fstream file;
file.open("font\\font.fnt");
{
if (file.is_open())
{
unsigned int width, height;
texture.size(width, height);

std::string line;
std::vector<std::string> data;

while (std::getline(file, line))
{
data = split(line, ',');
letters[std::stoi(data[ID])] = new Letter(
std::stof(data[X]) / width,
std::stof(data[Y]) / height,
std::stof(data[WIDTH]) / width,
std::stof(data[HEIGHT]) / height,
std::stof(data[XOFFSET]) / width,
std::stof(data[YOFFSET]) / height,
std::stof(data[XADVANCE]) / width,
std::stoi(data[PAGE]),
std::stoi(data[CHNL])
);
}
}
}
file.close();

file.open("font\\color.fnt");
{
if (file.is_open())
{
std::string line;
std::vector<std::string> data;

for (unsigned short i = 0; (i < COLORNUMBER) && std::getline(file, line); i++)
{
data = split(line, ',');
colors[i] = new Color(glm::vec3(
std::stof(data[R]) / 255.0f,
std::stof(data[G]) / 255.0f,
std::stof(data[B]) / 255.0f
));
}
}
}
file.close();

carsten neumann
05-20-2015, 09:35 AM
The crash seems to happen in part of the nvidia driver, but I don't see any OpenGL calls from the code you posted so my guess is that you are overwriting memory somewhere in your program (e.g. by writing past the end of an array or something similar) causing it to crash later. You should run your program under a debugger, examine the call stack at the point where it crashes and see which of your data structures are modified in nearby code - if you compare array indices and other sizes with what you expect them to be you can often find the out of bounds access.

Your problem is not really related to OpenGL as far as I can tell, as such you have a better chance of getting useful answers by posting on a general programming forum.