I'm drawing some "simple" 2D graphics using OpenGL ES, glDrawArrays and GL_TRIANGLE_STRIP.
I'm writing a function whose purpose is to take one 13x13 point (or other arbitrarily sized) texture and output it in specified number of columns and rows. So for 2 rows and 3 columns that would mean an area covered with 6 tiles over 26x39 points. The first row works well with the below code but as soon as I specify 2 or more rows there's just garbled output.
for (int row = 0; row < heightInTiles; row++) {
for (int col = 0; col < widthInTiles; col++) {
vertexIndexOffset += 8;
startX = (GLshort)(col * TEXTUREWIDTH);
startY = (GLshort)(row * TEXTUREHEIGHT);
// Vertices
vertices[vertexIndexOffset] = startX; // 1
vertices[vertexIndexOffset + 1] = startY; //0.0;
vertices[vertexIndexOffset + 2] = startX; // 2
vertices[vertexIndexOffset + 3] = startY + (GLshort)TEXTUREHEIGHT;
vertices[vertexIndexOffset + 4] = (GLshort)(startX + TEXTUREWIDTH); // 3
vertices[vertexIndexOffset + 5] = startY;
vertices[vertexIndexOffset + 6] = (GLshort)(startX + TEXTUREWIDTH); // 4
vertices[vertexIndexOffset + 7] = startY + (GLshort)TEXTUREHEIGHT;
// Texture coords
uvs[vertexIndexOffset] = WRESULT; // 1
uvs[vertexIndexOffset + 1] = 0;
uvs[vertexIndexOffset + 2] = WRESULT; // 2
uvs[vertexIndexOffset + 3] = HRESULTNEXT;
uvs[vertexIndexOffset + 4] = WRESULTNEXT; // 3
uvs[vertexIndexOffset + 5] = 0;
uvs[vertexIndexOffset + 6] = WRESULTNEXT; // 4
uvs[vertexIndexOffset + 7] = HRESULTNEXT;
}
}