Original Post
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...
All tips/assistance pretty welcomed
//
//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
*DisplayFormat=D3DFMT_R5G6B5;
*BackBufferFormat=D3DFMT_R5G6B5;
if(SUCCEEDED(g_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_R5G6B5, D3DFMT_R5G6B5, bWindowed))) return (TRUE);
*DisplayFormat=D3DFMT_A8R8G8B8;
*BackBufferFormat=D3DFMT_A8R8G8B8;
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){
D3DPRESENT_PARAMETERS d3dpp;
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_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; //D3DPRESENT_RATE_UNLIMITED;
d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE;
DWORD rVal=0;
if( FAILED( rVal = g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_MIXED_VERTEXPROCESSING,
&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,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &g_pd3dDevice ) ) )
{
WriteError2("D3D_CreateFullscreen","Failed to create the adjusted device! (ErrCode = %u)",rVal);
return (FALSE);
}
}
return (TRUE);
}
|