Fastest way to load arrays of vertices and face indices into OpenGL-ES?

前端 未结 2 1982
借酒劲吻你
借酒劲吻你 2021-01-14 05:33

I\'m trying to load .obj files that I\'ve formatted into:

vertexX vertexY vertexZ normalX normalY normalZ

and:

index1 index         


        
2条回答
  •  有刺的猬
    2021-01-14 06:24

    The best practice in game industry is to keep all models data in binary format, so you can very fast load whole non-interleaved blocks of memory that can be represented as vertices, normals or anything else. All you need for this - make small command line tool for converting text .obj files into your own binary file.

    Also:

    • Did you try to do text loading with stdio library, not stl ifstream?
    • Maybe try to read all the text data once and fill arrays from memory, not from filesystem?
    • how much parts in file do you have? Each resize of std::vector leads to new allocation and copying. Try to reserve space in std::vector, if you know desired volume before.

提交回复
热议问题