Using Sphere 1.1:
The TransformBlitImage() routine in sphere_gl.cpp
builds a GL_TRIANGLE_FAN to do the transformation.
Unfortunately it guesses at the center of the
transformed area by averaging the vertices. This is
fine for rectangular transforms, but then so is
GL_POLYGON. For a non-rectangular transform however
this approximation of the center of the transformed
image is often just plain wrong.
As an example:
function game()
{
Rectangle(0, 0, 200, 200, Blue);
for (var i = 0; i <= 200; i += 10)
Line(0, i, 200, i, White);
var tex = GrabImage(0, 0, 200, 200);
FlipScreen();
tex.transformBlit(100, 100, 150, 140, 150, 260, 100,
300);
FlipScreen();
GetKey();
}
The resultant image, because of the way the triangle
fan's centre point is defined, is a perfect example of
the problem. When viewed with the Standard32 driver
the lines are correctly slanted. With the OpenGL
driver, they are quite obviously not.
It should be possible to fix this bug (for convex
transforms) by creating a two-tri fan from the provided
coordinates, rather than calculating a horribly
inaccurate central point. Since non-convex transforms
don't work correctly in all cases for any of the
drivers, it's probably easier to just use GL_POLYGON
instead of GL_TRIANGLE_FAN.
Supporting non-convex transforms is a little more
difficult, but since they don't seem to work on any of
the drivers, it's probably not useful to write the code
to handle them on the GL driver.
Logged In: YES
user_id=485394
Ok, so it's not that simple. I'm looking into it, but it
looks like GL_POLYGON and a two-tri GL_TRIANGLE_FAN are not
the answer. I haven't had much experience with OpenGL,
unfortunately.
I'm working on a solution to this, since I can actually
build the video DLLs (unlike the main engine, which I still
haven't gotten to compile). Will update as soon as I find a
solution - probably involving a more interesting
centre-point calculation.