Domanda

The purose of my question is, that I want .obj Files (from blender) to be available in my (opengl) program without having these visible on my hard drive. So, I imagined that it could be possible to link these .obj files into my program file and read from them. How this could be done or is it not possible? What could I do else?

Remark: the .obj files contain 3d meshes which shouldn't be editable by the user and I don't want to hard code these .obj files into a .cpp file. Working on a osx mavericks + eclipse.

È stato utile?

Soluzione

On Windows, you can embed a file into the resources and then load them from within your software.

Altri suggerimenti

The purose of my question is, that I want .obj Files (from blender) to be available in my (opengl) program without having these visible on my hard drive.

That's normally not a good idea. Image you're releasing a new version of the program, for which you have an Internet updater. If you separate the data from the program, you only have to transfer a small executable binary file. If you embed all the data into the executable every update forces you to distribute a large package.

Of course if this is some data on which your program strongly depends on and which may change between versions, that embedding it makes sense; for example configuration images of an FPGA which is connected to a microcontroller's memory interface and where the microcontroller program uses memory mapped I/O into the FPGA and the FPGA image hence must match the program.

So, I imagined that it could be possible to link these .obj files into my program file and read from them.

Yes, this is certainly possible. The usual approach is to translate the file into a C array using a tool like bin2c and compile the generated file along with your program. However keep in mind that C compilers may have an upper limit on the size an array initializers.

What could I do else?

Don't be unreasonable. If the user can change the .obj file, does so, things break and the user is complaining to you, you can tell him, that after he made the changes it's upon his or her own responsibility. The user is not your enemy.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top