There really isn’t enough information shared clearly to help you here.
Setting your vertex buffer to null before drawing i imagine is a typo.
You say you have 4096 vertices but are trying to draw quads from them?
That would imply that this is already a laid out 2d grid of vertices or its already ready as 4096/4 quads but how exactly is this laid out?
Say that every 4 vertices is a quad that you load and you wish to index them?
In that case you loop like so.
int verticesInaQuad = 4;
int indicesInaQuad =6;
int verticeCount = 4096;
int quadCount = verticeCount / verticesInaQuad;
int indicesCount = quadCount * indicesInaQuad ;
short[] indices = new short[indicesCount];
int indexIndicer =0;
// We do a for loop and increment thru all the vertexs.
// We are incrementing the offset by a quads worth of vertices each time (verticesInaQuad) or by 4 verts.
for(int verticeIndicer = 0; verticeIndicer < vertexs.Length; verticeIndicer += verticesInaQuad )
{
indices[indexIndicer + 0] = (short)(verticeIndicer + 0);
indices[indexIndicer + 1] = (short)(verticeIndicer + 1);
indices[indexIndicer + 2] = (short)(verticeIndicer + 2);
indices[indexIndicer + 3] = (short)(verticeIndicer + 2);
indices[indexIndicer + 4] = (short)(verticeIndicer + 3);
indices[indexIndicer + 5] = (short)(verticeIndicer + 0);
// We initialized 6 indices, a quads worth (indicesInaQuad) so we increment our counter.
indexIndicer += indicesInaQuad;
// The for loop will continue till its accounted for all the vertices.
// At which time we will have filled our index array.
}
There is like 3 separate examples or links to examples for how to tile map in this post if it helps.
I put 2 on there myself the second one is better then the first one i posted.
nkasts is excellent and probably the fastest overall, but might be a bit tough to understand.