full screen quad does not work with burning video

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

full screen quad does not work with burning video

Post by vitek »

I haven't had time to investigate, but for one reason or another, the transforms that are given do not override the transforms cached in the driver (from the smgr->drawAll() call). The following code illustrates.

The result is that the full screen quad moves around on screen as if it were part of the 3d scene.

Code: Select all

#include <string.h>   // for strcmp

#include <irrlicht.h>
using namespace irr;

#ifdef _IRR_WINDOWS_
#  pragma comment(lib, "Irrlicht.lib")
#endif

int main(int argc, char* argv[])
{
  video::E_DRIVER_TYPE driverType = video::EDT_BURNINGSVIDEO;

  for (int i = 1; i < argc; ++i)
  {
    if (!strcmp (argv[i], "-opengl"))
      driverType = video::EDT_OPENGL;
    else if (!strcmp (argv[i], "-d3d8"))
      driverType = video::EDT_DIRECT3D8;
    else if (!strcmp (argv[i], "-d3d9"))
      driverType = video::EDT_DIRECT3D9;
    else if (!strcmp (argv[i], "-software"))
      driverType = video::EDT_SOFTWARE;
    else if (!strcmp (argv[i], "-burning"))
      driverType = video::EDT_BURNINGSVIDEO;
    else {
      return -1;
    }
  }

  IrrlichtDevice *device = createDevice(driverType, core::dimension2d<s32>(640, 480), 16);
  if (!device)
    return 1;

  video::IVideoDriver* driver = device->getVideoDriver();
  scene::ISceneManager* smgr = device->getSceneManager();

  smgr->addCameraSceneNodeFPS();

  scene::SMeshBuffer mb; 
  mb.Indices.set_used (6); 
  mb.Indices[0] = 0; 
  mb.Indices[1] = 1; 
  mb.Indices[2] = 2; 
  mb.Indices[3] = 0; 
  mb.Indices[4] = 2; 
  mb.Indices[5] = 3; 

  const video::SColor white(255, 255, 255, 255); 

  mb.Vertices.set_used (4); 
  mb.Vertices[0].Pos.set (-1.f, -1.f, 1.f); 
  mb.Vertices[0].TCoords.set(1.0f, 1.0f); 
  mb.Vertices[0].Color = white; 

  mb.Vertices[1].Pos.set (-1.f, 1.f, 1.f); 
  mb.Vertices[1].TCoords.set(1.0f, 0.0f); 
  mb.Vertices[1].Color = white; 

  mb.Vertices[2].Pos.set (1.f, 1.f, 1.f); 
  mb.Vertices[2].TCoords.set(0.0f, 0.0f); 
  mb.Vertices[2].Color = white; 

  mb.Vertices[3].Pos.set (1.f, -1.f, 1.f); 
  mb.Vertices[3].TCoords.set(0.0f, 1.0f); 
  mb.Vertices[3].Color = white; 

  const core::matrix4 identity; 
  video::SMaterial material; 

  material.setTexture(0, driver->getTexture("../../media/010shot.jpg")); 
  material.Lighting = false; 

  while(device->run()) 
  { 
    if (driver->beginScene(true, true, video::SColor(0,200,200,200))) 
    { 
      smgr->drawAll(); 

      driver->setTransform(video::ETS_WORLD, identity); 
      driver->setTransform(video::ETS_VIEW, identity); 
      driver->setTransform(video::ETS_PROJECTION, identity); 

      driver->setMaterial(material); 
      driver->drawMeshBuffer(&mb); 

      driver->endScene(); 
    } 
  } 

  device->drop();

  return 0;
}
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Huh, weird. I thought it worked at first, then I moved the camera and quad stayed in the same world space position. :shock:

Anyway it seems that Burning's relys on the matrices to be set in a specific order:

Code: Select all

driver->setTransform(video::ETS_PROJECTION, identity);
driver->setTransform(video::ETS_VIEW, identity);
driver->setTransform(video::ETS_WORLD, identity);
This is because when you set certain transformations such as ETS_WORLD, it takes ETS_VIEW and ETS_PROJECTION into account and forms a "combined matrix" for performance reasons it seems.

An easy fix would be to take all the matrices into account when setting ETS_VIEW and ETS_PROJECTION also, though I'm gonna let Burning handle this...

Thanks for the heads up.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Post Reply