Original Post
For some reason this goes through fine, but I don't get to see my window, nor the DXD_Device is created, and all I get is DXD_Lost no matter how many tries I have. I can't stop having a feeling that I am making a basic mistake somewhere...
...
dwExStyle=WS_EX_APPWINDOW;
dwStyle=WS_POPUP|WS_VISIBLE;
RECT WindowRect;
WindowRect.left=(long)0;
WindowRect.right=(long)resX;
WindowRect.top=(long)0;
WindowRect.bottom=(long)resY;
if(AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle)==0)
logger << "[ERROR] Failed to adjust window. Error value:" << GetLastError() << endl;
HWND hWnd;
if (!(hWnd=CreateWindowEx( dwExStyle, // Extended Style For The Window
reinterpret_cast<LPCWSTR>(classTitle), // Class Name
L"blah", // Window Title
dwStyle, //| // Defined Window Style
//WS_CLIPSIBLINGS | // Required Window Style
//WS_CLIPCHILDREN, // Required Window Style
0, 0, // Window Position
WindowRect.right-WindowRect.left, // Calculate Window Width
WindowRect.bottom-WindowRect.top, // Calculate Window Height
NULL, // No Parent Window
NULL, // No Menu
GetModuleHandle(NULL), // Instance
(void *)this))) // ?
logger<< "[ERROR] Failed to create window. Error value:" << GetLastError() << endl;
/*
DirectX
*/
g_pDirect3D = Direct3DCreate9(D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS PresentParams;
memset(&PresentParams, 0, sizeof(D3DPRESENT_PARAMETERS));
PresentParams.Windowed = TRUE;//FALSE;
/*PresentParams.BackBufferHeight=resY;
PresentParams.BackBufferWidth=resX;
PresentParams.SwapEffect = D3DSWAPEFFECT_FLIP;
PresentParams.BackBufferFormat=D3DFMT_UNKNOWN;
PresentParams.BackBufferCount=3; //Heh?
PresentParams.hDeviceWindow=hWnd;
PresentParams.EnableAutoDepthStencil=true;
*/
int erT2=0;int tries=6;
do{erT2=g_pDirect3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING, &PresentParams,
&g_pDirect3D_Device);Sleep(1000);
if(tries--<=0)break;
}while(erT2!=D3DERR_NOTAVAILABLE);
if(erT2!=D3D_OK)
{logger <<"[ERROR] D3D Creating Device error: "; //Blah
switch(erT2)
{
case D3DERR_DEVICELOST :
logger<<"DEVICE_LOST"<<endl;break;
case D3DERR_INVALIDCALL :
logger<<"DEVICE_LOST"<<endl;break;
case D3DERR_NOTAVAILABLE:
logger<<"DEVICE_LOST"<<endl;break;
case D3DERR_OUTOFVIDEOMEMORY:
logger<<"DEVICE_LOST"<<endl;break;
}
}
if(g_pDirect3D==NULL)
logger << "[ERROR] Our Direct3D thing is broken"<<endl;
if(g_pDirect3D_Device==NULL)
logger << "[ERROR] Our DXD DEVICE is also broken. OH S***"<<endl;
HDC hDC=GetDC(hWnd);
ShowWindow(hWnd, SW_SHOWDEFAULT); //SW_SHOWNORMAL
UpdateWindow(hWnd);
...