How to render a fullscreen quad?

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
Mars_999
Posts: 136
Joined: Sat Dec 08, 2012 7:59 pm

How to render a fullscreen quad?

Post by Mars_999 »

I am rendering a quad as fullscreen but the whole texture isn't showing up?

Code: Select all

 
void NX::App::DrawBackground()
{
    irr::video::SMaterial material;
    material.Lighting     = false;
    material.ZWriteEnable = false;
    material.UseMipMaps   = true;
    material.AntiAliasing = irr::video::EAAM_FULL_BASIC;
    material.TextureLayer[0].Texture = driver->getTexture("media/background.png");
    material.TextureLayer[0].AnisotropicFilter = 16;
    material.TextureLayer[0].TrilinearFilter   = true;  
    material.TextureLayer[0].TextureWrapU = irr::video::ETC_CLAMP;
    material.TextureLayer[0].TextureWrapV = irr::video::ETC_CLAMP;
    
    driver->setMaterial(material);
    driver->enableMaterial2D(true);
    driver->draw2DImage(material.TextureLayer[0].Texture, 
                        irr::core::position2d<irr::s32>(0,0),
                        irr::core::rect<irr::s32>(0,0,config.screenSize.Width,
                                                      config.screenSize.Height));
    driver->enableMaterial2D(false);
}
 
Riktovitch
Posts: 15
Joined: Tue Mar 05, 2013 12:36 am

Re: How to render a fullscreen quad?

Post by Riktovitch »

Here are the function I use for my screen quads, and they work alright:

Code: Select all

void ScreenQuad::prepare(dimension2d<u32> texturesize)
{
    assets.texture[0] = assets.device->getVideoDriver()->addRenderTargetTexture(texturesize, "RTT1");
    assets.texture[1] = assets.device->getVideoDriver()->addRenderTargetTexture(texturesize, "RTT2");
 
    assets.vertices[0] = S3DVertex(-1, 1, 0, 0, 0, 0, SColor(255, 255, 255, 255), 0, 0);
    assets.vertices[1] = S3DVertex(1, 1, 0, 0, 0, 0, SColor(255, 255, 255, 255), 1, 0);
    assets.vertices[2] = S3DVertex(1, -1, 0, 0, 0, 0, SColor(255, 255, 255, 255), 1, 1);
    assets.vertices[3] = S3DVertex(-1, -1, 0, 0, 0, 0, SColor(255, 255, 255, 255), 0, 1);
 
    assets.indices[0] = 0;
    assets.indices[1] = 1;
    assets.indices[2] = 3;
    assets.indices[3] = 1;
    assets.indices[4] = 2;
    assets.indices[5] = 3;
 
    assets.material.setTexture(0, assets.texture[0]);
    assets.material.setTexture(1, assets.texture[1]);
    assets.material.Wireframe = false;
    assets.material.Lighting = false;
    assets.material.ZWriteEnable = false;
    assets.material.MaterialType = EMT_TRANSPARENT_ALPHA_CHANNEL;
    assets.material.TextureLayer[0].BilinearFilter = false;
    assets.material.TextureLayer[1].BilinearFilter = false;
}
 
void ScreenQuad::render()
{
    assets.device->getVideoDriver()->setMaterial(assets.material);
    assets.device->getVideoDriver()->setTransform(ETS_PROJECTION, IdentityMatrix);
    assets.device->getVideoDriver()->setTransform(ETS_VIEW, IdentityMatrix);
    assets.device->getVideoDriver()->setTransform(ETS_WORLD, IdentityMatrix);
    assets.device->getVideoDriver()->drawIndexedTriangleList(&assets.vertices[0], 4, &assets.indices[0], 2);
}
Mars_999
Posts: 136
Joined: Sat Dec 08, 2012 7:59 pm

Re: How to render a fullscreen quad?

Post by Mars_999 »

thanks I will take a look at it tomorrow
Mars_999
Posts: 136
Joined: Sat Dec 08, 2012 7:59 pm

Re: How to render a fullscreen quad?

Post by Mars_999 »

Thanks that did the trick!
Post Reply