0

I would like to draw a custom red 3D triangle over my scene. I have followed some tutorials and came up with this code:

while(device->run()) {
    driver->beginScene();
    driver->setTransform(ETS_WORLD, matrix4());
    driver->setMaterial(material);
    driver->draw3DTriangle(myTriangle, SColor(0,255,0,0));
    smgr->drawAll();
    driver->endScene();
}

But this only show my 3D scene and there is no sign of a red triangle. I have checked its coordinates and they are good, I think it is only a render problem.

ouphi
  • 232
  • 2
  • 9

1 Answers1

1

smgr->drawAll() will clean the whole screen and display your scene. Thus calling it after driver->draw3DTriangle() will erase your triangle. If you invert your render functions order this will work fine. See below:

while(device->run()) {
    driver->beginScene();
    smgr->drawAll();
    driver->setTransform(ETS_WORLD, matrix4());
    driver->setMaterial(material);
    driver->draw3DTriangle(myTriangle, SColor(0,255,0,0));
    driver->endScene();
}
HmuBido
  • 11
  • 3