Alright, so in my engine there is a texture 512x512 that is being used on a map of points 512x512. The problem lies when the heights of the points are changed, the texture seems to not stetch to fit the change in height. The texture then appears see through and you can see the rest of the map. Is there a specific property I need to set for the texture?
The rendering code:
gl.glNewList(listNumber, GL.GL_COMPILE);
texture.enable();
texture.bind();
gl.glBegin(GL.GL_TRIANGLES);
for(int z = 0; z < 512; z++)
{
for(int x = 0; x < 512; x++)
{
gl.glTexCoord2f((float)x/texture.getWidth(), (float)z/texture.getHeight());
gl.glVertex3f(x, (int)points[x][z], z);
gl.glTexCoord2f((float)(x+1)/texture.getWidth(), (float)z/texture.getHeight());
gl.glVertex3f(x+1, (int)points[x+1][z], z);
gl.glTexCoord2f((float)x/texture.getWidth(), (float)(z+1)/texture.getHeight());
gl.glVertex3f(x, (int)points[x][z+1], z+1);
// ---------------------------------
gl.glTexCoord2f((float)x/texture.getWidth(), (float)(z+1)/texture.getHeight());
gl.glVertex3f(x, (int)points[x][z+1], z+1);
gl.glTexCoord2f((float)(x+1)/texture.getWidth(), (float)z/texture.getHeight());
gl.glVertex3f(x+1, (int)points[x+1][z], z);
gl.glTexCoord2f((float)(x+1)/texture.getWidth(), (float)(z+1)/texture.getHeight());
gl.glVertex3f(x+1, (int)points[x+1][z+1], z+1);
}
}
gl.glEnd();
texture.disable();
gl.glEndList();
Previews of the problem:
You can see what it should look like in the wireframe:
And what it looks like with the texture. You can see the rest of the map because the texture is not stretching (or whatever the problem is)
Thanks in advance