We have a coordinate system for a web page in which top left corner is (0,0) with pixel coordinates, x increasing to the right and y increasing going down.
For laying down a character, I compute x0, y0, x1, y1, a rectangle and copy the glyph of the character.
This has worked for a long time.
For rotating all text the same way, we can apply a transform and change the projection, but if we just want to rotate one piece of text, we decided to do it by changing the x,y locations of the 4 corners of the character:
Given that we have x0, y0, x1, y1, what is wrong with the following code?
glm::mat4 t(1);
t = glm::translate(t, glm::vec3(-x,-y,0.0f));
t = glm::rotate(t, ang, glm::vec3(0,0,1));
t = glm::translate(t, glm::vec3(x,y,0));
glm::vec4 vec0(x0, y0, 0, 0);
vec0 = vec0*t;
x0 = vec0.x, y0 = vec0.y;
glm::vec4 vec1(x1, y1, 0, 0);
vec1 = vec1*t;
x1 = vec1.x, y1 = vec1.y;
I thought this should bring (x,y) to the origin, rotate by angle, then translate back