I'm almost there. I found the way to create a square grid that adapts to the number of frames, and I can use this info to control the mesh and to feed the texture (as in the "TinyVideo" recipe)
Now I'm stuck in correctly set the vertical position of the frames in the matrix that will become the texture. It seems I can't figure out the correct math.
Please have a look at this patch. Try clicking a few times. It seems to work somehow for some values, but at the beginning it outputs values too high for the "row" coordinates, while the "columns" are set correctly.
Any hint would be appreciated.