irrlicht_0.1 Source Learning (5)-include/core/dimension2d.h, Include/core/position2d.h, IUnknown.h, Keycodes.h & include/ IrrlichtDevice.h

Source: Internet
Author: User

Because the previous study encountered in the engine core module dimension2d and position2d These two header files, here we first put these two files over.

The first is the dimension2d.h under the Include/core, which defines a template class called dimension2d to package a two-dimensional dimension.

The field of this class is only width and height of two, it is easier to understand, and then according to the diversity of its construction to achieve three different construction methods, followed by some overloaded operators, respectively, to determine equality, inequality and assignment.

Similarly, include/core under the position2d.h defined a position2d template class, used to refer to a point (coordinates) under 2d space, the specific implementation of this class is very simple, do not expand here. Now let's get rid of the three separate files that are left in the include.

Starting with a simple keycodes, the entire file is implemented with only one Ekey_codes enumeration, which is used to enumerate all key encodings on the keyboard under the win platform.

In contrast, IUnknown this file is much more interesting, in which the defined IUnknown class implements the reference counting mechanism, which manages the number of references to objects by grab,drop these two methods. In addition, this class stores debug strings for each instance of an object, providing the ability to get and set debug names. This class is the base class for most classes in the Irrlicht engine and acts as an object in some systems.

In the final IrrlichtDevice.h, the Irrlichtdevice class was created as the Irrlicht engine device interface:

//! The Irrlicht device. You can create it with CreateDevice ().
classIrrlichtdevice: Publiciunknown{ Public: //! destructor Virtual~Irrlichtdevice () {}; //! Runs the device. Returns False if device wants to is deleted. Use it on this to://! while (Device->run ()) {draweverything ();}; Virtual BOOLRun () =0; //! \return Returns A pointer the video driver. Virtualvideo::ivideodriver* getvideodriver () =0; //! \return Returns A pointer to the file system. Virtualio::ifilesystem* Getfilesystem () =0; //! \return Returns A pointer to the GUI environment. Virtualgui::iguienvironment* getguienvironment () =0; //! \return Returns A pointer to the scene manager. Virtualscene::iscenemanager* Getscenemanager () =0; //! Sets the caption of the window. //! \param text:new Text of the window caption. Virtual voidSetwindowcaption (Constwchar_t* text) =0; //! \return Returns True if window is active. If the window is inactive,//need to be drawn. Virtual BOOLIswindowactive () =0; //! Notifies the device that it should close itself. //! Irrlichtdevice::run () would always return false after CloseDevice () is called. Virtual voidCloseDevice () =0;};

According to the source, the Irrlicht engine device provides a general function to run the device (into the game loop), get the device drive, file system, GUI environment, scene Manager, set the window title bar, determine whether the window is active, and turn off the engine device.

irrlicht_0.1 Source Learning (5)-include/core/dimension2d.h, Include/core/position2d.h, IUnknown.h, Keycodes.h & include/ IrrlichtDevice.h

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.