Skip to main content
GameDev.net gamedev.net
🔒 Locked

Anti-aliasing Question

Started by cgibson Apr 10, 2003 at 12:59 PM 1 replies 600+ views
Original Post
cgibson
cgibson
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
      
	// 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__);
	}
      
[edited by - cgibson on April 10, 2003 2:00:50 PM] [edited by - cgibson on April 10, 2003 2:01:29 PM]
S1CA
S1CA
What does the debug output from the D3D runtime tell you ? - it should tell you WHY it returned INVALIDCALL.

Also - "I know my video card supports it." - have you checked the device caps?. Also remember some features can''t be used when other features are enabled etc - bullet point features on the sides of hardware boxes are never so simple in reality .

I suspect D3D will tell you something along the lines of it''s going to have trouble with Full Screen Anti Aliasing in windowed mode... [I''m tired - too tired to read the code and check for more obvious mistakes]

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
cgibson
cgibson
When I run it through D3DSpy and I get to the call to IDirect3D9::CheckDeviceMultiSampleType(), it tells me that the parameter that specifies the multisample type is and its return value is S_OK. I don''t understand why it is doing this. I attempted this query for both windowed and fullscreen modes.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.