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...
How can I repeat the texture? Pardon me if i did wrong.
By using texture coordinates (glTexCoord) outside the range [0,1].