Modify Irrlicht to use Direct3D9Ex

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
Zerowalker
Posts: 20
Joined: Mon Feb 16, 2015 3:05 pm

Modify Irrlicht to use Direct3D9Ex

Post by Zerowalker »

I am trying to make Irrlicht use Direct3D9Ex instead of the non-ex.

I have been able to make it work with fullscreen, but for some reason i just can't get it to work in Windowed mode.
As i don't know much about C++ overall i am totally confused.

The only thing i have done is pretty much changed everything to "Ex", and made the:

Code: Select all

    D3DDISPLAYMODEEX dm;
    dm.Format = D3DFMT_X8R8G8B8;
    dm.Height = present.BackBufferHeight;
    dm.Size = sizeof(dm);
    dm.RefreshRate = 60;
    dm.ScanLineOrdering = D3DSCANLINEORDERING_PROGRESSIVE;
    dm.Width = present.BackBufferWidth;
 
As "Ex" needed that.
Otherwise i haven't really changed anything.

So, anyone have any ideas what might be wrong?

Code: Select all

    present.BackBufferCount = 1; //Triple Buffering if 2
    present.EnableAutoDepthStencil = TRUE;
    if (Params.Vsync)
        present.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
    else
        present.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
 
    if (Params.Fullscreen)
    {
        present.BackBufferWidth = Params.WindowSize.Width;
        present.BackBufferHeight = Params.WindowSize.Height;
        // request 32bit mode if user specified 32 bit, added by Thomas Stuefe
        if (Params.Bits == 32)
            present.BackBufferFormat = D3DFMT_X8R8G8B8;
        else
            present.BackBufferFormat = D3DFMT_R5G6B5;
        present.SwapEffect = D3DSWAPEFFECT_FLIP;
        present.Windowed    = FALSE;
        present.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
    }
    else
    {
        present.BackBufferFormat    = d3ddm.Format;
        present.SwapEffect      = D3DSWAPEFFECT_DISCARD;
        present.Windowed        = TRUE;
    }
    D3DDISPLAYMODEEX dm;
    dm.Format = D3DFMT_X8R8G8B8;
    dm.Height = present.BackBufferHeight;
    dm.Size = sizeof(dm);
    dm.RefreshRate = 60;
    dm.ScanLineOrdering = D3DSCANLINEORDERING_PROGRESSIVE;
    dm.Width = present.BackBufferWidth;
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

Re: Modify Irrlicht to use Direct3D9Ex

Post by thanhle »

What is Direct3D9Ex?
Do you mean direct3D in window mode?

irr::SIrrlichtCreationParameters params;
params.Bits = 32;
params.DeviceType = EIDT_WIN32;
params.DriverType = EDT_DIRECT3D9;
params.ZBufferBits = 32;
params.EventReceiver = 0;
params.IgnoreInput = true;

params.WindowId = reinterpret_cast<void*>( renderWidget->winId()); //Cast windows handle id to void*
device = createDeviceEx(params);
scene::ICameraSceneNode * camera = device->getSceneManager()->addCameraSceneNode(0, core::vector3df( 0, 20.f, 0.1f));

//Then normal rendering loop.
Zerowalker
Posts: 20
Joined: Mon Feb 16, 2015 3:05 pm

Re: Modify Irrlicht to use Direct3D9Ex

Post by Zerowalker »

Direct3D9Ex is an Extended Version of Direct3D9, so it's not the same, though extremely similar with some additions.
Just would like to get it to work as i would like to play around with some stuff it has.
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

Re: Modify Irrlicht to use Direct3D9Ex

Post by thanhle »

Ah that sound great.
I hope it fix the issue with reset driver when we resize widow.
Zerowalker
Posts: 20
Joined: Mon Feb 16, 2015 3:05 pm

Re: Modify Irrlicht to use Direct3D9Ex

Post by Zerowalker »

No idea if it will solve anything, but perhaps:P
Probably need one of the developers to help me out, as they know how it's integrated.

Mainly interested in trying out FlipEx which i can't get to work even though fullscreen is working.
Zerowalker
Posts: 20
Joined: Mon Feb 16, 2015 3:05 pm

Re: Modify Irrlicht to use Direct3D9Ex

Post by Zerowalker »

I think i got Window mode to work.

Code: Select all

    D3DDISPLAYMODEEX* dm = NULL;
    if (Params.Fullscreen)
    {
    
        present.BackBufferWidth = Params.WindowSize.Width;
        present.BackBufferHeight = Params.WindowSize.Height;
        // request 32bit mode if user specified 32 bit, added by Thomas Stuefe
        if (Params.Bits == 32)
            present.BackBufferFormat = D3DFMT_X8R8G8B8;
        else
            present.BackBufferFormat = D3DFMT_R5G6B5;
        present.SwapEffect = D3DSWAPEFFECT_FLIP;
        present.Windowed    = FALSE;
        present.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
        dm = new D3DDISPLAYMODEEX;
        dm->Format = d3ddm.Format;
        dm->Height = present.BackBufferHeight;
        dm->Size = sizeof(dm);
        dm->RefreshRate = D3DPRESENT_RATE_DEFAULT;
        dm->ScanLineOrdering = D3DSCANLINEORDERING_PROGRESSIVE;
        dm->Width = present.BackBufferWidth;
    }
    else
    {
        present.BackBufferFormat    = d3ddm.Format;
        present.SwapEffect      = D3DSWAPEFFECT_FLIP;
        present.Windowed        = TRUE;
    }
I have to set fullscreen parameters to NULL in create device.
But i kinda cheat my way through it and make a pointer instead, and have it set to NULL when it's not fullscreen.
(I tried using only a pointer, but i can't get it to work, i need to have a reference as well).

EDIT: Solve it, was because i didn't use "new" for the pointer.
I also set it to Delete after it has been used.
Zerowalker
Posts: 20
Joined: Mon Feb 16, 2015 3:05 pm

Re: Modify Irrlicht to use Direct3D9Ex

Post by Zerowalker »

No one?

Also tried making some sort of Fullscreen toggle by resetting the device in the engine source code.
Didn't go well though, guess there is more to it;P
Post Reply