Hi,
Been struggling for a while to find out why I get the d3d debug error "Lost due to display uniqueness change", so I've made the most simple window create and d3d init program from scratch to see where it goes wrong...
Unfortunately still the same d3d error in debug output.
Here is the source, if anyone has in idea...
[source lang="cpp"]#include <Windows.h>#include <d3d9.h>#include <d3dx9.h>#pragma comment (lib, "d3d9.lib")#pragma comment (lib, "d3dx9.lib")#define D3D_DEBUG_INFOHWND _hwnd;WNDCLASSEX _wc;MSG _msg;LPDIRECT3DDEVICE9 d3ddev;D3DPRESENT_PARAMETERS d3dpp;LPDIRECT3D9 d3d;LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);bool InitWindowClass(HINSTANCE pInstance, int sw, int sh, bool pWindowed){ DWORD style = WS_OVERLAPPEDWINDOW; int screenwidth = sw; int screenheight = sh; ZeroMemory(&_wc, sizeof(WNDCLASSEX)); _wc.style = CS_HREDRAW | CS_VREDRAW; _wc.lpfnWndProc = (WNDPROC)WindowProc; _wc.cbClsExtra = 0; _wc.cbWndExtra = 0; _wc.hInstance = pInstance; _wc.hIcon = LoadIcon(0, IDI_APPLICATION); _wc.hCursor = LoadCursor(0, IDC_ARROW); _wc.style = 0; _wc.lpszClassName = L"Windowclass"; _wc.cbSize = sizeof(WNDCLASSEX); ShowCursor(true); if(!pWindowed) { _wc.hbrBackground = (HBRUSH)COLOR_WINDOW; style = WS_EX_TOPMOST | WS_POPUP; } else style = WS_OVERLAPPEDWINDOW; _wc.hbrBackground = (HBRUSH)COLOR_WINDOW; if(0 == (RegisterClassEx(&_wc))) return false; if(NULL == (_hwnd = CreateWindow(L"WindowClass", L"Title", style, 0, 0, screenwidth, screenheight, NULL, NULL, pInstance, NULL))) return false; return true;};bool InitD3d(bool pWindowed, int sw, int sh){ if(NULL == (d3d = Direct3DCreate9(D3D_SDK_VERSION))) return false; ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.hDeviceWindow = _hwnd; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; d3dpp.Windowed = pWindowed; d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; d3dpp.BackBufferCount = 1; d3dpp.EnableAutoDepthStencil= true; d3dpp.AutoDepthStencilFormat= D3DFMT_D24S8; if(!pWindowed) { d3dpp.BackBufferWidth = sw; d3dpp.BackBufferHeight = sh; } HRESULT hr = d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, _hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &d3ddev); if(hr != D3D_OK) return false; return true;}void Cleanup(){ d3ddev->Release(); d3d->Release(); DestroyWindow(_hwnd); ZeroMemory(&_wc, NULL); ZeroMemory(&d3dpp, NULL); }int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ bool windowed = false; if(!InitWindowClass(hInstance, 1024, 768, windowed)) MessageBox(NULL, L"Window not created", L"Error", MB_OK); if(!InitD3d(windowed, 1024, 768)) MessageBox(NULL, L"Direct3D initialization error", L"Error", MB_OK); ShowWindow(_hwnd, 1); UpdateWindow(_hwnd); PeekMessage(&_msg, NULL, 0, 0, PM_NOREMOVE); while(_msg.message != WM_QUIT) { if(PeekMessage(&_msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&_msg); DispatchMessage(&_msg); } else { } } Cleanup(); return (INT)_msg.wParam;}LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){ switch(message) { case WM_CLOSE: DestroyWindow(_hwnd); break; case WM_DESTROY: PostQuitMessage(WM_QUIT); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0;}[/source]
frustrating lost due to display uniqueness....
Started by cozzie, Dec 12 2012 02:39 PM
3 replies to this topic
Ad:
#4 Members - Reputation: 349
Posted 18 December 2012 - 02:39 PM
Problem solved, I was recreating the device and reloading the whole scene after resetting the devices.
Had to free/ OnLostDevice the assets before resetting.
Thanks again for the pointers.
Was thinking about using Direct3D9EX,but didn't find enough advantages for now (and wouldn't accept not solving this the right way
)
Had to free/ OnLostDevice the assets before resetting.
Thanks again for the pointers.
Was thinking about using Direct3D9EX,but didn't find enough advantages for now (and wouldn't accept not solving this the right way






