Simple problem compared to what is usually posted around here, but I'm trying to draw a rotated textured rectangle in my sprite batch:
if(sprt->tex != tex) {
flush();
sprt->tex = tex;
}
glm::vec2 oldHsize = hsize;
hsize.x = oldHsize.x * cos(angle) - oldHsize.y * sin(angle);
hsize.y = oldHsize.x * sin(angle) + oldHsize.y * cos(angle);
data.push_back({{pos.x - hsize.x, pos.y - hsize.y}, {0, 1}});
data.push_back({{pos.x + hsize.x, pos.y - hsize.y}, {1, 1}});
data.push_back({{pos.x - hsize.x, pos.y + hsize.y}, {0, 0}});
data.push_back({{pos.x + hsize.x, pos.y - hsize.y}, {1, 1}});
data.push_back({{pos.x - hsize.x, pos.y + hsize.y}, {0, 0}});
data.push_back({{pos.x + hsize.x, pos.y + hsize.y}, {1, 0}});
}
hsize is half the size of the sprite being drawn. But it seems to draw it completely incorrectly. If I slowly increase the value of angle, here's what it looks like (in the attachments).