neuray API Programmer's Manual

irender_context.h File Reference

Description

Context for rendering and picking operations.

Code Example

irender_context.h

‎/***************************************************************************************************
 * Copyright 2024 NVIDIA Corporation. All rights reserved.
 **************************************************************************************************/

#ifndef MI_NEURAYLIB_IRENDER_CONTEXT_H
#define MI_NEURAYLIB_IRENDER_CONTEXT_H

#include <mi/base/interface_declare.h>
#include <mi/base/handle.h>
#include <mi/neuraylib/idata.h>
#include <mi/neuraylib/typedefs.h>
#include <mi/neuraylib/ipick_array.h>

namespace mi {

namespace neuraylib {

class IProgress_callback;
class IReady_callback;
class IRender_counters;
class IRender_target_base;
class ITransaction;



class IRender_context : public
    mi::base::Interface_declare<0xad5ccd43,0x75a1,0x427a,0x83,0x7d,0x95,0xc8,0x70,0x91,0xd4,0xc8>
{
public:
    virtual Sint32 
               render(
        ITransaction* transaction,
        IRender_target_base* render_target_base,
        IProgress_callback* progress_callback) = 0;

    virtual Sint32 
               render_async(
        ITransaction* transaction,
        IRender_target_base* render_target_base,
        IReady_callback* ready_callback,
        IProgress_callback* progress_callback) = 0;

    enum Cancel_mode
    {
        CANCEL_AND_CONTINUE = 0,

        CANCEL_AND_RESTART  = 1,

        //  Undocumented, for alignment only
        CANCEL_FORCE_32_BIT = 0xffffffffU
    };

    virtual void cancel_render( Cancel_mode mode = CANCEL_AND_CONTINUE) = 0;

    virtual IPick_array* pick(
        ITransaction* transaction,
        const Float32_2_struct& point,
        Uint32 max_pick_levels = 1) = 0;

    virtual IPick_array* pick(
        ITransaction* transaction,
        const Float32_2_struct& center,
        const Float32_2_struct& size,
        Uint32 max_pick_levels = 1) = 0;

    virtual IRender_counters* get_render_counters() = 0;

    virtual Sint32 
               set_option( const char* name, const IData* value) = 0;

    virtual const IData* get_option( const char* name) const = 0;

    template<class T>
    const T* get_option( const char* name) const
    {
        const IData* ptr_idata = get_option( name);
        if ( !ptr_idata)
            return 0;
        const T* ptr_T = static_cast<const T*>( ptr_idata->get_interface( typename T::IID()));
        ptr_idata->release();
        return ptr_T;
    }

    virtual Size 
               get_options_length() const = 0;

    virtual const char* get_option_name( Size index) const = 0;

    virtual const char* get_option_type( Size index) const = 0;
};

mi_static_assert( sizeof( IRender_context::Cancel_mode) == sizeof( Uint32));


inline base::Handle< IPick_array> 
               pick(
        IRender_context& render_context,
        ITransaction* trans,
        const math::Bbox< Uint32, 2>& rectangle,
        const Float32_2& pixel_offset = Float32_2(.5f),
        const bool recursive = false)
{
    const Float32_2 size = Float32_2(rectangle.extent() + Uint32_2(1));
    const Float32_2 center = floor(Float32_2(rectangle.center())) + pixel_offset;
    return base::make_handle(render_context.pick(trans, center, size, recursive));
}

 // end group mi_neuray_rendering

} // namespace neuraylib

} // namespace mi

#endif // MI_NEURAYLIB_IRENDER_CONTEXT_H

Namespaces

namespace 
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH. More...
namespace 
Namespace for the neuray API. More...

Classes

class 
This interface is used for doing actual rendering and picking. More...

Functions

base::​Handle < IPick_array >  ( IRender_context& render_context, ITransaction* trans, const math::​Bbox < Uint32 , 2 >& rectangle, const Float32_2& pixel_offset = Float32_2(.5f), const bool recursive = false)
Picks what is behind a rectangle in the scene. More...