I've just finished my heightmap, rendered with triangle strip per row. My solution was:
height=data[k];
coords.push_back((float)col);
coords.push_back((float)(height/heightscale));
coords.push_back((float)row);
k+=3; //red is enough, im using greyscale
and the indexes for the strip:
for(int row=0;row<infoheader.biHeight-1;row++)
{
for(int col=0;col<infoheader.biWidth;col++)
{
indexes.push_back((row+1)*infoheader.biWidth+col);
indexes.push_back(row*infoheader.biWidth+col);
}
}
I use a VertexArrayObject and drawelements in a loop per row. Now I'm using it with a single shader coloring based on height, but i want it to combine with textures(also based on height but still not thats my problem)
I want to put the texture on 2 triangles forming a quad,
0,1-1,1
| /|
| / |
|/ |
0,0-1,0
...but I really have no idea how to implement it, I've read all topics about this but they didn't work(only solid color appeared or the whole map was black).
So, is it possible to make an array only for the first "quad" (2 triangles) and it textures the whole map based on it by for example increasing the indexes? If yes how can i do this. And one more: how can I put 1 texture on top of the whole map, scaling it over the terrain.
I could do them with a single quad or a triangle strip with 2 triangles, but not for ~3 000 000 triangles.
The main problem is the indexing, because if I'm right, it draws not only the vertice position based on the indexes but the colors and texture coordinates.
my map: http://kepfeltoltes.hu/view/130827/1094341850Untitled_www.kepfeltoltes.hu_.png I know its a pretty "overasked" question but I still have not found the right way. EDIT: I want to tile textures.