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 <h3>Passing Arguments</h3> 58 <p>Functions such as those below can be set as callbacks (PreRenderSignal here).</p> 59 <pre> 60void PreRenderCallback(nw::gfx::Model* model, nw::gfx::ResMesh mesh, nw::gfx::RenderContext* renderContext) 61{ 62 .... 63} 64 </pre> 65 <p>To set this function as a callback, create a slot and connect as given below.</p> 66<pre> 67model->PreRenderSignal().CreateAndConnect(PreRenderCallback); 68</pre> 69 <h3>Passing Function Objects</h3> 70 <p>Function objects such as those below can be set as callbacks (PreRenderSignal here).</p> 71 <pre> 72class RenderCallbackFunctor 73{ 74public: 75 void operator () (nw::gfx::Model* model, nw::gfx::ResMesh mesh, nw::gfx::RenderContext* renderContext) 76 { 77 .... 78 } 79}; 80 </pre> 81 <p>To set this function as a callback, create a slot and connect as given below.</p> 82<pre> 83model->PreRenderSignal().CreateAndConnect(RenderCallbackFunctor()); 84</pre> 85 <h3>Passing a Slot</h3> 86 <p>A class that inherits a slot such as shown below can be set as a callback (PreRenderSignal here).</p> 87 <pre> 88class RenderCallbackSlot : public nw::gfx::Model::RenderSlot 89{ 90public: 91 RenderCallbackSlot(nw::os::IAllocator* allocator) 92 : nw::gfx::Model::RenderSlot(allocator) 93 { 94 } 95 virtual void Invoke() (nw::gfx::Model* model, nw::gfx::ResMesh mesh, nw::gfx::RenderContext* renderContext) 96 { 97 .... 98 } 99}; 100 </pre> 101 <p>To set this slot to a callback, connect as given below.</p> 102<pre> 103void* memory = allocator.Alloc(sizeof(RenderCallbackSlot)); 104RenderCallbackSlot* slot = new(memory) RenderCallbackSlot(&allocator); 105model->PreRenderSignal().Connect(slot); 106</pre> 107 <p> 108 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. 109 </p> 110 </div> 111 <hr><p>CONFIDENTIAL</p></body> 112</html> 113