What could be the purpose of a header file with raw data?

ε祈祈猫儿з 提交于 2019-12-12 15:14:56

问题


Decided to check out some code other than my own, Quake I was the choice. The first file I click on is filled with nothing but raw data and the only comments are the GPL. I am guessing it is an array containing normal vectors? Regardless of what its purpose was, what confuses me is what it is doing in a header file anorms.h. I am wondering what could be the purpose of doing this?

The other source, actual code, feels fairly complicated to me. As a novice programmer I probably just need to spend more time at it.


回答1:


Guessing by the looks, it's indeed a normal array used somewhere in the game.

In older days, pretty much every game content was hardcoded; now you can simply open a file and load the data, because the HDDs (and more often SSDs) got so much faster.

Older games were also compiled as plain C executable; in modern IDEs such as Visual Studio (or pretty much anything, really), you can easily compile arbitrary data into the .exe in form of resources.

All that being said, it's simply legacy cruft and I shouldn't be very concerned with it.


Sample usage:

struct Vec { float x,y,z };
Vec arr[] = {
    #include "anorms.h"
};


来源:https://stackoverflow.com/questions/17770571/what-could-be-the-purpose-of-a-header-file-with-raw-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!