I'm attempting to texture a model of a wooden table with a wood bitmap i've found and resized, however the issue I have encountered is that each quad making up the surface of the table is clearly visible when the texture is applied. How do I make it look like one smooth texture?
void Table::DrawTableTop()
{
glPushMatrix();
//draw tabletop
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texid);
glBegin(GL_QUADS);
glMaterialfv(GL_FRONT, GL_SPECULAR, static_cast<GLfloat*>(specular));
glMaterialf(GL_FRONT, GL_SHININESS, static_cast<GLfloat>(shininess));
float unitx = 1.0f / (float)(xsize * 2 + 1);
float unity = 1.0f / (float)(zsize * 2 + 1);
for (int i = -xsize; i <= xsize; i++)
{
for (int j = -zsize; j <= zsize; j++)
{
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, static_cast<GLfloat*>(wDiffuse));
//top
glNormal3f(0.0f, 1.0f, 0.0f);
if (tex) glTexCoord2f(unitx * static_cast<float>(i + 20 + 1), unity * static_cast<float>(j + 10));
glVertex3f(scale[0] * static_cast<float>(i) + scale[0], 0, scale[2] * static_cast<float>(j) + scale[2]);
if (tex) glTexCoord2f(unitx * static_cast<float>(i + 20 + 1), unity * static_cast<float>(j + 10 + 1));
glVertex3f(scale[0] * static_cast<float>(i) + scale[0], 0, scale[2] * static_cast<float>(j));
if (tex) glTexCoord2f(unitx * static_cast<float>(i + 20), unity * static_cast<float>(j + 10 + 1));
glVertex3f(scale[0] * static_cast<float>(i), 0, scale[2] * static_cast<float>(j));
if (tex) glTexCoord2f(unitx * static_cast<float>(i + 20 ), unity * static_cast<float>(j + 10));
glVertex3f(scale[0] * static_cast<float>(i), 0, scale[2] * static_cast<float>(j) + scale[2]);
}
}
glEnd();
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
glPopMatrix();
The values of xsize and zsize are 20 and 10, respectively
I would like the texture to appear as if it was loaded on to one large quad, but obviously using multiple quads for improved lighting etc..
This is what the textured image looks like: