ZeroMemory(&d3dPresentationParameters, sizeof(d3dPresentationParameters));
d3dPresentationParameters.BackBufferFormat = d3dDisplayMode.Format;
d3dPresentationParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dPresentationParameters.Windowed = TRUE;
RECT tempRect;
GetClientRect(hwndInput, &tempRect);
if(d3dPresentationParameters.Windowed == FALSE)
{
d3dDisplayMode.Width = window_width;
d3dDisplayMode.Height = window_height;
}
d3dPresentationParameters.BackBufferWidth = d3dDisplayMode.Width;///*tempRect.right;*/window_width;
d3dPresentationParameters.BackBufferHeight = d3dDisplayMode.Height;///*tempRect.bottom;*/window_height;
if(d3dPresentationParameters.Windowed == FALSE)
{
d3dPresentationParameters.FullScreen_RefreshRateInHz = d3dDisplayMode.RefreshRate;
}
d3dPresentationParameters.EnableAutoDepthStencil = TRUE; // Not sure if needed.
d3dPresentationParameters.AutoDepthStencilFormat = D3DFMT_D16;
d3dPresentationParameters.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
My window creation code:
Window::Window(const wchar_t *szAppNameImport)
{
szAppName = szAppNameImport;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = NULL;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = GetModuleHandle(NULL);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = szAppName;
wc.hIconSm = LoadIcon(wc.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
created = true;
}
VOID Window::Create(LPCWSTR windowTitle,unsigned int window_width, unsigned int window_height, HWND parent)
{
windowRect.left = GetSystemMetrics(SM_CXSCREEN)/2-window_width/2;
windowRect.top = GetSystemMetrics(SM_CYSCREEN)/2-window_height/2;
windowRect.right = window_width;
windowRect.bottom = window_height;
AdjustWindowRect(&windowRect, NULL, NULL); // So we can have the window at the correct size based on the desired client area size.
if(!RegisterClassEx(&wc))
{
throw std::exception();
}
if((mHwnd = CreateWindowEx
(
0,
szAppName,
windowTitle,
WS_EX_TOPMOST | WS_POPUP,//WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
windowRect.left,windowRect.top,
windowRect.right,windowRect.bottom,
GetDesktopWindow(),
NULL,
wc.hInstance,
NULL))==NULL)
{
throw std::exception();
}
SetWindowLongPtr(mHwnd, GWLP_USERDATA, (LONG_PTR)this);
ShowWindow(mHwnd, SW_SHOWDEFAULT);
UpdateWindow(mHwnd);
}