LightsprintSDK 2021.08.08
rr_io Namespace Reference

Functions

void RR_IO_API registerIO (int argc, char **argv, unsigned step=0)
 
void RR_IO_API isolateIO (int argc, char **argv)
 

Detailed Description

LightsprintIO - import and export of scenes, textures, vertex buffers, videos, materials.

Function Documentation

◆ registerIO()

void RR_IO_API rr_io::registerIO ( int  argc,
char **  argv,
unsigned  step = 0 
)

Registers callbacks for loading and saving scenes, textures and videos in ~75 fileformats (Supported formats).

After registering loaders and savers, use

Parameters
argcCopy of your main() argument. Used only for import isolation on non-Windows platforms, can be 0 otherwise.
argvCopy of your main() argument. Used only for import isolation on non-Windows platforms, can be nullptr otherwise.
stepKeep empty. Only if you need to register your own isolated loader for fileformat already supported by LightsprintIO, all without modifying LightsprintIO, call registerIO(1); registerYourLoader(); registerIO(2); isolateIO();

◆ isolateIO()

void RR_IO_API rr_io::isolateIO ( int  argc,
char **  argv 
)

Isolates scene loaders and saver, makes them run in separated processes.

Isolation increases robustness of main application, by protecting it against various ill effects of low quality importers and exporters. Although no problems are known within Lightsprint's importers/exporters, imagine that one day in future, you run e.g. into memory corruption problem. Without isolated importers, any part of codebase can be responsible for corruption, it's tough problem to debug. With isolation, importers/exporters are ruled out as a source of problem (they make more than 50% of lines of code in Lightsprint SDK).

When isolating loaders/savers, your program startup should look like

register_your_non_isolated_loaders();
register_your_isolated_loaders();
void RR_IO_API isolateIO(int argc, char **argv)
Isolates scene loaders and saver, makes them run in separated processes.
void RR_IO_API registerIO(int argc, char **argv, unsigned step=0)
Registers callbacks for loading and saving scenes, textures and videos in ~75 fileformats (Supported ...

Isolation works by rerunning our own executable as a separated process with special arguments each time scene needs to be imported. This function checks for special arguments and if found, it converts the scene to .rr3 and exits. Therefore you should run this function as soon in your application as possible (before all slow steps), and you should let it exit, if it needs to. Caller then imports newly created .rr3, and deletes it. If isolated process fails to import the scene or write it back as .rr3, caller tries to import the scene without isolation.

.rr3 fileformat is never isolated, it is used for transferring data between processes.

Parameters
argcCopy of your main() argument. Used only on non-Windows platforms, can be 0 otherwise.
argvCopy of your main() argument. Used only on non-Windows platforms, can be nullptr otherwise.