1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"[]> 2<html xml:lang="en-US" lang="en-US"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <meta http-equiv="Content-Style-Type" content="text/css" /> 6 <link rel="stylesheet" href="../../css/document.css" type="text/css" /> 7 <title>High-Speed Features</title> 8 </head> 9 <body> 10 <h1>High-Speed Features</h1> 11 <h2 id="stereo">Standard Rendering and Stereo Rendering</h2> 12 <div class="section"> 13 <p> 14 Unlike standard rendering, commands are re-used with stereo rendering. 15 </p> 16 <a href="images/Rendering.png"><img src="images/Rendering.png" border="0" alt="Rendering.png(122057 byte)" width="800" /></a> 17 <p> 18 Rendering is performed in the order given below in the case of standard rendering. 19 </p> 20 <ol> 21 <li>Camera configuration with <a href="../../nw/gfx/RenderContext/SetCameraMatrix.html">SetCameraMatrix</a></li> 22 <li>3D command creation with <a href="../../nw/gfx/MeshRenderer/RenderMesh.html">RenderMesh</a></li> 23 <li>Buffer transfer command configuration</li> 24 </ol> 25 <p> 26 In the case of stereo rendering, performance can be greatly improved compared to calling RenderMesh twice by re-using commands as follows to perform rendering. 27 </p> 28 <ol> 29 <li>3D command creation with <a href="../../nw/gfx/MeshRenderer/RenderMesh.html">RenderMesh</a></li> 30 <li>Save 3D command</li> 31 <li>Left-eye camera configuration with <a href="../../nw/gfx/RenderContext/SetCameraMatrix.html">SetCameraMatrix</a></li> 32 <li>Set access to saved 3D command</li> 33 <li>Buffer transfer command configuration</li> 34 <li>Right-eye camera configuration with <a href="../../nw/gfx/RenderContext/SetCameraMatrix.html">SetCameraMatrix</a></li> 35 <li>Set access to saved 3D command</li> 36 <li>Buffer transfer command configuration</li> 37 </ol> 38 </div> 39 40 <h2 id="callback">Interrupting Update and Rendering with Callbacks</h2> 41 <div class="section"> 42 <p> 43 Callbacks can be called during the following processess.<br /> 44 </p> 45 <img src="images/callback.png" /> 46 <p> 47 There are two methods of implementing callbacks. 48 </p> 49 <ul> 50 <li>Create a function object inheriting <a href="../../nw/gfx/SceneNode/UpdateSignal.html">UpdateSignal</a> or other such class, and execute <a href="../../nw/ut/Signal2/Overview.html">Connect</a> for the signal obtained using <a href="../../nw/gfx/SceneNode/PreUpdateSignal.html">PreUpdateSignal</a> or other such function.</li> 51 <li>Pass a function pointer to <a href="../../nw/ut/Signal2/Overview.html">CreateAndConnect</a> for the signal obtained using <a href="../../nw/gfx/SceneNode/PreUpdateSignal.html">PreUpdateSignal</a> or other such function.</li> 52 </ul> 53 <p> 54 Specify the number of signals at time of creation using <a href="../../nw/gfx/Model/Overview.html">Model</a> or other such class.<br /> Specify the maximum number of callbacks using <a href="../../nw/gfx/SceneBuilder/MaxCallbacks.html">MaxCallbacks</a> of the <a href="../../nw/gfx/SceneBuilder/Overview.html">SceneBuilder class.</a> Or, automatically generate the signal when adding the callback by setting <a href="../../nw/gfx/SceneBuilder/IsFixedSizeMemory.html">IsFixedSizeMemory</a> to false.<br /> For details on RenderCommand, see <a href="../../nw/gfx/SceneBuilder/IsFixedSizeMemory.html">Interrupt Processing During Rendering</a>. 55 </p> 56 <p>The following are examples of setting a callbacks.</p> 57 58 <h3>Passing Arguments</h3> 59 <p>Functions such as those below can be set as callbacks (PreRenderSignal here).</p> 60 <pre> 61void PreRenderCallback(nw::gfx::Model* model, nw::gfx::ResMesh mesh, nw::gfx::RenderContext* renderContext) 62{ 63 .... 64} 65 </pre> 66 <p>To set this function as a callback, create a slot and connect as given below.</p> 67<pre> 68model->PreRenderSignal().CreateAndConnect(PreRenderCallback); 69</pre> 70 71 <h3>Passing Function Objects</h3> 72 <p>Function objects such as those below can be set as callbacks (PreRenderSignal here).</p> 73 <pre> 74class RenderCallbackFunctor 75{ 76public: 77 void operator () (nw::gfx::Model* model, nw::gfx::ResMesh mesh, nw::gfx::RenderContext* renderContext) 78 { 79 .... 80 } 81}; 82 </pre> 83 <p>To set this function as a callback, create a slot and connect as given below.</p> 84<pre> 85model->PreRenderSignal().CreateAndConnect(RenderCallbackFunctor()); 86</pre> 87 88 <h3>Passing a Slot</h3> 89 <p>A class that inherits a slot such as shown below can be set as a callback (PreRenderSignal here).</p> 90 <pre> 91class RenderCallbackSlot : public nw::gfx::Model::RenderSlot 92{ 93public: 94 RenderCallbackSlot(nw::os::IAllocator* allocator) 95 : nw::gfx::Model::RenderSlot(allocator) 96 { 97 } 98 99 virtual void Invoke() (nw::gfx::Model* model, nw::gfx::ResMesh mesh, nw::gfx::RenderContext* renderContext) 100 { 101 .... 102 } 103}; 104 </pre> 105 <p>To set this slot to a callback, connect as given below.</p> 106<pre> 107void* memory = allocator.Alloc(sizeof(RenderCallbackSlot)); 108RenderCallbackSlot* slot = new(memory) RenderCallbackSlot(&allocator); 109model->PreRenderSignal().Connect(slot); 110</pre> 111 <p> 112 The slot is automatically destroyed when the signal is destroyed by passing an allocator to the RenderSlot constructor. To prevent automatic destruction, pass NULL to the contructor. 113 </p> 114 </div> 115 <hr><p>CONFIDENTIAL</p></body> 116</html> 117