[fixed]draw2DImage on a RenderTarget problem

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
Valmond
Posts: 308
Joined: Thu Apr 12, 2007 3:26 pm

[fixed]draw2DImage on a RenderTarget problem

Post by Valmond »

Hi

I'm trying to draw 4 images (256x256) on a RenderTarget (512x512).
Normally the Rendertarget should be completely covered.

If my screensize (well for the game) is 512x512 then everything works as expected but
if I set it to 1024x768 then the images drawn on the rendertarget are scaled, actually it is like the RT
is scaled (smaller, to a like 512x384) because it even clips the images drawn (not shown in the screenshot though).

The rendertarget drawn to screen (RT 512x512, screen 1024x768):
Image

I draw things at render time (between beginscene and endscene).

the RT:

Code: Select all

video::ITexture *BaseMapRT;
...
BaseMapRT=globals.GetDriver()->addRenderTargetTexture(core::dimension2d<s32>(512,512), "BASEMAP");
the image to be drawn onto it:

Code: Select all

video::ITexture *Image;
...
Image=driver->getTexture(filename);
The drawing code:

Code: Select all

		driver->setRenderTarget(BaseMapRT,true,false,video::SColor(127,63,0,63));

		driver->draw2DImage(MapPart00.GetImage(), core::position2d<s32>(  0,  0));
		driver->draw2DImage(MapPart10.GetImage(), core::position2d<s32>(256,  0));
		driver->draw2DImage(MapPart01.GetImage(), core::position2d<s32>(  0,256));
		driver->draw2DImage(MapPart11.GetImage(), core::position2d<s32>(256,256));

		driver->setRenderTarget(0);
The MapPartxx stuff are just containers for the images.

I'm using Irrlicht 1.5 and OpenGL.


I saw this bug but I don't know if it has something to do with this.


Any ideas on what I'm doing wrong?

Thanks!
Valmond
Posts: 308
Joined: Thu Apr 12, 2007 3:26 pm

Post by Valmond »

Found it.

It seems like a bug so here is the "hack" to make it work, I guess that either this could be added to the draw2DImage(...) or done in setRenderTarget(...) maybe.

I just needed to zero out the View matrix to make it work (even with a non square RT) just before the drawing:

Code: Select all

      driver->setRenderTarget(BaseMapRT,true,false,video::SColor(127,63,0,63));

      //# New code:

      core::matrix4 mat;
      mat.makeIdentity();
      driver->setTransform(video::ETS_VIEW,mat); //<- set view matrix to identity

      //# end of new code
 
      driver->draw2DImage(MapPart00.GetImage(), core::position2d<s32>(  0,  0));
      driver->draw2DImage(MapPart10.GetImage(), core::position2d<s32>(256,  0));
      driver->draw2DImage(MapPart01.GetImage(), core::position2d<s32>(  0,256));
      driver->draw2DImage(MapPart11.GetImage(), core::position2d<s32>(256,256));

      driver->setRenderTarget(0); 
HTH
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Actually this should be made in the 2d setup routines. Could you please set up a little example app which uses media from the SDK and reproduces this problem? Moving to bug reports for tracking this issue.
Valmond
Posts: 308
Joined: Thu Apr 12, 2007 3:26 pm

Post by Valmond »

I took the 2D tutorial and modified it, the bug appears but my workaround doesn't work anymore:

MSVC Project

The bug only appears in OpenGL, DirectX works fine.

HTH
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Edit: Sorry, my test was wrong. But now it's fixed, should properly render the correctly scaled images.
Post Reply