Skip to main content
gamedev.net
🔒 Locked

Initializing D3D

Started by Whoknewb Jan 14, 2003 at 2:34 PM 2 replies 250+ views
Original Post
Whoknewb
Whoknewb
Hey I''m trying to make a DirectX application but am having troubles initializing directx. It should be making a fullscreen application but it stays windowed I''m pretty sure my CreateDevice is failing
  
// Create the d3d object

	g_d3d = Direct3DCreate8(D3D_SDK_VERSION);

	// Get adapter display mode

	D3DDISPLAYMODE d3ddm;
	g_d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);

	// Set the presentation parameters

	D3DPRESENT_PARAMETERS d3dpp;
	d3dpp.BackBufferWidth = 800;
	d3dpp.BackBufferHeight = 600;
	d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;;
	d3dpp.hDeviceWindow = hWnd;
	d3dpp.Windowed   = FALSE;
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;

	// Create the d3d device

	g_d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, hWnd,
                                  D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                  &d3dpp, &g_d3ddev);
  
Dave Hunt
Dave Hunt
Try setting d3dpp to all zeros before filling in the values.

e.g. ZeroMemory(&d3dpp,sizeof(d3dpp));

It may be that there is garbage in the Fullscreen_RefreshRateInhz field that is causing the thing to fail.

You should also check the result code of the CreateDevice call (or at least wrap it with "if (FAILED(...)))". That way you''ll know if it fails.
Whoknewb
Whoknewb
your a genius I would have never thought
Dave Hunt
Dave Hunt
Not genius. Just been there, did that

Glad I could help.

Topic Locked

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

Sign in to reply to this topic.