NVIDIA Iray API — software examples nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
example_render_target_simple.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2020 NVIDIA Corporation. All rights reserved.
3  *****************************************************************************/
4 
5 // examples/example_render_target_simple.h
6 //
7 // Code shared by many rendering examples
8 
9 #ifndef EXAMPLE_RENDER_TARGET_SIMPLE_H
10 #define EXAMPLE_RENDER_TARGET_SIMPLE_H
11 
12 #include <mi/neuraylib.h>
13 
14 // A simple implementation of the IRender_target interface using default implementations
15 // for the abstract ICanvas and ITile interfaces.
16 class Render_target : public mi::base::Interface_implement<mi::neuraylib::IRender_target>
17 {
18 public:
19  // Constructor.
20  //
21  // Creates a render target with a single canvas of the given pixel type, width, and height.
22  // This variant uses the default implementation for canvases and tiles available via
23  // mi::neuraylib::IImage_api.
25  mi::neuraylib::IImage_api* image_api,
26  const char* pixel_type,
27  mi::Uint32 width,
28  mi::Uint32 height)
29  {
30  m_canvas = image_api->create_canvas( pixel_type, width, height);
31  }
32 
33  // Implement the interface of mi::neuraylib::IRender_target
34  mi::Uint32 get_canvas_count() const { return 1; }
38  { return 0; }
40  {
41  if( index > 0)
42  return 0;
43  m_canvas->retain();
44  return m_canvas.get();
45  }
47  {
48  if( index > 0)
49  return 0;
50  m_canvas->retain();
51  return m_canvas.get();
52  }
53 
54 private:
55  // The only canvas of this render target
57 };
58 
59 #endif // MI_EXAMPLE_RENDER_TARGET_SIMPLE_H