After checking the docs I think it might be a little hard for me to figure it out by myself.
In OpenGL developing we can set the stencil buffer by ourselves, with which I can render only part of the whole render zone by making use of the stencil check.
But in Irrlicht the only thing I found related to the stencil buffer is the bool stencilbuffer which decide if we want to use it in shadows rendering. Is that possible for us to use the stencilbuffer directly?
I wish to render some images for stereoscopic device based on light barriers.
//=============================================================================================
I got freeglut involved to solve the problem.
Code: Select all
driver->beginScene(true, true, SColor(255, 100, 101, 140));
//Enable Stencil buffer and write in it. It's used as mask in this case. ======================================
glClearStencil(0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_NEVER, 0x1, 0x1);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
//set part of the stencil buffer by drawing. It is strange that I can only draw the rects by the methods provided by irrlicht.
driver->draw2DRectangle(video::SColor(100, 255, 255, 255),
core::rect<s32>(0, 0, 1300, 500));
glStencilFunc(GL_EQUAL, 0x1, 0x1);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
//=============================================
smgr->drawAll();
guienv->drawAll();
driver->endScene();