Here is an overview of how you would go about producing an glTF asset from your data.
First, write your index and vertex data arrays into files.
- They can be all the same file, but for the conceptually simplest case, make them separate files.
- You write the integers or floats as raw bytes, not text or any other format, with no metadata. This is just like you would pass the same data to a GPU buffer, except that they must be little endian integers (that is, swap the order of the bytes in each integer if your program is compiled for a big-endian processor; this is rare but possible).
Your “pixels” — a texture for the object, I assume — should be written into a image file (PNG, JPEG, or a compressed texture format specified in a glTF extension).
Then, you create the glTF file itself, which is a JSON structure that describes how to use the contents of the above binary files.
The glTF file will specify that the indices are indices, and which one of the files contains vertex positions and which one contains normals, using “attributes” and “accessors”, and put them together into a “mesh”. It may also contain “node”, “scene”, “camera”, and “animation” objects, describing more about what to do with the mesh, but these are all optional.
There are a lot of details to glTF, but this is fundamentally all there is to it: write out your numerical data to binary files, then write out the glTF that describes the structure of those files. (It's also possible to pack all the data into a single .glb file.)
Now that I've given you the big picture, I hope you will be able to able to figure out all the concrete details by following the glTF specification and checking your work with a glTF scene viewer and a validator. When I was doing this, I found the glTF Tools Extension for Visual Studio Code very useful — it does both preview and validation.