Ok, WOW is all I can say!! You all have given me a lot to work on and its great!!
Thank you Evil Steve for the link of those tutorials you created. There some of the best I have read online and in books. A few questions though.
Currently I am using CreateWindowEx, is there any reason why I should not use this and should use CreateWindow()?
I fixed the problem of setting the client window height and width to be the same as the buffers.
This is where I define the window and register it.
void CPlatform::Initialise(char* cAppName, int iXPos, int iYPos, int iWidth, int iHeight, int argc, char** argv){// Define the window memset(&wStructure,0,sizeof(wStructure)); //set the size of the window structure to 0 wStructure.cbSize = sizeof( wStructure ); //initialize the count byte size of the window structure wStructure.style = CS_HREDRAW | CS_VREDRAW; //redraw when the window height or width changes wStructure.lpfnWndProc = WindowsProcedure; wStructure.cbClsExtra = 0; wStructure.cbWndExtra = 0; wStructure.hInstance = hInstance; wStructure.hIcon = NULL; wStructure.hCursor = NULL; wStructure.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH ); // wStructure.lpszMenuName = NULL; wStructure.lpszClassName = cAppName; // wStructure.hIconSm = LoadIcon( hInstance, IDI_APPLICATION ); // Register the window if (!RegisterClassEx( &wStructure )) { CLogger::Write("window register failed"); } else c_pMainWindow= new CWindow(cAppName,iXPos,iYPos,iWidth,iHeight,hInstance);}
This is where I adjustwindow size and create the window
[source =lang"cpp"]CWindow::CWindow(char *cAppName, int iXPos, int iYPos, int iWidth, int iHeight,HINSTANCE hInstance){ m_iWidth = iWidth; m_iHeight = iHeight; /* next i will use AdjustWindowRect to determine the window size based on the client area size; */ dwStyle = (WS_OVERLAPPEDWINDOW| WS_VISIBLE) & ~WS_THICKFRAME; rc.top=rc.left=0; rc.right = m_iWidth; rc.bottom= m_iHeight; AdjustWindowRect(&rc, dwStyle, FALSE); sizeWindow.cx=rc.right - rc.left; sizeWindow.cy=rc.bottom - rc.top; m_windowHandle = CreateWindowEx(dwStyle, cAppName, cAppName, dwStyle, iXPos, iYPos, sizeWindow.cx,sizeWindow.cy, NULL, NULL, hInstance, this);}
At the moment my window will not show up. It just sits in the taskbar but when i try to view it nothing happens.
I have done all the D3DFORMAT checks now along with the device cap checks. This was from following the tutorials.Here is my Directx initialization:
bool CDirectx::Initialise(CPlatform * c_pPlatform){ //get direct3d pointer g_p3DObject = Direct3DCreate9(D3D_SDK_VERSION); //check if pointer was successful if (!g_p3DObject) { CLogger::Write("could not get direct3d pointer"); return false; } //get current desktop format hResult=g_p3DObject->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &g_displayMode); if(FAILED(hResult)) { CLogger::Write("get adapter display mode failed"); g_p3DObject->Release(); g_p3DObject=NULL; return false; } fmtBackBuffer=g_displayMode.Format; //Check to see what depth buffer supports D3DFORMAT fmtDepths[] = { D3DFMT_D32, D3DFMT_D24X8, D3DFMT_D24S8, D3DFMT_D24X4S4, D3DFMT_D16, D3DFMT_D15S1}; D3DFORMAT fmtDepthSelected = D3DFMT_UNKNOWN; size_t nDepthFormats = sizeof(fmtDepths) / sizeof(fmtDepths[0]); for (size_t i=0; i<nDepthFormats; ++i) { //see if we support the format hResult= g_p3DObject->CheckDeviceFormat (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_displayMode.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, fmtDepths); if(FAILED(hResult)) { //graphics card does not support this format continue; } //check if this format can be used with backbuffer format hResult = g_p3DObject->CheckDepthStencilMatch(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_displayMode.Format,fmtBackBuffer,fmtDepths); if(FAILED(hResult)) { //graphics card does not support this z-buffer continue; } //this format is usable fmtDepthSelected=fmtDepths; break; } if(fmtDepthSelected==D3DFMT_UNKNOWN) { return false; } D3DCAPS9 D3DCaps; g_p3DObject->GetDeviceCaps( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &D3DCaps ); DWORD vertexProcessing = 0; if ( D3DCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT ) { vertexProcessing = D3DCREATE_HARDWARE_VERTEXPROCESSING; // Check for pure device if ( D3DCaps.DevCaps & D3DDEVCAPS_PUREDEVICE ) { vertexProcessing |= D3DCREATE_PUREDEVICE; } } else { vertexProcessing = D3DCREATE_SOFTWARE_VERTEXPROCESSING; } m_iWidth=c_pPlatform->GetMainWindow()->m_iWidth; m_iHeight=c_pPlatform->GetMainWindow()->m_iHeight; D3DPRESENT_PARAMETERS d3dParam; ZeroMemory (&d3dParam, sizeof (d3dParam)); d3dParam.Windowed =true; d3dParam.EnableAutoDepthStencil=TRUE; d3dParam.AutoDepthStencilFormat = fmtDepthSelected; d3dParam.SwapEffect=D3DSWAPEFFECT_DISCARD; d3dParam.BackBufferHeight=c_pPlatform->GetMainWindow()->sizeWindow.cy; d3dParam.BackBufferWidth=c_pPlatform->GetMainWindow()->sizeWindow.cx; d3dParam.BackBufferFormat=D3DFMT_X8R8G8B8; d3dParam.BackBufferCount=1; d3dParam.hDeviceWindow= c_pPlatform->GetMainWindow()->GetHandle(); if (FAILED( g_p3DObject->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, c_pPlatform->GetMainWindow()->GetHandle(), vertexProcessing, &d3dParam, &g_p3DDevice))) { return false; } return true;}
I am not sure why my debugger is not ouputing more information. I checked it more than once to make sure the debug output level was to the max along with the other settings.
Thanks again to everyone that has been helping me work through this.