Sign in to follow this  
tourettes

[SlimDX] GetAdapterDisplayModeEx not working

Recommended Posts

tourettes    100
I'm currently tring to conver SlimDX based DirectX9 application into DirectX9 Ex one. I'm facing an issue with few methods that aren't working (most likely not a bug in SlimDX but instead in the code I have written). Code is trying to enumerate thru different / available modes 1) creation of Direct3DEx is succeeding (in code samples it is MPDirect3D.Direct3D) 2) "int aCount = MPDirect3D.Direct3D.AdapterCount" returns valid adapter count, which is one in my case 3) "int mCount = MPDirect3D.Direct3D.GetAdapterModeCountEx(0, filter)" returns same count (36) as the GetAdapterModeCount() when Direct3D is used But few DirectX9 Ex based methods are failing: Following one causes D3DERR_INVALIDCALL, where DirectX debug info is "[5032] Direct3D9: (ERROR) :Invalid pMode parameter specified for GetAdapterDisplayModeEx"
DisplayModeEx mode = MPDirect3D.Direct3D.GetAdapterDisplayModeEx(0)
pMode is in SlimDX's internal code?
DisplayModeEx Direct3DEx::GetAdapterDisplayModeEx( int adapter )
{
  D3DDISPLAYMODEEX nativeMode;
  HRESULT hr = InternalPointer->GetAdapterDisplayModeEx( adapter, &nativeMode, NULL );
  RECORD_D3D9( hr );

  DisplayModeEx mode = DisplayModeEx::FromUnmanaged( nativeMode );
  return mode;
}
So, what could be wrong? Also following code is causing similar error to popup:
DisplayModeFilter filter = new DisplayModeFilter();
filter.Format = Format.X8R8G8B8;
DisplayModeExCollection collection = MPDirect3D.Direct3D.GetDisplayModes(filter);
[2164] Direct3D9: (ERROR) :Invalid pMode parameter specified for EnumAdapterModesEx [Edited by - tourettes on March 16, 2010 11:22:26 PM]

Share this post


Link to post
Share on other sites
tourettes    100
Here's a small code snippet from a test application that causes the same issue


namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

Direct3DEx d3d = new Direct3DEx();

if (d3d.AdapterCount > 0)
{
PresentParameters p = new PresentParameters();
p.SwapEffect = SwapEffect.Copy;
p.DeviceWindowHandle = this.Handle;
p.Windowed = true;
p.BackBufferWidth = ((int)Width < 0) ? 1 : (int)Width;
p.BackBufferHeight = ((int)Height < 0) ? 1 : (int)Height;
p.BackBufferFormat = Format.X8R8G8B8;
p.AutoDepthStencilFormat = Format.D16;
DeviceEx device = new DeviceEx(d3d, 0, DeviceType.Hardware, this.Handle, CreateFlags.HardwareVertexProcessing, p);

AdapterInformationEx ai = d3d.AdaptersEx[0];

DisplayModeFilter filter = new DisplayModeFilter();
filter.Format = Format.X8R8G8B8;

DisplayModeExCollection collection = ai.GetDisplayModes(filter);
}
}
}
}


GetDisplayModes() call fails exactly the same way.

Share this post


Link to post
Share on other sites
Promit    13246
It's a SlimDX bug; we're supposed to be initializing Size fields in some cases that we've missed. I'll patch it up in SVN.

Share this post


Link to post
Share on other sites
tourettes    100
Thanks!

In a mean while I'll use the DirectX9 versions of those methods. Those seem to work nicely after updating to latest SlimDX version (previously in some older version the Adapters array was null when DirectX9 Ex device was in use. AdaptersEx was filled nicely).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this