所以,我只是想为两个与视口大小相同的三角形绘制纹理,但它会破坏图像并使其扭曲,我尝试调整图像文件的大小和所有内容,但似乎没有任何效果。下面是映射纹理并绘制三角形的代码。
public void Render()
{
Texture texture = _textureManager.Get("splash");
Gl.glEnable(Gl.GL_TEXTURE_2D);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture.Id);
double height = 720;
double width = 1280;
double x = 0;
double y = 0;
double z = 0;
float topUV = 0;
float bottomUV = 1;
float leftUV = 0;
float rightUV = 1;
Gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
Gl.glBegin(Gl.GL_TRIANGLES);
{
Gl.glTexCoord2d(leftUV, topUV);
Gl.glVertex3d(x - width, y + height, z);
Gl.glTexCoord2d(rightUV, topUV);
Gl.glVertex3d(x + width, y + height, z);
Gl.glTexCoord2d(leftUV, bottomUV);
Gl.glVertex3d(x - width, y - height, z);
Gl.glTexCoord2d(rightUV, topUV);
Gl.glVertex3d(x + width, y + height, z);
Gl.glTexCoord2d(rightUV, bottomUV);
Gl.glVertex3d(x + width, y - height, z);
Gl.glTexCoord2d(leftUV, bottomUV);
Gl.glVertex3d(x - width, y - height, z);
}
Gl.glEnd();
}
这是原始图像:
结果如下:
图像为 1920 x 1080,视口为 1280 x 720,但我不太确定这是否重要,因为我尝试调整图像大小但似乎没有任何效果。