I have a texture with a 3x9 repeating section. I don't want to store the tesselated 1920x1080 image that I have for the texture, I'd much rather generate it in code so that it can be applied correctly at other resolutions. Any ideas on how I can do this? The original texture is here: http://img684.imageshack.us/img684/6282/matte1.png
I know that the texture is a non-power-of-2, so I have to do the repeating within a shader, which I do:
uniform sampler2D tex;
varying vec2 texCoord;
void main() {
gl_FragColor = texture2D(tex, mod(texCoord, vec2(3.0, 9.0)) * vec2(0.75, 0.5625));
}
This is how I'm drawing the quad:
glBegin(GL_QUADS)
glColor4f(1.0, 1.0, 1.0, 1.0)
glMultiTexCoord2f(GL_TEXTURE1, self.widgetPhysicalRect.topLeft().x(), self.widgetPhysicalRect.topLeft().y())
glVertex2f(-1.0, 1.0)
glMultiTexCoord2f(GL_TEXTURE1, self.widgetPhysicalRect.topRight().x(), self.widgetPhysicalRect.topRight().y())
glVertex2f(1.0, 1.0)
glMultiTexCoord2f(GL_TEXTURE1, self.widgetPhysicalRect.bottomRight().x(), self.widgetPhysicalRect.bottomRight().y())
glVertex2f(1.0, -1.0)
glMultiTexCoord2f(GL_TEXTURE1, self.widgetPhysicalRect.bottomLeft().x(), self.widgetPhysicalRect.bottomLeft().y())
glVertex2f(-1.0, -1.0)
glEnd()
Any ideas would be greatly appreciated.
Thanks!