DriveWorks SDK Reference
3.5.78 Release
For Test and Development only

/dvs/git/dirty/gitlab-master_av/dw/sdk/src/dwvisualization/core/docs/usecase2.md
Go to the documentation of this file.
1 # Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
2 
3 @page renderer_usecase2 Renderer Engine Workflow
4 
5 @note SW Release Applicability: This tutorial is applicable to modules in both **NVIDIA DriveWorks** and **NVIDIA DRIVE Software** releases.
6 
7 The Render Engine provides an API for drawing points, lines, triangles, boxes, ellipses, and grids.
8 
9 ##### dwRenderEngineParams: Render Engine Parameters #####
10 Below are the parameters for the initialization of the Render Engine:
11 
12 ```{.cpp}
13 dwRectf bounds
14 ```
15 
16 The bounds are the display boundaries for the Render Engine.
17 
18 ```{.cpp}
19 dwRenderEngineTileState defaultTile
20 
21 ```
22 
23 The Render Engine works by rendering into tiles. More tiles can be added, but there is one tile initially. This is the default tile. This default tile state represents the state of that tile.
24 
25 ```{.cpp}
26 uint32_t bufferSize
27 ```
28 
29 This is the default buffer size for rendering primitives in bytes. It is used to allocate an internal GPU buffer which is then used when rendering data.
30 
31 ```{.cpp}
32 uint32_t maxBufferCount
33 ```
34 
35 The maximum static buffer count is used when calling dwRenderEngine_addbuffer and dwRenderEngine_removeBuffer. It allocates buffers for static rendering.
36 
37 ##### Rendering simple primitives #####
38 Here is a simple example to render a list of 3 random 3D boxes:
39 
40 ```{.cpp}
41  const uint32_t boxCount = 3;
42  typedef struct
43  {
44  float32_t aRandomFloatToDemonstrateOffset;
45  bool aRandomBoolToDemonstrateOffset;
46  dwVector3f pos;
47  dwVector3f size;
48  int32_t aRandomIntToDemonstrateStride;
49  } Box3D;
50  Box3D boxes[boxCount];
51  for (uint32_t i = 0; i < boxCount; ++i)
52  {
53  boxes[i].pos.x = getRandom() * 4 - 2;
54  boxes[i].pos.y = getRandom() * 4 - 2;
55  boxes[i].pos.z = getRandom() * 4 - 2;
56 
57  boxes[i].size.x = 1.5f;
58  boxes[i].size.y = 0.5f;
59  boxes[i].size.z = 1.5f;
60  }
61 
62  dwRenderEngine_setLineWidth(3.0f, m_renderEngine);
63  dwRenderEngine_setColor({0.0f, 0.5f, 1.0f, 1.0f}, m_renderEngine);
64 
65  dwRenderEngine_setLookAtByAngles(10.0f * M_PI / 180.0f,
66  10.0f * M_PI / 180.0f,
67  5.0f,
68  {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f}, m_renderEngine);
69 
70  dwRenderEngine_setPerspectiveProjection(60.0f * M_PI / 180.0f,
71  16.0f / 9.0f, 0.01f, 1000.0f, m_renderEngine);
72 
73  dwRenderEngine_render(DW_RENDER_ENGINE_PRIMITIVE_TYPE_BOXES_3D,
74  boxes,
75  sizeof(Box3D), // NOTE THE STRIDE
76  // NOTE THE OFFSET POINTS TO WHERE THE FIRST
77  // FIELD OF THE DATA STARTS FOR EACH ELEMENT
78  offsetof(Box3D, pos),
79  boxCount,
80  m_renderEngine);
81 ```
82 
83 For more examples of how to use the Render Engine see:
84 - @ref dwx_render_engine_sample