Using Irrlicht engine just to support model rendering

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
galf
Posts: 10
Joined: Sun Nov 08, 2015 8:24 am

Using Irrlicht engine just to support model rendering

Post by galf »

Hi,

Environment: windows 7 64 bit, c++ visual studio 2012, no clr.

I'm new in irrlicht.

I have my own framework which I use in order to draw simple primitive in 3D
such as: lines, images,text, points etc.
In this framework:
*I use openGL (I define my own coordinate system).
* the framework has it's own "Game Loop"

now I want to draw a model using irrlicht within this framework.
I created a device using an handle I gave and set it to openGL:

Code: Select all

 
        HWND hIrrlichtWindow = mGlFrame->GetHandle();
    irr::video::SExposedVideoData videodata(hIrrlichtWindow);
    irr::SIrrlichtCreationParameters param;
    param.DriverType = irr::video::EDT_OPENGL;
    param.WindowId = reinterpret_cast<void*>(hIrrlichtWindow);
    param.Bits = 16;
    param.Fullscreen = false;
    param.Stencilbuffer = false;
    param.Vsync = false;
    irr::IrrlichtDevice* device = irr::createDeviceEx(param);
 
I took the "Hello world" example, and copied the settings :

Code: Select all

 
        IVideoDriver* driver = device->getVideoDriver();
    ISceneManager* smgr = device->getSceneManager();
        IAnimatedMesh* mesh = smgr->getMesh("sydney.md2");
        IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
        node->setMaterialFlag(EMF_LIGHTING, false);
        // I set a model position and camera position in such way I can see the result
        smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
 
in the framework's game loop I inserted this code:

Code: Select all

 
         driver->beginScene(false, true, SColor(0,0,0,255));
    smgr->drawAll();
    driver->endScene();
 
problem:
1.When I draw the model it seems the normals (it's my explanation for the phenomena) does not look right,
meaning - the back of the model is drawn in the front (sydney's left arm is drawn in the same plane of it's right although they are clearly not in the same plane).

2. it seems irrlicht sometimes causes the framework's game-loop to be stuck (I guess)

3. some of the primitive I draw is not shown
does anybody have an idea?
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Using Irrlicht engine just to support model rendering

Post by mongoose7 »

1. I guess you have reversed the winding order for visible faces. For Irrlicht this is normally clockwise from the outside (I think). Irrlicht has a left-hand coordinate system.
2. No.
3. Irrlicht changes the OpenGL state, so you should set state for your code and restore it before calling Irrlicht. You may have changed the projection matrix.
galf
Posts: 10
Joined: Sun Nov 08, 2015 8:24 am

Re: Using Irrlicht engine just to support model rendering

Post by galf »

Thank you for your answer.

My problem was (like in many cases in opengl) in the opengl pipeline.
I did not call glEnable(GL_DEPTH_TEST)
after I called glDisable(GL_DEPTH_TEST)
in one of my primitives drawings.

The other issue caused by bad integration...
Post Reply