Size for IVideoDriver::createRenderTargetTexture()

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
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Size for IVideoDriver::createRenderTargetTexture()

Post by greenya »

Hello,

Documentation says:

Code: Select all

virtual ITexture* irr::video::IVideoDriver::createRenderTargetTexture( const core::dimension2d<s32> &size )
Creates a render target texture.

Parameters:
size,: Size of the texture, in pixels. Width and height should be a power of two (for example 64, 128, 256, 512, ...) and it should not be bigger than the backbuffer, because it shares the zbuffer with the screen buffer.
I guess the question is very stupid, but i want to know for sure, about "and it should not be bigger than the backbuffer":
If i have 800x600 mode what maximum size may i use ? (512x512 ?)
If i have 1024x768 mode --------------------------------- ? (1024x1024 or 1024x512 ?)

P.S.: How to determinate backbuffer size and check is this size acceptable?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

How to determinate backbuffer size and check is this size acceptable?
You should be able to use driver->getScreenSize() to get the size of the back buffer.
If i have 800x600 mode what maximum size may i use ? (512x512 ?)
Yes.
If i have 1024x768 mode --------------------------------- ? (1024x1024 or 1024x512 ?)
1024x512

Code: Select all

core::dimension2d<s32>
getMaxRenderTargetSize(video::IVideoDriver* driver)
{
  const core::dimension2d<s32> ss = driver->getScreenSize();

  core::dimension2d<s32> result(1, 1);
  while (result.Width <= ss.Width)
    result.Width <<= 1;
  result.Width >>= 1;

  while (result.Height <= ss.Height)
    result.Height <<= 1;
  result.Height >>= 1;

  return result;
} 
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post by Luben »

Why is the max size that of the backbuffer? And why does dx force 2^n-sizes? Does this apply to all the drivers?
If you don't have anything nice to say, don't say anything at all.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The limitation to the backbuffer is because its zbuffer is reused, so you wouldn't get sane results otherwise. The Power-of-two is because no DirectX programmer in the team yet fixed it. It was reported that this limitation does not exists for D3D9, but I simply don't know and try to avoid messing with D3D stuff, and the others did not fix it. What about D3D8, is it also capable of NPOT RTT?
LLDD
Posts: 43
Joined: Fri May 11, 2007 9:50 am

Post by LLDD »

I'm using rendertargets with the size of the backbuffer (non power of 2, like 640x480 etc) on the OpenGL driver and it works fine.
*edit* hybrid answered faster and better :D
________
VAPORIZER AFFILIATE
Last edited by LLDD on Sun Feb 20, 2011 2:13 am, edited 2 times in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

OpenGL supports this due to Framebuffer Objects.
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post by Luben »

Is the z-buffer also reused in opengl, or does the framebuffer object consist of all buffers needed to render?
If you don't have anything nice to say, don't say anything at all.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

It contains all stuff so results are correct :)
Post Reply