I’m trying to load a texture over a height map and struggling. I’ve got my texture stored as a jpg and have loaded it. This is working as I’ve applied the texture to something else as a test, however I can’t get it to work properly on my height map
public void renderHeightMap(GL gl, byte[] pheightMap) {
gl.glBindTexture(GL.GL_TEXTURE_2D, land[0]);
gl.glBegin(renderType);
for(int X = 0; X < (MAP_SIZE - STEP_SIZE); X += STEP_SIZE) {
for(int Y = 0; Y < (MAP_SIZE - STEP_SIZE); Y += STEP_SIZE) {
int x = X;
int y = height(pheightMap, X, Y);
int z = Y;
// setVertexColor(gl, pheightMap, x, z);
gl.glTexCoord2i(0,0);
gl.glVertex3i(x, y, z);
x = X;
y = height(pheightMap, X, Y + STEP_SIZE);
z = Y + STEP_SIZE;
// setVertexColor(gl, pheightMap, x, z);
gl.glTexCoord2i(1,0);
gl.glVertex3i(x, y, z);
x = X + STEP_SIZE;
y = height(pheightMap, X + STEP_SIZE, Y + STEP_SIZE);
z = Y + STEP_SIZE;
// setVertexColor(gl, pheightMap, x, z);
gl.glTexCoord2i(1,1);
gl.glVertex3i(x, y, z);
x = X + STEP_SIZE;
y = height(pheightMap, X + STEP_SIZE, Y);
z = Y;
// setVertexColor(gl, pheightMap, x, z);
gl.glTexCoord2i(0,1);
gl.glVertex3i(x, y, z);
}
}
gl.glEnd();
gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
That is the code used for rendering my height map. I’ve added the TexCoord commands and the texture is being applied but for every single square being drawn. I want to stretch the texture over the entire map.
How?
Thanks