This example imports a scene file, renders the scene, and writes the image to disk.
To render a scene, you have to provide some rendering infrastructure for the Iray SDK API. Basically, you have to provide buffers where the rendered image is written to. These buffers are defined by the interfaces mi::neuraylib::IRender_target, mi::neuraylib::ICanvas, and mi::neuraylib::ITile.
This example demonstrate a very simple implementation of the mi::neuraylib::IRender_target interface. It makes use of default implementations for the interfaces mi::neuraylib::ICanvas and mi::neuraylib::ITile (the next example demonstrates how to use custom implementations of these interfaces). The implementation of the render target shown here has only a single canvas consisting of a single tile.
The mi::neuraylib::IDatabase interface is one of the central interface classes that become available after the Iray SDK has been started. Using this interface, you can access the scene database. In particular, you can either access the global scope or create your own scope. The mi::neuraylib::IScope interface allows you to create transactions, which are required for all operations that access the database.
This example uses the database interface to access the global scope and creates a transaction in the global scope. All transactions need either to get committed or aborted. By committing a transaction, all changes (if any) will become visible for subsequently started transactions. Aborting a transaction discards any changes made in that transaction.
The import of files is handled by the API component mi::neuraylib::IImport_api. The actual import is done by the method mi::neuraylib::IImport_api::import_elements(). The result of the import operation is described by the interface mi::neuraylib::IImport_result. This interface provides among other things the method mi::neuraylib::IImport_result::get_error_number() to retrieve the resulting error number. This error number is 0 in case of success, all other numbers indicate failures.
The example also creates an instance of the mi::neuraylib::IScene interface, which is later used for rendering. To this end, the name of the root group, the camera, and the options are set in the scene. These names are available from the import result.
Rendering a scene requires a render target and a render context. The render target has to be provided by you, as explained earlier in this example. The render context can be obtained from mi::neuraylib::IScene::create_render_context().
Source Code Location: examples/example_render_target_simple.h
Source Code Location: examples/example_rendering.cpp