Original Post
I have a problem. I made a successful call to the IDirect3D9::CheckMultiSampleType() function for D3DMULTISAMPLETYPE_2_SAMPLES. The problem is when I try to create the IDirect3DDevice9 object. It fails with a DXERR_INVALIDCALL. I comment out the anti-alias check and the device is created successfully. I know my video card supports it.
I am attempting this in windowed mode with a format of D3DFMT_X8R8G8B8.
Video Card: NVidia GeForce3 Ti200
I want to thank all of you for your help in advance. And if there is any additional information you need, just let me know.
The following is the code snippet that is causing me problems and a description of the important variables.
m_pd3d - Main IDirect3D9 interface pointer
m_pd3dDevice - IDirect3DDevice9 interface pointer
m_d3dpp - D3DPRESENT_PARAMETERS structure
d3ddm - Current display mode for the primary adapter
[edited by - cgibson on April 10, 2003 2:00:50 PM]
[edited by - cgibson on April 10, 2003 2:01:29 PM]
// Get the default adapter's current display mode
D3DDISPLAYMODE d3ddm;
m_pd3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);
// Fill in the devices presentation parameters
m_d3dpp.BackBufferWidth = 800;
m_d3dpp.BackBufferHeight = 600;
m_d3dpp.BackBufferFormat = d3ddm.Format;
m_d3dpp.BackBufferCount = 1; // double buffering
m_d3dpp.Windowed = TRUE;
m_d3dpp.hDeviceWindow = m_Window.GetHandle();
m_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
if (SUCCEEDED(m_pd3d->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format,
TRUE, D3DMULTISAMPLE_2_SAMPLES, NULL))) // Use FSAA if it is available
{ m_d3dpp.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES; }
else
{ m_d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; }
m_d3dpp.AutoDepthStencilFormat = D3DFMT_D16; // Setup the depth/stencil buffer
m_d3dpp.EnableAutoDepthStencil = TRUE;
m_d3dpp.FullScreen_RefreshRateInHz = 0;
m_d3dpp.PresentationInterval = 0;
m_d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; // Lockable Backbuffer
// Determine if the display adapter supports hardware vertex processing
D3DCAPS9 d3dcaps;
m_pd3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3dcaps);
DWORD dwVertexProcessing = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
if (d3dcaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT && d3dcaps.DevCaps & D3DDEVCAPS_HWRASTERIZATION)
{ dwVertexProcessing = D3DCREATE_HARDWARE_VERTEXPROCESSING; }
// Create the Direct3D device
HRESULT hr = m_pd3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_Window.GetHandle(),
dwVertexProcessing, &m_d3dpp, &m_pd3dDevice);
if (FAILED(hr))
{
::SendMessage(m_Window.GetHandle(), WM_CLOSE, 0, 0);
throw CD3DException(hr, "CD3DInitApp::Initialize()", __FILE__, __LINE__);
}