如何将pyopengl纹理大小缩放为pygame窗口大小?

问题描述 投票:-1回答:1

Windows大小:640 * 480

纹理尺寸:1280 * 720

您好,如何将纹理缩放到pygame窗口?

pygame pyopengl
1个回答
0
投票

您已设置正交投影:

glOrtho(0, self.windowWidth, self.windowHeight, 0, -1, 1)

如果要使纹理填充整个窗口,则必须绘制与正交投影和纹理坐标形式(0,0)到(1,1)相对应的四边形:

glEnable(GL_TEXTURE_2D)

glBegin(GL_QUAD)

glTexCoord2f(0, 0)
glVertex2f(0, 0)

glTexCoord2f(1, 0)
glVertex2f(self.window.Width, 0)

glTexCoord2f(1, 1)
glVertex2f(self.window.Width, self.windowHeight)

glTexCoord2f(0, 1)
glVertex2f(self.windowHeight)

glEnd()
© www.soinside.com 2019 - 2024. All rights reserved.