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();