Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


D3D rendering...

This topic is 6294 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Greets. Straight to the point, i have two functions, that are used to initiaize D3D, either windowed, or fullscreen mode. In windowed mode everything seems to work fine. However, when in Fullscreen mode, though it appears to work correctly, my rendering never really appears on the screen! Here''s the Fullscreen function, in case someone can help out...


//Returns a valid color format


DWORD D3D_SelectDeviceType(DWORD bpp, DWORD resX, DWORD resY, D3DFORMAT *DisplayFormat, D3DFORMAT *BackBufferFormat, BOOL bWindowed){
//	Formats to be tested...

//		D3DFMT_R5G6B5

//		D3DFMT_R8G8B8 

//		D3DFMT_A8R8G8B8

	if(SUCCEEDED(g_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_R5G6B5, D3DFMT_R5G6B5, bWindowed))) return (TRUE);

	if(SUCCEEDED(g_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8, bWindowed))) return (TRUE);

	return (FALSE);


//Goes into fullscreen via D3D8


DWORD D3D_CreateFullscreen(HWND hWnd, DWORD resX, DWORD resY, DWORD bpp){
	ZeroMemory(&d3dpp, sizeof(d3dpp));

	D3DFORMAT DisplayFormat, BackBufferFormat;

	if(!D3D_SelectDeviceType(bpp, resX, resY, &DisplayFormat, &BackBufferFormat, FALSE)){
		WriteError2("D3D_CreateFullscreen","No valid display formats could be found (%ux%ux%u)",resX,resY,bpp);
		return (FALSE);

	ZeroMemory( &d3dpp, sizeof(d3dpp) );
	d3dpp.BackBufferWidth = resX;
	d3dpp.BackBufferHeight= resY;
	d3dpp.BackBufferFormat= BackBufferFormat;
	d3dpp.BackBufferCount = 1;
	d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
	d3dpp.SwapEffect	  = D3DSWAPEFFECT_FLIP;
	d3dpp.hDeviceWindow	  = hWnd;
	d3dpp.Windowed		  = FALSE;
	d3dpp.EnableAutoDepthStencil = TRUE;
	d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

	d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE;

	DWORD rVal=0;
	if( FAILED( rVal = g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                      &d3dpp, &g_pd3dDevice ) ) )
		WriteWarning2("D3D_CreateFullscreen","Presentation Parameters where adjusted to fit the device (ErrCode = %u)",rVal);
		if( FAILED( rVal = g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
										  &d3dpp, &g_pd3dDevice ) ) )
			WriteError2("D3D_CreateFullscreen","Failed to create the adjusted device! (ErrCode = %u)",rVal);
			return (FALSE);

	return (TRUE);

All tips/assistance pretty welcomed

Share this post

Link to post
Share on other sites
I think you must set the size of the ''d3dpp'' structure
like this " d3dpp.dwSize = sizeof(d3dpp); "
I''m not sure if that will fix your problem but i have
had problems alot of times when i forgot to set the size
of a DirectX structure. I never used the D3DPRESENT_PARAMETERS
structure myself but i think they all have a "dwSize" member
that needs to be set.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!