"Irrlicht Wisp engine" Mastering engine use Flow, starter program HelloWorld

Source: Internet
Author: User
I. Summary of use stepsGenerally speaking, for a simple program, the general use of the Irrlicht engine is as follows:

Pretreatment:
(1) Include <irrlicht.h> header files
#include <irrlicht.h>
(2) Setting up namespaces
using namespace IRR;
Setting the namespace makes the subsequent programming a little easier, as with using namespace STD when programming with C + +,std::cout<<→cout<<.
(3) Notify the compiler to connect the IRR library file
#ifdef _irr_windows_
#pragma comment (lib, "Irrlicht.lib")
#pragma COMMENT (linker, "/subsystem:windows/entry:maincrtstartup")
#endif
If you do not do as above, in the process of compiling the program, will be in the link section error. So this step is very important, must not forget.

Here, the preprocessing steps are completed, and next, we will give the program a main function, as the entry of the program.
The steps to be done in the main function are as follows:
(1) Create a device
(2) Get the scene manager, GUI environment, video device pointers, use them for rendering control
(3) In the case of Device->run (), cycle. Render control of all content in Driver->beginscene () and Driver->endscene (). (as we mentioned before, driver is a pointer to Ivideodriver, responsible for 2d\3d rendering implementation)
(4) Release equipment
In general, the use of device->drop () means that the statement implements the device's release.

In this way, a very basic Irrlicht engine-based program is done, and we can do a variety of additions, such as adding a mesh model, adding an FPS camera, adding terrain, adding sky boxes, and so on. These actions are mentioned in a future article.

ii. Examples of HelloWorld programs

Below, to show you a simple program based on the process described above, in the program, in the need to understand, note the part of the comments to explain the role of the statement in the program, I hope it will help you understand.



Introduce header file #include <irrlicht.h>//Set namespace, start with the following declaration, can save later write Irr::core:: Trouble using namespace IRR;  
using namespace core;  
Scene is scenes management, including scene node, camera, example system, MESH, bulletin board, lighting, animation, Sky box, terrain and so on most//3D function using namespace scene;  
Video is mainly responsible for the settings of the drive, 2D and 3D rendering are implemented here, including textures, materials, lights, images, vertices and other rendering of the genus//sex control using namespace video;  
using namespace Io;  
  

using namespace GUI; In order to be able to use the Irrilcht.dll file, inform the compiler to connect the Irrlicht.lib library file #ifdef _irr_windows_ #pragma comment (lib, "Irrlicht.lib") #pragma comm   
        ENT (linker, "/subsystem:windows/entry:maincrtstartup") #endif int main () {//create device Irrlichtdevice *device =   
  
    CreateDevice (Video::edt_software, dimension2d<u32> (640, 480), +, False, False, False, 0);  
  
if (!device) return 1;  
  
    Set window name Device->setwindowcaption (L "Hello world!-Irrlicht Engine Demo");  
    ivideodriver* Driver = Device->getvideodriver ();  
    iscenemanager* smgr = Device->getscenemanager (); iguienvironment* Guienv = Device->getguienvironment (); Add a static text inside the window Guienv->addstatictext (L "Hello world!  
  
This is the Irrlicht software renderer! ", rect<s32> (10,10,260,22), true);  
  
    The scene is joined to the camera, at (0,30,-40) position, the viewpoint position in (0,5,0) smgr->addcamerascenenode (0, VECTOR3DF (0,30,-40), VECTOR3DF (0,5,0));
        while (Device->run ()) {//All draws must be//beginscene () between BeginScene () and EndScene () to fill the screen with the color Scolor (255,100,101,140)  
  
        Driver->beginscene (True, True, Scolor (255,100,101,140));  
        Smgr->drawall ();  
  
        Guienv->drawall ();  
    Driver->endscene ();  
  
    }//At the end of the program, remember to delete the device object Device->drop ();  
return 0;  
 }


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.