Problem displaying images on Windows.

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
Malardrim
Posts: 2
Joined: Thu May 19, 2016 7:28 am

Problem displaying images on Windows.

Post by Malardrim »

Hello, it's been two weeks since i started Irrlitch, and i have an issue.
My screen is HD and when i get the resolution with a nulldevice it get it right: 1920 x 1080
Then my goal is to display an image fullscreen here is my code:

Code: Select all

 
//t_sz = resolution get by the nulldevice
IrrlichtDevice *device =
        createDevice(video::EDT_OPENGL, t_sz, 48,
            true, true, true, 0);
 
    if (!device)
        return 1;
 
    IVideoDriver* driver = device->getVideoDriver();
    ISceneManager* smgr = device->getSceneManager();
    IGUIEnvironment* guienv = device->getGUIEnvironment();
    IGUIFont *big = guienv->getFont("../media/Fonts/Arial_26/Arial_26.xml");
    ITexture *image = driver->getTexture("../media/assasin.bmp");
 
    driver->makeColorKeyTexture(image, core::position2d<s32>(0, 0));
[...code without incidence on the picture...]
   while (device->run())
    {
        driver->beginScene(true, true, SColor(255, 100, 101, 140));
        driver->draw2DImage(image, core::position2d<s32>(0, 0),
            core::rect<s32>(0, 0, 1920, 1080), 0);
        smgr->drawAll();
        guienv->drawAll();
        driver->endScene();
    }
 
    device->drop();
 
    return 0;
 
the source image is 1920 x 1080 resolution: https://drive.google.com/file/d/0BznWzJ ... sp=sharing
and i get this:
https://drive.google.com/file/d/0BznWzJ ... sp=sharing

Thanks for the help :D
I apologize if this tobic isn't in the right place it's my first post
Malardrim
Posts: 2
Joined: Thu May 19, 2016 7:28 am

Re: Problem displaying images on Windows.

Post by Malardrim »

Sorry my problem was solved changing the driver to EDT_SOFTWARE
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: Problem displaying images on Windows.

Post by Seven »

You might want to use direct3d or OpenGL. The software driver is pretty slow
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: Problem displaying images on Windows.

Post by Cube_ »

What was the problem in the first place?
The code looks legit enough as far as I can tell.

I mean, I'd change

Code: Select all

driver->draw2DImage(image, core::position2d<s32>(0, 0), core::rect<s32>(0, 0, 1920, 1080), 0);
to

Code: Select all

driver->draw2DImage(image, core::position2d<s32>(0, 0), core::rect<s32>(0, 0, t_sz.Width, t_sz.Height)); // works on any resolution
or even

Code: Select all

driver->draw2DImage(image, 
core::rect<s32>(0, 0,t_sz.Width, t_sz.Height), //The location on screen you want to render to - this is useful if you want to downscale or upscale 
core::rect<s32>(0, 0, t_sz.Width, t_sz.Height)); //the part of the image you want to render, in this case 100% of it.
This code should work fine under OpenGL, I should know - I only use the OpenGL renderer and have used this method quite extensively.

Here's an example from one of my projects:

Code: Select all

        driver->draw2DImage(bg, rect<s32>(0, 0, res.Width, res.Height), rect<s32>(0, 0, res.Width/4, res.Height/4));
        if(party1)
        {
            driver->draw2DImage(portrait,
                                rect<s32>(res.Width/1.58, 5, res.Width/1.22, res.Height/7+portSize.Height),
                                rect<s32>(0, 0, portSize.Width, portSize.Height));
        }
 
/*there was a blob of code here, I omitted it because it's just the different screen-positions for these elements. 
Since there's no harm in omitting them I did so for brevity(party1 and party6 ought to be sufficient)*/
 
        }
        if(party6)
        {
            driver->draw2DImage(portrait,
                                rect<s32>(res.Width/1.22, ((res.Height/7+portSize.Height)*2)+5, res.Width, (res.Height/7+portSize.Height)*3),
                                rect<s32>(0, 0, portSize.Width, portSize.Height));
        }
 
        driver->draw2DImage(rt, rect<s32>(1, 1, res.Width/1.6, res.Height/1.6), rect<s32>(0, 0, res.Width, res.Height));
        driver->draw2DImage(compass, rect<s32>(5, res.Height/1.6+10, 300, 500), rect<s32>(0, 0, compassSize.Width, compassSize.Height));
"this is not the bottleneck you are looking for"
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Problem displaying images on Windows.

Post by mongoose7 »

You can't draw a 1920x1080 image on a 1280x768 framebuffer. Well, you can, but it will be 1280x768 and not 1920x1080.

I think the OP was frustrated that s/he was not getting full resolution. As the software driver uses GDI or DirectX, WYSIWYG.
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: Problem displaying images on Windows.

Post by Cube_ »

Right...
why is the framebuffer 1280x768? Isn't it supposed to match the screen resolution of 1920x1080? Really weak hardware? (I've yet to have any problems with that even with a 1920x1080 RTT target, which is why I'm wondering mostly)
"this is not the bottleneck you are looking for"
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Problem displaying images on Windows.

Post by mongoose7 »

I think that is his point. The image he provided was not 1920x1080. I didn't check it because the resolution is irrelevant if it is not 1920x1080.
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: Problem displaying images on Windows.

Post by Cube_ »

mongoose7 wrote:I think that is his point. The image he provided was not 1920x1080. I didn't check it because the resolution is irrelevant if it is not 1920x1080.
I beg to disagree, I just downloaded it - it is 1920x1080.
Image
"this is not the bottleneck you are looking for"
Post Reply