所有Irr的引擎文件都在Irr命名空间下,Irr命名空间下又分五大模块:

Core:包含一些引擎核心类,包括各种数据结构和自定义的数据结构。

Gui:一些常用的图形用户接口,实现了各种常用控件。

Io:内部的一些输入输出,xml,zip,ini的文件的读取。

Scene:内部主要负责场景管理,包括场景节点,摄像机,粒子系统mesh,公告板,灯光,动画器,天空盒,地形等。

Video:负责对视频驱动的设置,2D,3D渲染都在这里实现,包括纹理,材质,灯光,图片,顶点等渲染属性的控制。

Irrlicht的场景中的所有的东西都是场景节点,统一由sceneManager来管理。

步骤:

1、创建设备。

2、获取场景管理器,视频设备、GUI环境指针,使用他们进行渲染控制。

3、在beginScene和endScene之间drawAll。

4、释放设备。

/* Example 001 HelloWorld
This Tutorial shows how to set up the IDE for using the Irrlicht Engine and how
to write a simple HelloWorld program with it. The program will show how to use
the basics of the VideoDriver, the GUIEnvironment, and the SceneManager.
Microsoft Visual Studio is used as an IDE, but you will also be able to
understand everything if you are using a different one or even another
operating system than windows.
You have to include the header file <irrlicht.h> in order to use the engine. The
header file can be found in the Irrlicht Engine SDK directory \c include. To let
the compiler find this header file, the directory where it is located has to be
specified. This is different for every IDE and compiler you use. Let's explain
shortly how to do this in Microsoft Visual Studio:
- If you use Version 6.0, select the Menu Extras -> Options.
  Select the directories tab, and select the 'Include' Item in the combo box.
  Add the \c include directory of the irrlicht engine folder to the list of
  directories. Now the compiler will find the Irrlicht.h header file. We also
  need the irrlicht.lib to be found, so stay in that dialog, select 'Libraries'
  in the combo box and add the \c lib/VisualStudio directory.
  \image html "vc6optionsdir.jpg"
  \image latex "vc6optionsdir.jpg"
  \image html "vc6include.jpg"
  \image latex "vc6include.jpg"
- If your IDE is Visual Studio .NET, select Tools -> Options.
  Select the projects entry and then select VC++ directories. Select 'show
  directories for include files' in the combo box, and add the \c include
  directory of the irrlicht engine folder to the list of directories. Now the
  compiler will find the Irrlicht.h header file. We also need the irrlicht.lib
  to be found, so stay in that dialog, select 'show directories for Library
  files' and add the \c lib/VisualStudio directory.
  \image html "vcnetinclude.jpg"
  \image latex "vcnetinclude.jpg"
That's it. With your IDE set up like this, you will now be able to develop
applications with the Irrlicht Engine.
Lets start!
After we have set up the IDE, the compiler will know where to find the Irrlicht
Engine header files so we can include it now in our code.
*/
#include <irrlicht.h>
/*
In the Irrlicht Engine, everything can be found in the namespace 'irr'. So if
you want to use a class of the engine, you have to write irr:: before the name
of the class. For example to use the IrrlichtDevice write: irr::IrrlichtDevice.
To get rid of the irr:: 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
irr:: anymore.
*/
using namespace irr;
/*
There are 5 sub namespaces in the Irrlicht Engine. Take a look at them, you can
read a detailed description of them in the documentation by clicking on the top
menu item 'Namespace List' or by using this link:
http://irrlicht.sourceforge.net/docu/namespaces.html
Like the irr namespace, we do not want these 5 sub namespaces now, to keep this
example simple. Hence, we tell the compiler again that we do not want always to
write their names.
*/
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
/*
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 for VisualStudio. On Windows platforms, we have to get rid
of the console window, which pops up when starting a program with main(). This
is done by the second pragma. We could also use the WinMain method, though
losing platform independence then.
*/
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")// 告诉连接器与这个库连接
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")// 设置连接器选项,屏蔽控制台应用程序的窗口
#endif
/*
This is the main method. We can now use main() on every platform.
*/
int main()
{
   /*
   The most important function of the engine is the createDevice()
   function. The IrrlichtDevice is created by it, which is the root
   object for doing anything with the engine. createDevice() has 7
   parameters:
   - deviceType: Type of the device. This can currently be the Null-device,
      one of the two software renderers, D3D8, D3D9, or OpenGL. In this
      example we use EDT_SOFTWARE, but to try out, you might want to
      change it to EDT_BURNINGSVIDEO, EDT_NULL, EDT_DIRECT3D8,
      EDT_DIRECT3D9, or EDT_OPENGL.
   - windowSize: Size of the Window or screen in FullScreenMode to be
      created. In this example we use 640x480.
   - bits: Amount of color bits per pixel. This should be 16 or 32. The
      parameter is often ignored when running in windowed mode.
   - fullscreen: Specifies if we want the device to run in fullscreen mode
      or not.
   - stencilbuffer: Specifies if we want to use the stencil buffer (for
      drawing shadows).
   - vsync: Specifies if we want to have vsync enabled, this is only useful
      in fullscreen mode.
   - eventReceiver: An object to receive events. We do not want to use this
      parameter here, and set it to 0.
   Always check the return value to cope with unsupported drivers,
   dimensions, etc.
   */
   IrrlichtDevice *device =
       createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16,
           false, false, false, 0);
   if (!device)
       return 1;
   /*
   Set the caption of the window to some nice text. Note that there is an
   'L' in front of the string. The Irrlicht Engine uses wide character
   strings when displaying text.
   */
   device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
   /*
   Get a pointer to the VideoDriver, the SceneManager and the graphical
   user interface environment, so that we do not always have to write
   device->getVideoDriver(), device->getSceneManager(), or
   device->getGUIEnvironment().
   */
   IVideoDriver* driver = device->getVideoDriver();
   ISceneManager* smgr = device->getSceneManager();
   IGUIEnvironment* guienv = device->getGUIEnvironment();
   /*
   We add a hello world label to the window, using the GUI environment.
   The text is placed at the position (10,10) as top left corner and
   (260,22) as lower right corner.
   */
   guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
       rect<s32>(10,10,260,22), true);
   /*
   To show something interesting, we load a Quake 2 model and display it.
   We only have to get the Mesh from the Scene Manager with getMesh() and add
   a SceneNode to display the mesh with addAnimatedMeshSceneNode(). We
   check the return value of getMesh() to become aware of loading problems
   and other errors.
   Instead of writing the filename sydney.md2, it would also be possible
   to load a Maya object file (.obj), a complete Quake3 map (.bsp) or any
   other supported file format. By the way, that cool Quake 2 model
   called sydney was modelled by Brian Collins.
   */
   IAnimatedMesh* mesh = smgr->getMesh("../media/sydney.md2");
   if (!mesh)
   {
       device->drop();
       return 1;
   }
   IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
   /*
   To let the mesh look a little bit nicer, we change its material. We
   disable lighting because we do not have a dynamic light in here, and
   the mesh would be totally black otherwise. Then we set the frame loop,
   such that the predefined STAND animation is used. And last, we apply a
   texture to the mesh. Without it the mesh would be drawn using only a
   color.
   */
   if (node)
   {
       node->setMaterialFlag(EMF_LIGHTING, false);
       node->setMD2Animation(scene::EMAT_STAND);
       node->setMaterialTexture( 0, driver->getTexture("../media/sydney.bmp") );
   }
   /*
   To look at the mesh, we place a camera into 3d space at the position
   (0, 30, -40). The camera looks from there to (0,5,0), which is
   approximately the place where our md2 model is.
   */
   smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
   /*
   Ok, now we have set up the scene, lets draw everything: We run the
   device in a while() loop, until the device does not want to run any
   more. This would be when the user closes the window or presses ALT+F4
   (or whatever keycode closes a window).
   */
   while(device->run())
   {
       /*
       Anything can be drawn between a beginScene() and an endScene()
       call. The beginScene() call clears the screen with a color and
       the depth buffer, if desired. Then we let the Scene Manager and
       the GUI Environment draw their content. With the endScene()
       call everything is presented on the screen.
       */
       driver->beginScene(true, true, SColor(255,100,101,140));
       smgr->drawAll();
       guienv->drawAll();
       driver->endScene();
   }
   /*
   After we are done with the render loop, we have to delete the Irrlicht
   Device created before with createDevice(). In the Irrlicht Engine, you
   have to delete all objects you created with a method or function which
   starts with 'create'. The object is simply deleted by calling ->drop().
   See the documentation at irr::IReferenceCounted::drop() for more
   information.
   */
   device->drop();
   return 0;
}
/*
That's it. Compile and run.
**/

Irrlicht例001--Hello World相关推荐

  1. Irrlicht例002--Quake3Map

    这个例子仅简单的介绍了下如何Load一个Quake3的场景,其中没有什么特殊的概念. 只需注意一下Irr的思想就可以,将场景和摄象机都做为场景节点来处理. 最后,提供了用户选择设备类型的功能,并显示了 ...

  2. stm32f4 hs 电路_电动机控制电路识图一看就懂

    点击上方电工电气学习,关注并星标 专业的电工电气领域自媒体,不容错过 欢迎转发朋友圈,欢迎文末留言 本书采用原理图与实物接线图一一对照的形式,讲述了常用机械设备.液位控制的水泵.小型机械设备.供排循环 ...

  3. 三. 自动化测试用例设计

    1.  主要内容:   2.  手工测试用例与自动化测试用例区别 目前自动化测试更多的时候是定位在冒烟测试和回归测试: 冒烟测试执行的是主体功能点的用例. 回归测试执行全部或部分的测试用例. 3.  ...

  4. 对正则表达式又重新学了一遍,笔记方便以后查阅

    学习地址:慕课网 JavaScript正则表达式 学习地址:慕课网 JavaScript正则表达式通配符:*测试正则表达式: 在线工具:http://regexper.com 也可以从npm上安装到本 ...

  5. python标注工具_Python labelImg 图像标注工具安装及使用教程windows版(亲测有效)

    1.首先先下载这个工具的源代码(此处贴一个github上面的源代码) 地址:https://github.com/tzutalin/labelImg 2.安装 QT5 tools 看到如上图,表示安装 ...

  6. 十进制与二进制,八进制,十六进制的转换

    (一)数制       计算机采用的是二进制,因为二进制具有运算简单,易实现且可靠,为逻辑设计提供了有利的途径,节省设备等优点,为了便于描述,又常用八.十六进制作为二进制的缩写.特点: (1)逢n进一 ...

  7. 由浅入深,解决三道【只出现一次的数】!

    作者 | 袁厨 来源 | 袁厨的算法小屋(ID:tan45du_me) 头图 | CSDN下载自视觉中国 今天我们来做几道非常经典的题目,第一道题目我们会用多种方法解答,虽然这是一道简单题目,但是我们 ...

  8. python单元测试框架作用_Python单元测试框架:Pytest简介

    Pytest简介 入门简单,文档丰富 支持单元测试.功能测试 支持参数化 重复执行,部分执行,测试跳过 兼容其他测试框架(nose,unittest等) 支持生成html报告 可集成CI环境(Jenk ...

  9. 一个小兔子的大数据见解2

    Big Data 阿里的大数据解决方案 MAXCOMPUTE DATAWORKS QUICKBI 1.Vmware增强 2. 1.1.VMware 虚拟网络设备 1.1.1.虚拟网卡.虚拟交换机 虚拟 ...

最新文章

  1. Windows Server 2008 升级安装
  2. iOS开发之 几本书
  3. myeclipse + maven项目创建
  4. Python的filter方法实现筛选功能
  5. HTTP和HTTPS总结
  6. 仿Gin搭建自己的web框架(七)
  7. java integer valueof_对 Java Integer.valueOf() 的一些了解
  8. python s d是什意思_python里d是什么意思
  9. 周鸿祎回应参加RSA大会一事:已在家自行隔离 目前身体状况一切都好
  10. java泛型实例化_如何实例化泛型spring bean?
  11. contenttype文件ajax_jquery ajax contentType设置
  12. vivado下block design重新整理布局regenerate layout
  13. python子类_python创建子类的方法分析
  14. VS2013 Qt Unable to find a Qt Build 及 LINK1112错误
  15. aardio - 【库】内存画板 paint
  16. html代码学习离线文档,新手学HTML代码的简易方法
  17. 打印机服务器虚拟端口,Win7打印机服务器端口添加方法
  18. LeetCode - 加一
  19. 三、大数据存储——HBase
  20. Android近距离通信

热门文章

  1. android adb端口被占用问题
  2. pt-query-digest分析mysql日志
  3. switch case 解决字符串选择的问题
  4. 我的asp.net mvc学习过程
  5. Python的几种实现
  6. ASP.NET Web API 异常日志记录
  7. 【cf789D】Weird journey(欧拉路、计数)
  8. for 循环新的写法==列表解析
  9. PHP laravel框架Redis门面的误用
  10. 关于Xcode7中添加不了libresolv.dylib等类似库的问题