libgdx,如何让opengl正确拉伸图像?

the*_*ter 5 opengl transform stretch libgdx

所以我试图创建一个简单的方法来在渲染图像时拉伸图像。但是因为 opengl 使用这些三角形而不是矩形,所以有点搞砸了。

在此输入图像描述

正如你所看到的,三角形的两个部分被不同程度地拉伸。我为此的代码如下:

public static void drawTexture(Texture texture, float x, float y, float x2, float y2, float x3, float y3, float x4, float y4){
    if(cantRender()) return;
    polyBatch.begin();
    float[] vertices = new float[20];

    float color = Color.WHITE.toFloatBits();
    int idx = 0;
    vertices[idx++] = x;
    vertices[idx++] = y;
    vertices[idx++] = color;
    vertices[idx++] = 0;
    vertices[idx++] = 1;

    vertices[idx++] = x2;
    vertices[idx++] = y2;
    vertices[idx++] = color;
    vertices[idx++] = 1;
    vertices[idx++] = 1;

    vertices[idx++] = x3;
    vertices[idx++] = y3;
    vertices[idx++] = color;
    vertices[idx++] = 1;
    vertices[idx++] = 0;

    vertices[idx++] = x4;
    vertices[idx++] = y4;
    vertices[idx++] = color;
    vertices[idx++] = 0;
    vertices[idx++] = 0;
    polyBatch.draw(texture, vertices, 0, 20);


    polyBatch.end();
}

Renderer.drawTexture(testTexture, 100, 100, 500, 100, 400, 500, 200, 500);
Run Code Online (Sandbox Code Playgroud)

我在互联网上找到了修复程序,但我不知道如何使其与 libgdx 结合使用。这是我找到的文章: http: //www.xyzw.us/~cass/qcoord/。问题是 libgdx 似乎并不像文章中描述的那样支持所有 4 个变量。