zoukankan      html  css  js  c++  java
  • Irrlicht_0.1源码学习(5)—include/core/dimension2d.h、include/core/position2d.h、IUnknown.h、Keycodes.h & include/IrrlichtDevice.h

    因为之前的学习中有遇着引擎核心模块中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; //! eturn Returns a pointer the video driver. virtual video::IVideoDriver* getVideoDriver() = 0; //! eturn Returns a pointer to the file system. virtual io::IFileSystem* getFileSystem() = 0; //! eturn Returns a pointer to the gui environment. virtual gui::IGUIEnvironment* getGUIEnvironment() = 0; //! eturn 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; //! eturn 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环境、场景管理器、设置窗口标题栏、判断窗口是否出于激活状态,以及关闭引擎设备。

  • 相关阅读:
    多线程实现看病Test2
    多线程Test1
    实现注册的账户在重新运行程序后依然可以登录
    教资科一科二pdf资料+科三
    error Custom elements in iteration require 'v-bind:key' directives vue/valid-v-for
    vue-router配置路由出现错误: Mixed spaces and tabs no-mixed-spaces-and-tabs
    [vue-router] route config "component" for path:canot be a string id. Use an actual compone
    20 个超赞的 CSS3 库
    20个简洁的 JS 代码片段
    Vue 前端代码风格指南 |
  • 原文地址:https://www.cnblogs.com/MuSmile/p/5350175.html
Copyright © 2011-2022 走看看