2Ddraw coordinate bug(Win)

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
sawada
Posts: 3
Joined: Thu Mar 20, 2014 4:08 pm

2Ddraw coordinate bug(Win)

Post by sawada »

Satisfies the following cases, the coordinate system of the 2D drawing (ex: draw2DImage ,drawPixel) seems to be abnormal.
1)non-power-of-two textures NOT supported
2)use setRenderTarget()

I think, perhaps, the following code is the cause.
CD3D9Driver.cpp:865:  CD3D9Driver::setRenderTarget()

Code: Select all

 
CurrentRendertargetSize = tex->getSize()
 
It seems to solve if use getOriginalSize()
CuteAlien
Admin
Posts: 9652
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: 2Ddraw coordinate bug(Win)

Post by CuteAlien »

Do you maybe have a quick-example that shows how it goes wrong? (we are lazy and it will probably take as a lot longer to write an example that reproduces a bug which you already seem to have on your screen)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
sawada
Posts: 3
Joined: Thu Mar 20, 2014 4:08 pm

Re: 2Ddraw coordinate bug(Win)

Post by sawada »

testcode

Code: Select all

 
#include <irrlicht.h>
 
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
 
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
 
int main()
{
    bool force_off_TEXTURENPOT = true;
 
 
    IrrlichtDevice *device =
        createDevice( video::EDT_DIRECT3D9, dimension2d<u32>(640, 480), 16,
            false, false, false, 0);
 
    if (!device)
        return 1;
 
 
    IVideoDriver* driver = device->getVideoDriver();
    
    if(force_off_TEXTURENPOT)
        driver->disableFeature(EVDF_TEXTURE_NPOT);
    
    if(driver->queryFeature(EVDF_TEXTURE_NPOT)) {
        device->setWindowCaption(L"test : TEXTURE_NPOT(ON) + renderTarget + 2Ddraw");
    }
    else {
        device->setWindowCaption(L"test : TEXTURE_NPOT(OFF) + renderTarget + 2Ddraw");
    }
 
    ITexture *rt0 = driver->addRenderTargetTexture(dimension2d<u32>(600,400)); //make RECTANGLE renderTargetTexture
    if(!rt0) return 1;
 
    while(device->run())
    {
        driver->beginScene(true, true, SColor(255,100,101,140));
 
        //use rendertarget
        driver->setRenderTarget(rt0,true,true,SColor(255,100,101,140));
        driver->draw2DRectangle(SColor(0xffff0000) , rect<s32>(10,10,600-10,400-10)); //draw RECTANGLE RedBox
        driver->setRenderTarget(0);
 
        //
        driver->draw2DImage(rt0,vector2d<s32>(0,0));
 
 
        driver->endScene();
    }
 
    device->drop();
 
    return 0;
}
 
When force_off_TEXTURENPOT = false
The RedBox is drawn as a rectangle.
This appearance is correct.

When force_off_TEXTURENPOT = true
The RedBox is drawn as a square.
This appearance is wrong.
CuteAlien
Admin
Posts: 9652
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: 2Ddraw coordinate bug(Win)

Post by CuteAlien »

Thanks a lot for the info and test-case. I hope it won't be too long until one of us has some time to go over this. But might take a while as we're short on Windows developers this weeks. Nadro and me are both trying to finish some Android projects at the moment and Hybrid hasn't shown up for a while :-(
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply