[Irrlicht ghost engine] Master the engine usage process and the Getting Started program HelloWorld

Source: Internet
Author: User

Analysis

1. Procedure

Generally, for a simple program, the Irrlicht engine is generally used as follows:

Preprocessing:
(1) include the <irrlicht. h> header file
# Include <irrlicht. h>
(2) set the namespace
Using namespace irr;
Setting the namespace makes subsequent programming a little easier, just like using the using namespace std; when using C ++ for programming, std: cout <→ cout <.
(3) notify the compiler to connect to the irr Library File
# Ifdef _ IRR_WINDOWS _
# Pragma comment (lib, "Irrlicht. lib ")
# Pragma comment (linker, "/subsystem: windows/ENTRY: mainCRTStartup ")
# Endif
If you do not perform the preceding operations, an error will be reported in the Link section during program compilation. Therefore, this step is very important and must not be forgotten.

At this point, the preprocessing step is complete. Next, we will provide the program with a main function as the entry of the program.
The steps required in the main function are as follows:
(1) create a device
(2) Use the scenario manager, GUI environment, and video device pointers for Rendering Control.
(3) loop in the case of device-> Run. Render control of all content in driver-> beginScene () and driver-> endScene. (We mentioned earlier that the driver is a pointer to IVideoDriver and is responsible for 2D/3D rendering)
(4) release the device
In general, the device is released using the device-> drop (); statement.

In this way, a very basic program based on the Irrlicht engine is completed. On this basis, we can perform various addition operations, such as adding a mesh model and an FPS camera, add terrain, add sky boxes, and so on. These operations will be mentioned in future articles.

2. helloWorld program example

Next, we will show you a simple program written based on the process described above. In the program, we add comments to the sections that need to be understood and noticed to explain the role of statements in the program, hope it will help you understand it!

#include <irrlicht.h>         comment(lib, "Irrlicht.lib")   comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")          IrrlichtDevice *device =<u32>(, ), , , ,  (!     device->setWindowCaption(L* driver = device->* smgr = device->* guienv = device->    guienv->addStaticText(L<s32>(,,,),     smgr->addCameraSceneNode(, vector3df(,,-), vector3df(,,(device->        driver->beginScene(, , SColor(,,,->->->    device-> 

 

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.