Solution:
strtod instead of atof solved it. Thanks!
TODO: make this an answer for acceptance
I'm loading a value from an XML file that tells how much the texture should be rotated.
It looks like this:
string rotv = ItemElem->FirstChild("Rotation")->FirstChild()->Value();
rotation = -(atof(rotv.c_str()))*57.2957795;
In my level editor the textures are rotated properly; pi equals 180 degrees and so on. But in the engine; they are not, it seems like the decimals are ignored. So for example, a texture that should be rotated 3.14 radians is only rotated 3 radians and so on. I've tried many different approaches to make sure the decimals are included, but I can't get it to work.
I rotate the textures like this:
glBindTexture(GL_TEXTURE_2D, texture->GetImage());
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(0.5, 0.5, 0);
glRotatef(rotation, 0, 0, 1);
glTranslatef(-0.5, -0.5, 0);
glMatrixMode(GL_PROJECTION);
The value in the xml file uses a dot instead of coma and I convert it like this, I also store the decimals separately just for debugging.
for (int x = 0; x < rotv.size(); x++)
{
if (afterComa)
{
int temp = (int) rotv[x] - '0';
if (temp <10 && temp >= 0)
{
decimals[decimalPos] = temp;
decimalPos++;
}
else
{
break;
}
}
if (rotv[x] == '.')
{
rotv[x] = ',';
afterComa = true;
}
}
float decimalValue = decimals[0]/10 + decimals[1]/100 + decimals[2]/1000 + decimals[3]/10000 + decimals[4]/100000 + decimals[5]/1000000;
The decimals are stored properly and I add them to the rotation value but it still doesn't help.