neuray Services API Programmer's Manual

mi::nservices::IRender_loop Class Reference

[Render Loops]

Description

Represents a render loop. Instances of this class are created via mi::nservices::IRender_loop_manager::create_render_loop. They should then be initialized and started. Once started the render loop continues in a separate thread. Subsequent commands can then retrieve this render loop via mi::nservices::IRender_loop_manager::get_render_loop an then manipulate the loop.

Public Member Functions

virtual void cancel_render( mi::Sint32 cancel_level) =0
Cancels any ongoing render. More...
virtual void end_loop() =0
Ends the loop. More...
virtual mi::neuraylib::ICanvasget_canvas() =0
Retrieves the most recently render canvas.
virtual mi::Sint32 get_last_render_result() =0
Returns the result of the last render.
virtual const char* get_name() const =0
returns the name of the render loop
virtual const mi::IStringget_parameter( const char* key) =0
Gets a render loop parameter from the render handler. More...
virtual mi::Float64 get_progress( const char* area) const =0
Returns the progress of the render being performed by the render context used by this render loop. More...
virtual const mi::IDataget_render_context_option( const char* key) const =0
Returns the value of a render-context option. More...
template< class T>const T* get_render_context_option( const char* name) const
Returns the value of a render-context option. More...
virtual mi::Uint32 get_render_loop_counter() const =0
Returns the current render loop counter value. More...
virtual mi::Sint32 initialize( ICommand_context_neuray* context, const char* scene_name, mi::Uint32 timeout) =0
Initializes the render loop with the scene to render. More...
virtual bool  is_paused() const =0
Returns if the loop is currently paused or not. More...
virtual void keep_alive() =0
Restarts the expiry timer.
virtual mi::Sint32 register_render_counter_callback( IRender_loop_render_counter_callback* callback, mi::Uint32 counter_value) =0
Registers a callback to be triggered at the given render counter. More...
virtual void set_dirty() =0
Informs the loop that the scene is dirty. More...
virtual mi::Sint32 set_parameter( const char* key, const char* value) =0
Sets a render loop parameter on the render handler. More...
virtual void set_paused( bool paused) =0
Sets the paused flag on the render loop. More...
virtual mi::Sint32 set_render_context_option( const char* key, const mi::IData* value) =0
Sets the value of a render-context option. More...
virtual mi::Sint32 start_loop() =0
Starts the render loop in another thread. More...

Member Functions

virtual void mi::​nservices::​IRender_loop::cancel_render( mi::Sint32 cancel_level) [pure virtual]

Cancels any ongoing render.

Parameters

cancel_level
The intention of the cancel level is to specify how fast the rendering should be finished, but currently this value is not yet taken into account.
virtual void mi::​nservices::​IRender_loop::end_loop() [pure virtual]

Ends the loop. Note that this call will block until the render loop thread quits.

virtual mi::neuraylib::ICanvas* mi::​nservices::​IRender_loop::get_canvas() [pure virtual]

Retrieves the most recently render canvas.

virtual mi::Sint32 mi::​nservices::​IRender_loop::get_last_render_result() [pure virtual]

Returns the result of the last render.

virtual const char* mi::​nservices::​IRender_loop::get_name() const [pure virtual]

returns the name of the render loop

virtual const mi::IString* mi::​nservices::​IRender_loop::get_parameter( const char* key) [pure virtual]

Gets a render loop parameter from the render handler. This call is passed through to IRender_loop_handler::get_parameter().

Parameters

key
the parameter key

Returns

the value of parameter key or NULL if key does not exist

virtual mi::Float64 mi::​nservices::​IRender_loop::get_progress( const char* area) const [pure virtual]

Returns the progress of the render being performed by the render context used by this render loop. The type of progress returned is selected by the area parameter.

Parameters

area
This describes the area where progress has been made. The following values are currently supported depending on the renderer used:
  • progression (iray/hybrid/rt_bsp in progressive rendering mode) Estimated progression between 0 and 1, indicating progress until error threshold is reached.
  • error (iray/hybrid/rt_bsp in progressive rendering mode) Current estimate of per-pixel error.
  • iteration (iray/hybrid) Number of iterations accumulated in the current progression.

Returns

Some value which gives information about how much the work progressed. The interpretation depends on the area string. In some areas it might be a percentage, in some it might be an absolute value. Will be -1 if area is NULL , an empty string or an unknown value.

virtual const mi::IData* mi::​nservices::​IRender_loop::get_render_context_option( const char* key) const [pure virtual]

Returns the value of a render-context option.

See also:

set_option()

Returns

The value of the option, or NULL in case of failure, e.g, if there is no such option.

template< class T>

const T* mi::​nservices::​IRender_loop::get_render_context_option( const char* name) const [inline]

Returns the value of a render-context option.

See also:

set_render_context_option()

This templated member function is a wrapper of the non-template variant for the user's convenience. It eliminates the need to call mi::base::IInterface::get_interface(const Uuid &) on the returned pointer, since the return type already is a pointer to the type T specified as template parameter.

Parameters

name
The name of the option.

Returns

The value of the option, or NULL in case of failure, e.g, if there is no such option.

virtual mi::Uint32 mi::​nservices::​IRender_loop::get_render_loop_counter() const [pure virtual]

Returns the current render loop counter value. This represents the absolute number of times that the render loop has looped. This can be used with the register_render_counter_callback to request the render at a given counter.

Returns

The render loop counter.

virtual mi::Sint32 mi::​nservices::​IRender_loop::initialize( ICommand_context_neuray* context, const char* scene_name, mi::Uint32 timeout) [pure virtual]

Initializes the render loop with the scene to render. This must be called before the loop is started. Other parameters should be set using the set_parameter method before calling this method. NB: the render loop may not retain the scene passed into it.

Parameters

context
the command context which created this loop.
scene_name
the name of the scene to render.
timeout
the render loops timeout value in seconds.

Returns

  • 0 - success
  • -1 - failure
  • -2 - invalid parameters
  • -3 - unable to find scene called scene_name
  • -4 - unable to create render context
  • -5 - no underlying render handler
  • -6 - scene not ready to render (root group, camera or options missing)
virtual bool mi::​nservices::​IRender_loop::is_paused() const [pure virtual]

Returns if the loop is currently paused or not.

Returns

True if the loop is currently paused.

virtual void mi::​nservices::​IRender_loop::keep_alive() [pure virtual]

Restarts the expiry timer.

virtual mi::Sint32 mi::​nservices::​IRender_loop::register_render_counter_callback( IRender_loop_render_counter_callback* callback, mi::Uint32 counter_value) [pure virtual]

Registers a callback to be triggered at the given render counter. If a render counter of 0 (zero) is given then the render loop will assume the next render. If the callback is needs a render, then the values on the callback will be used to create a buffer before calling the callback.

Parameters

callback
The callback handler.
counter_value
The goal counter value for when the callback will be triggered.

Returns

  • 0: Success.
  • -1: callback is null or empty.
  • -2: counter_value is lower than or equal to the current render loop counter (would never trigger).
virtual void mi::​nservices::​IRender_loop::set_dirty() [pure virtual]

Informs the loop that the scene is dirty. This enables rendering to begin again if it has converged.

virtual mi::Sint32 mi::​nservices::​IRender_loop::set_parameter( const char* key, const char* value) [pure virtual]

Sets a render loop parameter on the render handler. This call is passed through to IRender_loop_handler::set_parameter().

Parameters

key
the parameter key
value
the parameter value

Returns

  • 0 - success
  • -1 - failure
  • -2 - invalid parameter, NULL or empty key string
  • -3 - unsupported key
  • -4 - value could not be converted to required type
virtual void mi::​nservices::​IRender_loop::set_paused( bool paused) [pure virtual]

Sets the paused flag on the render loop. Pausing the loop prevents further rendering, it will not pause the current frame being rendered however.

Parameters

paused
The flag to either pause or unpause the loop.
virtual mi::Sint32 mi::​nservices::​IRender_loop::set_render_context_option( const char* key, const mi::IData* value) [pure virtual]

Sets the value of a render-context option. There are three different types of options:

This method deals with the second of the three types. Currently, there are no options common for all render modes. See the documentation of the render mode in question for render mode-specific options.

These options are not set until the beginning of the next render iteration.

See also:

get_option()

Parameters

key
value
The value of the option to be set.

Returns

  • 0: Success.
  • -1: name is null or empty.
  • -2: value is null.
virtual mi::Sint32 mi::​nservices::​IRender_loop::start_loop() [pure virtual]

Starts the render loop in another thread.

Returns

  • 0 - started successfully
  • -1 - failure
  • -2 - not initialized
  • -3 - thread already running
  • -4 - thread already started once