Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > media > contrib-release > by-pkgid > 58828b263d8f56d90ac336dea07a4586 > files > 747

irrlicht-doc-1.6.1-1mdv2010.1.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Irrlicht Engine: Tutorial 16: Quake3 Map Shader Support</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<table class="irrlicht" >
  <tr valign="middle"> 
    <td><font size="2"><a class="qindex" href="index.html"><font color="#FFFFFF">Home</font></a> 
      | <a class="qindex" href="namespaces.html"><font color="#FFFFFF">Namespaces</font></a> 
      | <a class="qindex" href="hierarchy.html"><font color="#FFFFFF">Hierarchy</font></a> 
      | <a class="qindex" href="classes.html"><font color="#FFFFFF">Alphabetical 
      List</font></a> | <a class="qindex" href="annotated.html"><font color="#FFFFFF"> 
      Class list</font></a> | <a class="qindex" href="files.html"><font color="#FFFFFF">Files</font></a> 
      | <a class="qindex" href="namespacemembers.html"><font color="#FFFFFF"> 
      Namespace&nbsp;Members</font></a> | <a class="qindex" href="functions.html"><font color="#FFFFFF">Class 
      members</font></a> | <a class="qindex" href="globals.html"><font color="#FFFFFF">File 
      members</font></a> | <a class="qindex" href="pages.html"><font color="#FFFFFF">Tutorials</font></a></font> </td>
  </tr>
</table>
<!-- Generated by Doxygen 1.5.6 -->
<div class="contents">
<h1><a class="anchor" name="example016">Tutorial 16: Quake3 Map Shader Support </a></h1><div align="center">
<img src="016shot.jpg" alt="016shot.jpg">
</div>
 <p>
This Tutorial shows how to load a Quake 3 map into the engine, create a SceneNode for optimizing the speed of rendering and how to create a user controlled camera.<p>
Lets start like the HelloWorld example: We include the irrlicht header files and an additional file to be able to ask the user for a driver type using the console. <div class="fragment"><pre class="fragment"><span class="preprocessor">#include &lt;<a class="code" href="irrlicht_8h.html" title="Main header file of the irrlicht, the only file needed to include.">irrlicht.h</a>&gt;</span>
<span class="preprocessor">#include &lt;iostream&gt;</span>
</pre></div><p>
define which Quake3 Level should be loaded <div class="fragment"><pre class="fragment"><span class="preprocessor">#define IRRLICHT_QUAKE3_ARENA</span>
<span class="preprocessor"></span><span class="comment">//#define ORIGINAL_QUAKE3_ARENA</span>
<span class="comment">//#define CUSTOM_QUAKE3_ARENA</span>
<span class="comment">//#define SHOW_SHADER_NAME</span>

<span class="preprocessor">#ifdef ORIGINAL_QUAKE3_ARENA</span>
<span class="preprocessor"></span><span class="preprocessor">        #define QUAKE3_STORAGE_FORMAT   addFolderFileArchive</span>
<span class="preprocessor"></span><span class="preprocessor">        #define QUAKE3_STORAGE_1                "/baseq3/"</span>
<span class="preprocessor"></span><span class="preprocessor">        #ifdef CUSTOM_QUAKE3_ARENA</span>
<span class="preprocessor"></span><span class="preprocessor">                #define QUAKE3_STORAGE_2        "/cf/"</span>
<span class="preprocessor"></span><span class="preprocessor">                #define QUAKE3_MAP_NAME         "maps/cf.bsp"</span>
<span class="preprocessor"></span><span class="preprocessor">        #else</span>
<span class="preprocessor"></span><span class="preprocessor">                #define QUAKE3_MAP_NAME                 "maps/q3dm8.bsp"</span>
<span class="preprocessor"></span><span class="preprocessor">        #endif</span>
<span class="preprocessor"></span><span class="preprocessor">#endif</span>
<span class="preprocessor"></span>
<span class="preprocessor">#ifdef IRRLICHT_QUAKE3_ARENA</span>
<span class="preprocessor"></span><span class="preprocessor">        #define QUAKE3_STORAGE_FORMAT   addZipFileArchive</span>
<span class="preprocessor"></span><span class="preprocessor">        #define QUAKE3_STORAGE_1        "../../media/map-20kdm2.pk3"</span>
<span class="preprocessor"></span><span class="preprocessor">        #define QUAKE3_MAP_NAME                 "maps/20kdm2.bsp"</span>
<span class="preprocessor">#endif</span>
</pre></div><p>
As already written in the HelloWorld example, in the Irrlicht Engine, everything can be found in the namespace 'irr'. To get rid of the <a class="el" href="namespaceirr.html" title="Everything in the Irrlicht Engine can be found in this namespace.">irr</a>:: in front of the name of every class, we tell the compiler that we use that namespace from now on, and we will not have to write that 'irr::'. There are 5 other sub namespaces 'core', 'scene', 'video', 'io' and 'gui'. Unlike in the HelloWorld example, we do not a 'using namespace' for these 5 other namespaces because in this way you will see what can be found in which namespace. But if you like, you can also include the namespaces like in the previous example. Code just like you want to. <div class="fragment"><pre class="fragment"><span class="keyword">using namespace </span>irr;
<span class="keyword">using namespace </span>scene;
</pre></div><p>
Again, to be able to use the Irrlicht.DLL file, we need to link with the Irrlicht.lib. We could set this option in the project settings, but to make it easy, we use a pragma comment lib: <div class="fragment"><pre class="fragment"><span class="preprocessor">#ifdef _MSC_VER</span>
<span class="preprocessor"></span><span class="preprocessor">#pragma comment(lib, "Irrlicht.lib")</span>
<span class="preprocessor"></span><span class="preprocessor">#endif</span>
<span class="preprocessor"></span>

<span class="keyword">class </span>CScreenShotFactory : <span class="keyword">public</span> IEventReceiver
{
<span class="keyword">public</span>:

        CScreenShotFactory( IrrlichtDevice *device, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> * templateName, ISceneNode* node )
                : Device(device), Number(0), FilenameTemplate(templateName), Node(node)
        {
                FilenameTemplate.replace ( <span class="charliteral">'/'</span>, <span class="charliteral">'_'</span> );
                FilenameTemplate.replace ( <span class="charliteral">'\\'</span>, <span class="charliteral">'_'</span> );
        }

        <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent&amp; event)
        {
                <span class="comment">// check if user presses the key F9</span>
                <span class="keywordflow">if</span> ((event.EventType == <a class="code" href="namespaceirr.html#c9eed96e06e85ce3c86fcbbbe9e48a0c6f90390f3147a1693e5e2e3422d6ca09" title="A key input event.">EET_KEY_INPUT_EVENT</a>) &amp;&amp;
                                event.KeyInput.PressedDown)
                {
                        <span class="keywordflow">if</span> (event.KeyInput.Key == <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb35dfbe4e0c7c8d9d810717fc1331fd3c9">KEY_F9</a>)
                        {
                                video::IImage* image = Device-&gt;getVideoDriver()-&gt;createScreenShot();
                                <span class="keywordflow">if</span> (image)
                                {
                                        <a class="code" href="namespaceirr.html#9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> buf[256];
                                        snprintf(buf, 256, <span class="stringliteral">"%s_shot%04d.jpg"</span>,
                                                        FilenameTemplate.c_str(),
                                                        ++Number);
                                        Device-&gt;getVideoDriver()-&gt;writeImageToFile(image, buf, 85 );
                                        image-&gt;drop();
                                }
                        }
                        <span class="keywordflow">else</span>
                        <span class="keywordflow">if</span> (event.KeyInput.Key == <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb35111be01fea6429912b3e497b2a85d73">KEY_F8</a>)
                        {
                                Node-&gt;setDebugDataVisible(<a class="code" href="namespaceirr_1_1scene.html#52b664c4c988113735042b168fc32dbe80f38e42f1b8cf169e83f44092367bfe" title="EDS_BBOX | EDS_BBOX_BUFFERS.">scene::EDS_BBOX_ALL</a>);
                        }
                }
                <span class="keywordflow">return</span> <span class="keyword">false</span>;
        }

<span class="keyword">private</span>:
        IrrlichtDevice *Device;
        <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> Number;
        <a class="code" href="namespaceirr_1_1core.html#de1071a878633f2f6d8a75c5d11fec19" title="Typedef for character strings.">core::stringc</a> FilenameTemplate;
        ISceneNode* Node;
};
</pre></div><p>
Ok, lets start. <div class="fragment"><pre class="fragment"><span class="keywordtype">int</span> <a class="code" href="_irr_compile_config_8h.html#3f9bf2240c47d3f99b86f83f9123aa9d">IRRCALLCONV</a> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])
{
</pre></div><p>
Like in the HelloWorld example, we create an IrrlichtDevice with <a class="el" href="namespaceirr.html#baf4d8719cc26b0d30813abf85e47c76" title="Creates an Irrlicht device. The Irrlicht device is the root object for using the...">createDevice()</a>. The difference now is that we ask the user to select which hardware accelerated driver to use. The Software device would be too slow to draw a huge Quake 3 map, but just for the fun of it, we make this decision possible too. <div class="fragment"><pre class="fragment">        <span class="comment">// ask user for driver</span>

        <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d0" title="An enum for all types of drivers the Irrlicht Engine supports.">video::E_DRIVER_TYPE</a> driverType;

        printf(<span class="stringliteral">"Please select the driver you want for this example:\n"</span>\
                <span class="stringliteral">" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"</span>\
                <span class="stringliteral">" (d) Software Renderer\n (e) Burning's Software Renderer\n"</span>\
                <span class="stringliteral">" (f) NullDevice\n (otherKey) exit\n\n"</span>);

        <span class="keywordtype">char</span> i;
        std::cin &gt;&gt; i;

        <span class="keywordflow">switch</span>(i)
        {
                <span class="keywordflow">case</span> <span class="charliteral">'a'</span>: driverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d04691ca314f9018f508dcf2c57dcaacec" title="Direct3D 9 device, only available on Win32 platforms.">video::EDT_DIRECT3D9</a>;<span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> <span class="charliteral">'b'</span>: driverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d08cc3807f6f28404f3424ad7e31b3142f" title="Direct3D8 device, only available on Win32 platforms.">video::EDT_DIRECT3D8</a>;<span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> <span class="charliteral">'c'</span>: driverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d02715182a79f1cb8e2826fd68a8150a53" title="OpenGL device, available on most platforms.">video::EDT_OPENGL</a>;   <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> <span class="charliteral">'d'</span>: driverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d01598cd235a1a6bd052e2011b559e8995" title="The Irrlicht Engine Software renderer.">video::EDT_SOFTWARE</a>; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> <span class="charliteral">'e'</span>: driverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d0e85481da26159b967191ccc6de1e4a05" title="The Burning&amp;#39;s Software Renderer, an alternative software renderer.">video::EDT_BURNINGSVIDEO</a>;<span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> <span class="charliteral">'f'</span>: driverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d0cfdbd476cbfd4d05e72f9adffcc42210" title="Null driver, useful for applications to run the engine without visualisation.">video::EDT_NULL</a>;     <span class="keywordflow">break</span>;
                <span class="keywordflow">default</span>: <span class="keywordflow">return</span> 1;
        }       

        <span class="comment">// create device and exit if creation failed</span>
        <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#d2e562e3219072e2f7fc7c2bba0ef0cb" title="Typedef for an unsigned integer dimension.">core::dimension2du</a> videoDim ( 800,600 );

        IrrlichtDevice *device = <a class="code" href="namespaceirr.html#baf4d8719cc26b0d30813abf85e47c76" title="Creates an Irrlicht device. The Irrlicht device is the root object for using the...">createDevice</a>(driverType, videoDim, 32, <span class="keyword">false</span> );

        <span class="keywordflow">if</span> (device == 0)
                <span class="keywordflow">return</span> 1; <span class="comment">// could not create selected driver.</span>

        <span class="keyword">const</span> <span class="keywordtype">char</span>* mapname=0;
        <span class="keywordflow">if</span> (argc&gt;2)
                mapname = argv[2];
        <span class="keywordflow">else</span>
                mapname = QUAKE3_MAP_NAME;
</pre></div><p>
Get a pointer to the video driver and the SceneManager so that we do not always have to write device-&gt;getVideoDriver() and device-&gt;getSceneManager(). <div class="fragment"><pre class="fragment">        video::IVideoDriver* driver = device-&gt;getVideoDriver();
        scene::ISceneManager* smgr = device-&gt;getSceneManager();
        gui::IGUIEnvironment* gui = device-&gt;getGUIEnvironment();

        device-&gt;getFileSystem()-&gt;addFolderFileArchive(<span class="stringliteral">"../../media/"</span>);
</pre></div><p>
To display the Quake 3 map, we first need to load it. Quake 3 maps are packed into .pk3 files, which are nothing other than .zip files. So we add the .pk3 file to our FileSystem. After it was added, we are able to read from the files in that archive as they would directly be stored on disk. <div class="fragment"><pre class="fragment">        <span class="keywordflow">if</span> (argc&gt;2)
                device-&gt;getFileSystem()-&gt;QUAKE3_STORAGE_FORMAT (argv[1]);
        <span class="keywordflow">else</span>
                device-&gt;getFileSystem()-&gt;QUAKE3_STORAGE_FORMAT ( QUAKE3_STORAGE_1 );
<span class="preprocessor">#ifdef QUAKE3_STORAGE_2</span>
<span class="preprocessor"></span>        device-&gt;getFileSystem()-&gt;QUAKE3_STORAGE_FORMAT ( QUAKE3_STORAGE_2 );
<span class="preprocessor">#endif</span>
<span class="preprocessor"></span>


        <span class="comment">// Quake3 Shader controls Z-Writing</span>
        smgr-&gt;getParameters()-&gt;setAttribute(<a class="code" href="namespaceirr_1_1scene.html#b585d23bc2a3d02cd368d8bfd0b1414a" title="Name of the parameter for changing how Irrlicht handles the ZWrite flag for transparent...">scene::ALLOW_ZWRITE_ON_TRANSPARENT</a>, <span class="keyword">true</span>);
</pre></div><p>
Now we can load the mesh by calling getMesh(). We get a pointer returned to a IAnimatedMesh. As you know, Quake 3 maps are not really animated, they are only a huge chunk of static geometry with some materials attached. Hence the IAnimated mesh consists of only one frame, so we get the "first frame" of the "animation", which is our quake level and create an OctTree scene node with it, using addOctTreeSceneNode(). The OctTree optimizes the scene a little bit, trying to draw only geometry which is currently visible. An alternative to the OctTree would be a AnimatedMeshSceneNode, which would draw always the complete geometry of the mesh, without optimization. Try it out: Write addAnimatedMeshSceneNode instead of addOctTreeSceneNode and compare the primitives drawed by the video driver. (There is a getPrimitiveCountDrawed() method in the IVideoDriver class). Note that this optimization with the Octree is only useful when drawing huge meshes consisting of lots of geometry. <div class="fragment"><pre class="fragment">        scene::IQ3LevelMesh* mesh =
                (scene::IQ3LevelMesh*) smgr-&gt;getMesh(mapname);
</pre></div><p>
add the geometry mesh to the Scene ( polygon &amp; patches ) The Geometry mesh is optimised for faster drawing <div class="fragment"><pre class="fragment">        scene::ISceneNode* node = 0;
        <span class="keywordflow">if</span> ( mesh )
        {
                scene::IMesh *geometry = mesh-&gt;getMesh(<a class="code" href="namespaceirr_1_1scene_1_1quake3.html#44a1a489a965cc9a0ad2c235bbb7bf3310a5968f2ec9c929bfbca721780a7ef6">quake3::E_Q3_MESH_GEOMETRY</a>);
<span class="comment">//              node = smgr-&gt;addMeshSceneNode ( geometry );</span>
                node = smgr-&gt;addOctTreeSceneNode(geometry, 0, -1, 1024);
        }

        <span class="comment">// create an event receiver for making screenshots</span>
        CScreenShotFactory screenshotFactory ( device, mapname, node );
        device-&gt;setEventReceiver ( &amp;screenshotFactory );
</pre></div><p>
now construct SceneNodes for each Shader The Objects are stored in the quake mesh scene::E_Q3_MESH_ITEMS and the Shader ID is stored in the MaterialParameters mostly dark looking skulls and moving lava.. or green flashing tubes? <div class="fragment"><pre class="fragment">        <span class="keywordflow">if</span> ( mesh )
        {
                <span class="comment">// the additional mesh can be quite huge and is unoptimized</span>
                scene::IMesh * additional_mesh = mesh-&gt;getMesh ( <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#44a1a489a965cc9a0ad2c235bbb7bf3315b1dd0b29d69900d070346d61f44319">quake3::E_Q3_MESH_ITEMS</a> );

<span class="preprocessor">#ifdef SHOW_SHADER_NAME</span>
<span class="preprocessor"></span>                gui::IGUIFont *font = device-&gt;getGUIEnvironment()-&gt;getFont(<span class="stringliteral">"../../media/fontlucida.png"</span>);
                <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> count = 0;
<span class="preprocessor">#endif</span>
<span class="preprocessor"></span>
                <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i = 0; i!= additional_mesh-&gt;getMeshBufferCount (); ++i )
                {
                        IMeshBuffer *meshBuffer = additional_mesh-&gt;getMeshBuffer ( i );
                        <span class="keyword">const</span> video::SMaterial &amp;material = meshBuffer-&gt;getMaterial();

                        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> shaderIndex = (<a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) material.MaterialTypeParam2;

                        <span class="comment">// the meshbuffer can be rendered without additional support, or it has no shader</span>
                        <span class="keyword">const</span> quake3::IShader *shader = mesh-&gt;getShader ( shaderIndex );
                        <span class="keywordflow">if</span> ( 0 == shader )
                        {
                                <span class="keywordflow">continue</span>;
                        }

                        <span class="comment">// we can dump the shader to the console in its</span>
                        <span class="comment">// original but already parsed layout in a pretty</span>
                        <span class="comment">// printers way.. commented out, because the console</span>
                        <span class="comment">// would be full...</span>
                        <span class="comment">// quake3::dumpShader ( Shader );</span>

<span class="preprocessor">#ifndef SHOW_SHADER_NAME</span>
<span class="preprocessor"></span>                        smgr-&gt;addQuake3SceneNode ( meshBuffer, shader );
<span class="preprocessor">#else</span>
<span class="preprocessor"></span>                        count += 1;

                        node = smgr-&gt;addQuake3SceneNode ( meshBuffer, shader );

                        <a class="code" href="namespaceirr_1_1core.html#ef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a> name( node-&gt;getName() );
                        node = smgr-&gt;addBillboardTextSceneNode(
                                        font,
                                        name.c_str(),
                                        node,
                                        core::dimension2d&lt;f32&gt;(80.0f, 8.0f),
                                        <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0, 10, 0)
                                        );
<span class="preprocessor">#endif</span>
<span class="preprocessor"></span>                }


        }
</pre></div><p>
Now we only need a Camera to look at the Quake 3 map. And we want to create a user controlled camera. There are some different cameras available in the Irrlicht engine. For example the Maya Camera which can be controlled compareable to the camera in Maya: Rotate with left mouse button pressed, Zoom with both buttons pressed, translate with right mouse button pressed. This could be created with addCameraSceneNodeMaya(). But for this example, we want to create a camera which behaves like the ones in first person shooter games (FPS). <div class="fragment"><pre class="fragment">        scene::ICameraSceneNode* camera = smgr-&gt;addCameraSceneNodeFPS();
</pre></div><p>
so we need a good starting Position in the level. we can ask the Quake3 Loader for all entities with class_name "info_player_deathmatch" we choose a random launch<p>
<div class="fragment"><pre class="fragment">        <span class="keywordflow">if</span> ( mesh )
        {
                <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#312f35a37540d810fcb14b75fd449c9e">quake3::tQ3EntityList</a> &amp;entityList = mesh-&gt;getEntityList ();

                <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#93ed78aeb11a2a7e8f8ae9b99801aba7">quake3::IEntity</a> search;
                search.name = <span class="stringliteral">"info_player_deathmatch"</span>;

                <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> index = entityList.binary_search ( search );
                <span class="keywordflow">if</span> ( index &gt;= 0 )
                {
                        <span class="keyword">const</span> quake3::SVarGroup *group;
                        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> notEndList;
                        <span class="keywordflow">do</span>
                        {
                                group = entityList[ index ].getGroup(1);

                                <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> parsepos = 0;
                                <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a> pos =
                                        <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#6163d5a7fba9950a2f390a42fe354c3f" title="get a quake3 vector translated to irrlicht position (x,-z,y )">quake3::getAsVector3df</a> ( group-&gt;get ( <span class="stringliteral">"origin"</span> ), parsepos );

                                parsepos = 0;
                                <a class="code" href="namespaceirr.html#0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> angle = <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#dca7fb6948f37384aca94a4c9ac73f14">quake3::getAsFloat</a> ( group-&gt;get ( <span class="stringliteral">"angle"</span>), parsepos );

                                <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a> target ( 0.f, 0.f, 1.f );
                                target.rotateXZBy ( angle, <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a> () );

                                camera-&gt;setPosition ( pos );
                                camera-&gt;setTarget ( pos + target );

                                index += 1;
</pre></div><p>
notEndList = ( index &lt; (s32) entityList.size () &amp;&amp; entityList[index].name == search.name &amp;&amp; (device-&gt;getTimer()-&gt;getRealTime() &gt;&gt; 3 ) &amp; 1 ); <div class="fragment"><pre class="fragment">                                notEndList = index == 2;
                        } <span class="keywordflow">while</span> ( notEndList );
                }

        }
</pre></div><p>
The mouse cursor needs not to be visible, so we make it invisible. <div class="fragment"><pre class="fragment">        device-&gt;getCursorControl()-&gt;setVisible(<span class="keyword">false</span>);

        <span class="comment">// load the engine logo</span>
        gui-&gt;addImage(driver-&gt;getTexture(<span class="stringliteral">"irrlichtlogo2.png"</span>),
                        core::position2d&lt;s32&gt;(10, 10));

        <span class="comment">// show the driver logo</span>
        <a class="code" href="namespaceirr_1_1core.html#3643c2cc7820dd78cd87e73a46b92145">core::position2di</a> pos ( videoDim.Width - 128, videoDim.Height - 64 );

        <span class="keywordflow">switch</span> ( driverType )
        {
                <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d0e85481da26159b967191ccc6de1e4a05" title="The Burning&amp;#39;s Software Renderer, an alternative software renderer.">video::EDT_BURNINGSVIDEO</a>:
                        gui-&gt;addImage(driver-&gt;getTexture(<span class="stringliteral">"burninglogo.png"</span>),pos);
                        <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d02715182a79f1cb8e2826fd68a8150a53" title="OpenGL device, available on most platforms.">video::EDT_OPENGL</a>:
                        gui-&gt;addImage(driver-&gt;getTexture(<span class="stringliteral">"opengllogo.png"</span>),pos);
                        <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d08cc3807f6f28404f3424ad7e31b3142f" title="Direct3D8 device, only available on Win32 platforms.">video::EDT_DIRECT3D8</a>:
                <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d04691ca314f9018f508dcf2c57dcaacec" title="Direct3D 9 device, only available on Win32 platforms.">video::EDT_DIRECT3D9</a>:
                        gui-&gt;addImage(driver-&gt;getTexture(<span class="stringliteral">"directxlogo.png"</span>),pos);
                        <span class="keywordflow">break</span>;
        }
</pre></div><p>
We have done everything, so lets draw it. We also write the current frames per second and the drawn primitives to the caption of the window. The 'if (device-&gt;isWindowActive())' line is optional, but prevents the engine render to set the position of the mouse cursor after task switching when other program are active. <div class="fragment"><pre class="fragment">        <span class="keywordtype">int</span> lastFPS = -1;

        <span class="keywordflow">while</span>(device-&gt;run())
        <span class="keywordflow">if</span> (device-&gt;isWindowActive())
        {
                driver-&gt;beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, video::SColor(255,20,20,40));
                smgr-&gt;drawAll();
                gui-&gt;drawAll();

                driver-&gt;endScene();

                <span class="keywordtype">int</span> fps = driver-&gt;getFPS();

                <span class="comment">//if (lastFPS != fps)</span>
                {
                        io::IAttributes * attr = smgr-&gt;getParameters();

                        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> calls = attr-&gt;getAttributeAsInt ( <span class="stringliteral">"calls"</span> );
                        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> culled = attr-&gt;getAttributeAsInt ( <span class="stringliteral">"culled"</span> );

                        <a class="code" href="namespaceirr_1_1core.html#ef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a> str = L<span class="stringliteral">"Q3 ["</span>;
                        str += driver-&gt;getName();
                        str += <span class="stringliteral">"] FPS:"</span>;
                        str += fps;
                        str += <span class="stringliteral">" Cull:"</span>;
                        str += calls;
                        str += <span class="stringliteral">"/"</span>;
                        str += culled;
                        str += <span class="stringliteral">" Draw: "</span>;
                        str += attr-&gt;getAttributeAsInt ( <span class="stringliteral">"drawn_solid"</span> );
                        str += <span class="stringliteral">"/"</span>;
                        str += attr-&gt;getAttributeAsInt ( <span class="stringliteral">"drawn_transparent"</span> );
                        str += <span class="stringliteral">"/"</span>;
                        str += attr-&gt;getAttributeAsInt ( <span class="stringliteral">"drawn_transparent_effect"</span> );

                        device-&gt;setWindowCaption(str.c_str());
                        lastFPS = fps;
                }
        }
</pre></div><p>
In the end, delete the Irrlicht device. <div class="fragment"><pre class="fragment">        device-&gt;drop();
        
        <span class="keywordflow">return</span> 0;
}
</pre></div> </div>
<hr size="1">
<address style="align: right;">
<small> </small>
</address>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
  <tr> 
    <td width="0"> <div align="left"><small><a href="http://irrlicht.sourceforge.net" target="_blank"><img src="irrlicht.png" alt="The Irrlicht Engine" align="middle" border=0 width=88 height=31></a></small></div></td>
    <td> <div align="left"><small><em><font size="2">The <a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht 
        Engine</a> Documentation &copy; 2003-2009 by Nikolaus Gebhardt. Generated 
        on Sun Jan 10 09:24:07 2010 by <a href="http://www.doxygen.org" target="_blank">Doxygen</a> 
        (1.5.6)</font></em></small></div></td>
  </tr>
</table>
<address style="align: right;">
</address>
</body>
</html>