[fixed] draw2DRectangleOutline() top-left pixel missing

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
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

[fixed] draw2DRectangleOutline() top-left pixel missing

Post by RdR »

I noticed a bug in draw2DRectangleOutline() for the DirectX 9 driver.
The top left pixel from the rectangle is missing

Using latest revision from Irrlicht trunk.

Image

Testcase:

Code: Select all

 
#include <irrlicht.h>
#include "driverChoice.h"
 
using namespace irr;
 
int main() {
        // ask user for driver
        video::E_DRIVER_TYPE driverType = driverChoiceConsole();
        if (driverType == video::EDT_COUNT)
                return 1;
 
        // create device with full flexibility over creation parameters
        // you can add more parameters if desired, check irr::SIrrlichtCreationParameters
        irr::SIrrlichtCreationParameters params;
        params.DriverType = driverType;
        params.WindowSize = core::dimension2d<u32>(1024, 768);
        params.Bits = 32;
        IrrlichtDevice* device = createDeviceEx(params);
 
        if (device == 0)
                return 1; // could not create selected driver.
 
        video::IVideoDriver* driver = device->getVideoDriver();
        scene::ISceneManager* smgr = device->getSceneManager();
        gui::IGUIEnvironment* env = device->getGUIEnvironment();
 
        // Set window title
        core::stringw str = L"Driver: ";
        str += driver->getName();
        device->setWindowCaption(str.c_str());
 
        while (device->run()) {
                if (device->isWindowActive()) {
                        driver->beginScene(true, true, 0);
 
                        smgr->drawAll();
 
                        env->drawAll();
 
                        // Draw rectangle
                        irr::core::recti rect = irr::core::recti(10,10, 100,100);
                        driver->draw2DRectangleOutline(rect, video::SColor(255,255,0,0));
 
                        // test line
                        driver->draw2DLine(core::vector2di(10,8), core::vector2di(100,8), video::SColor(255,255,0,0));
 
                        driver->endScene();
                }
        }
 
        device->drop();
 
        return 0;
}
 
 
EDIT:
draw2Dline() seems to be the problem
Image
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: [Bug] draw2DRectangleOutline() top-left pixel missing

Post by Cube_ »

o.0
that is odd... and it kind of annoys me.
"this is not the bottleneck you are looking for"
Brkopac
Posts: 88
Joined: Fri Sep 19, 2008 2:36 am

Re: [Bug] draw2DRectangleOutline() top-left pixel missing

Post by Brkopac »

aaammmsterdddam wrote:o.0
that is odd... and it kind of annoys me.
Your post brings great insight into the aforementioned bug. We, as a community, would like to thank you for your generous contribution.
Image - The glory days.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: [Bug] draw2DRectangleOutline() top-left pixel missing

Post by hybrid »

I guess it's the problem with texture/pixel alignment under d3d. The positions are slightly offset, hence there's one part missing.
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: [Bug] draw2DRectangleOutline() top-left pixel missing

Post by RdR »

hybrid wrote:I guess it's the problem with texture/pixel alignment under d3d. The positions are slightly offset, hence there's one part missing.
So CD3D9Driver::draw2DLine() should be fixt?

http://msdn.microsoft.com/en-us/library ... 85%29.aspx
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: [Bug] draw2DRectangleOutline() top-left pixel missing

Post by hybrid »

Yeah, whatever a fix would be here. I know this page, but it's not obvious why three of four corners are properly working.
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: [Bug] draw2DRectangleOutline() top-left pixel missing

Post by RdR »

hybrid wrote:Yeah, whatever a fix would be here. I know this page, but it's not obvious why three of four corners are properly working.
All the lines are shifted 1 pixel in the X and Y direction in DirectX.
And the bottom right corners overlaps with 2 lines.

Image

Test:

Code: Select all

 
// Draw rectangle
irr::core::recti rect = irr::core::recti(10, 10, 100, 100);
driver->draw2DRectangleOutline(rect, video::SColor(255, 255, 0, 0));
 
// test line
driver->draw2DLine(core::vector2di(10, 8), core::vector2di(100, 8), video::SColor(255, 255, 255, 0)); // Top line
driver->draw2DLine(core::vector2di(8, 10), core::vector2di(8, 100), video::SColor(255, 255, 255, 0)); // Left line
driver->draw2DLine(core::vector2di(10, 102), core::vector2di(100, 102), video::SColor(255, 255, 255, 0)); // Bottom line
driver->draw2DLine(core::vector2di(102, 10), core::vector2di(102, 100), video::SColor(255, 255, 255, 0)); // Right line
 
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: [Bug] draw2DRectangleOutline() top-left pixel missing

Post by hybrid »

Actually, the problem was even worse. Line start and ending were respected differently for every driver. Some made a last point on the end point, some not. Which also lead to the situation that rendering from X1 to X2 was different to rendering from X2 to X1. All these issues should be fixed now, including rendering only from X1 to X1. This is equivalent to drawPixel(X1) now.
Post Reply