Tex coord gen on a grid. please help..

I’m using vertex arrays to handle a grid of WIDTH * HEIGHT faces made of triangles…
(a really big tic-tac-toe board)

Can any of you offer tips on generating texture coords for this map? All the vertex data is stored in a one dimensional array of size WIDTH * HEIGHT.

I’m looking for a simple generic loop that can store all the coords needed to map a single texture across the entire grid…I’m not even sure how many texture coords there will be.

I can do this if I store my vertex values in
a 2 dimensional array and draw the grid with Quads in one big loop. I’m trying to use a more efficient way of doing this but I can’t seem to visualize it in this manner…

I suspect this is simple. Any Ideas?

Yes, it’s easy.
To get a scaling value, just divide 1.0f by the width of the grid (number of grid elements, not world width).
Then as you traverse the grid, creating your vertex array, just multiply the current grid x by the scaling value, and insert the result as your ‘s’ coordinate.
Do the same for the height and ‘t’ coordinate.
Just in case you don’t know, to access an element in a one dimensional array as if it was a two dimensional array, use the following formula :-
contents = array[(ywidth)+x];
And if each of your elements in the array has more than one component (say, x,y,z,s,t), then your formula should be this:-
contents = array[(y