Irrlicht_0.1源码学习(5)—include/core/dimension2d.h、include/core/position2d.h、IUnknown.h、Keycodes.h & inc...

因为之前的学习中有遇着引擎核心模块中dimension2d和position2d这两个头文件,这里我们先把这两个文件过一遍。

 

首先是include/core下的dimension2d.h,这个头文件里面定义了一个叫做dimension2d的模板类,用以包装一个二维尺寸。

该类的字段只有Width和Height两个,比较容易理解,然后根据其构造方式的多样性实现了三种不同的构造方法,再接着是一些重载的运算符,分别用于判断相等、不等以及赋值。

同样,include/core下的position2d.h里定义了一个position2d模板类,用以指代2d空间下的一个点(坐标),该类的具体实现也是非常简单,在此不展开赘述。现在我们开始把include中剩下的三个单独的文件解决掉。

 

先从简单的Keycodes动手,整个文件中只实现有一个EKEY_CODES枚举,用来枚举win平台下键盘上所有的键编码。

相比之下,IUnknown这个文件就有意思的多了,其中定义的IUnknown类实现了引用计数机制,通过grab,drop这两个方法来管理对象的引用次数。此外这个类还为每个对象的实例存储调试字符串,提供获取和设置调试名称的功能。该类是Irrlicht引擎中大多数类的基类,作用相当于某些系统中的Object。

 

在最后的IrrlichtDevice.h中,创建了IrrlichtDevice类用作irrlicht引擎设备接口:

//! The Irrlicht device. You can create it with createDevice().
class IrrlichtDevice : public IUnknown { public: //! destructor virtual ~IrrlichtDevice() {}; //! Runs the device. Returns false if device wants to be deleted. Use it in this way: //! while(device->run()) { drawEveryThing(); }; virtual bool run() = 0; //! \return Returns a pointer the video driver. virtual video::IVideoDriver* getVideoDriver() = 0; //! \return Returns a pointer to the file system. virtual io::IFileSystem* getFileSystem() = 0; //! \return Returns a pointer to the gui environment. virtual gui::IGUIEnvironment* getGUIEnvironment() = 0; //! \return Returns a pointer to the scene manager. virtual scene::ISceneManager* getSceneManager() = 0; //! Sets the caption of the window. //! \param text: New text of the window caption. virtual void setWindowCaption(const wchar_t* text) = 0; //! \return Returns true if window is active. If the window is inactive, //! nothing need to be drawn. virtual bool isWindowActive() = 0; //! Notifies the device that it should close itself. //! IrrlichtDevice::run() will always return false after closeDevice() was called. virtual void closeDevice() = 0; };

根据源码可知,irrlicht引擎设备提供的功能大致有运行设备(进入游戏循环)、获取设备驱动器、文件系统、gui环境、场景管理器、设置窗口标题栏、判断窗口是否出于激活状态,以及关闭引擎设备。

转载于:https://www.cnblogs.com/MuSmile/p/5350175.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值