Python Opengl 纹理重复
我是 opengl 的初学者。我正在尝试在 GL_QUADS 上重复纹理。
的代码,
file = os.path.join('image','texture.png')
surface = image.load(file)
self.t1 = surface.image_data.create_texture(image.Texture)
glBindTexture(GL_TEXTURE_2D, t1.id)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
到目前为止,这是加载纹理和绘制
glBindTexture(GL_TEXTURE_2D, self.t1.id)
glBegin(GL_QUADS)
glTexCoord2f(0.0, 0.0); glVertex3f(0, 0, 0)
glTexCoord2f(1.0, 0.0); glVertex3f(self.width, 0, 0)
glTexCoord2f(1.0, 1.0); glVertex3f(self.width, self.height, 0)
glTexCoord2f(0.0, 1.0); glVertex3f(0, self.height, 0)
glEnd()
当 self.width 和 self.height 更改时,纹理会被拉伸和扭曲。
如何重复纹理? 如果我做错了,请原谅我。
谢谢...
I am a beginner in opengl. I am trying to repeat the texture on the GL_QUADS.
So far Here is the code for loading the texture,
file = os.path.join('image','texture.png')
surface = image.load(file)
self.t1 = surface.image_data.create_texture(image.Texture)
glBindTexture(GL_TEXTURE_2D, t1.id)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
and drawing
glBindTexture(GL_TEXTURE_2D, self.t1.id)
glBegin(GL_QUADS)
glTexCoord2f(0.0, 0.0); glVertex3f(0, 0, 0)
glTexCoord2f(1.0, 0.0); glVertex3f(self.width, 0, 0)
glTexCoord2f(1.0, 1.0); glVertex3f(self.width, self.height, 0)
glTexCoord2f(0.0, 1.0); glVertex3f(0, self.height, 0)
glEnd()
When self.width and self.height are changed, the texture is stretched and distorted.
How can I repeat the texture?
Pardon me if i did wrong.
Thank you...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过使用 [0,1] 范围之外的纹理坐标 (glTexCoord)。
By using texture coordinates (glTexCoord) outside the range [0,1].