Alright, for some reason my mapping of this terrain just isn't working out.
Here is where I'm loading the texture...
void Terrain::loadTextures()
{
if (!(m_targaLoader->LoadTarga(&m_ground, "grass.tga"))) exit(1);
glGenTextures(1, &m_ground.id);
glBindTexture(GL_TEXTURE_2D, m_ground.id);
glTexImage2D(GL_TEXTURE_2D, 0, 4, m_ground.width, m_ground.height, 0, m_ground.type, GL_UNSIGNED_BYTE, m_ground.image_data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
}
We can take for granted that the targa loader works because I tested it in a program that was already working, and it was fine. Same for the image itself.
Here's where the drawing gets done.
void Terrain::draw()
{
glColor3f(1.0f, 1.0f, 1.0f);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_ground.id);
for (int row = 0; row < m_mapWidth; row++)
{
for (int column = 0; column < m_mapHeight; column++)
{
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 1.0f); glVertex3f(m_tileWidth * column, -(m_tileHeight * row), m_zPos + m_heightMap[4 * ((row * m_mapWidth) + column)]);
glTexCoord2f(0.0f, 0.0f); glVertex3f(m_tileWidth * column, -(m_tileHeight + (m_tileHeight * row)), m_zPos + m_heightMap[4 * ((row * m_mapWidth) + column) + 1]);
glTexCoord2f(1.0f, 0.0f); glVertex3f(m_tileWidth + (m_tileWidth * column), -(m_tileHeight + (m_tileHeight * row)), m_zPos + m_heightMap[4 * ((row * m_mapWidth) + column) + 2]);
glTexCoord2f(1.0f, 1.0f); glVertex3f(m_tileWidth + (m_tileWidth * column), -(m_tileHeight * row), m_zPos + m_heightMap[4 * ((row * m_mapWidth) + column) + 3]);
glEnd();
}
}
}
Everything is white, it's not loading the texture. Can't quite figure out why, as I've done this before... I must be missing something small...