Bug in dglDrawBitmapStretchSR
by Andy Rollins · in Torque Game Engine · 05/21/2007 (8:43 am) · 0 replies
Unless I am very much mistaken there is a bug in the dglDrawBitmapStretchSR function found in dgl.cc, this is under 1.5.1 & 1.5.2. If no rotation parameter is supplied it quite correctly sets the scrPoints array used for drawing the vertexs in the sequence Top Left, Top Right, Bottom Left, Bottom Right as shown below
This is the correct behaviour and draws the image from top to bottom, whereas if a rotation is specified then the scrPoints are specified in the sequence Bottom Left, Bottom Right, Top Left, Top Right again as shown below:
This causes any rotated image to be flipped on the Y-axis regardless of whether you want it to be or not. In order to resolve this just replace the incorrect points above with:
Hopefully we can get this bug fixed in a later release of Torque.
if(fSpin == 0.0f)
{
scrPoints[0].x = dstRect.point.x;
scrPoints[0].y = dstRect.point.y;
scrPoints[1].x = dstRect.point.x + dstRect.extent.x;
scrPoints[1].y = dstRect.point.y;
scrPoints[2].x = dstRect.point.x;
scrPoints[2].y = dstRect.point.y + dstRect.extent.y;
scrPoints[3].x = dstRect.point.x + dstRect.extent.x;
scrPoints[3].y = dstRect.point.y + dstRect.extent.y;
}This is the correct behaviour and draws the image from top to bottom, whereas if a rotation is specified then the scrPoints are specified in the sequence Bottom Left, Bottom Right, Top Left, Top Right again as shown below:
points[0].set(-halfExtentX, halfExtentY, 0.0f);
points[1].set( halfExtentX, halfExtentY, 0.0f);
points[2].set(-halfExtentX, -halfExtentY, 0.0f);
points[3].set( halfExtentX, -halfExtentY, 0.0f);This causes any rotated image to be flipped on the Y-axis regardless of whether you want it to be or not. In order to resolve this just replace the incorrect points above with:
// ADR - set the vertex points in the correct sequence so it doesn't flip the image incorrectly
points[0].set(-halfExtentX, -halfExtentY, 0.0f); // tl
points[1].set( halfExtentX, -halfExtentY, 0.0f); // tr
points[2].set(-halfExtentX, halfExtentY, 0.0f); // bl
points[3].set( halfExtentX, halfExtentY, 0.0f); // brHopefully we can get this bug fixed in a later release of Torque.