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

前端 未结 2 1981
借酒劲吻你
借酒劲吻你 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:16

    I don't know if you've considered this, but if your .obj files won't change in your application, you can format them as objective-C arrays and compile them directly with your code.

    0 讨论(0)
  • 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.
    0 讨论(0)
提交回复
热议问题