I have a project that I worked on a while ago, that worked fine at that time. I decided to open it up and run it again, and its crashing and giving me an error saying that my device isn't initialize using IDirect3DDevice9*. Basically an unhandled exception of 0x0000000. According to my code I am still using the same function that I used previously to initialize the device. Here is some of my code. It crashed right were it sets the transform. Maybe its something easy that I am missing. Any help would be appreciated
thanks.
Code:
// Grab the window width and height from the HWND
RECT r;
GetWindowRect(hWnd, &r);
m_nWidth = r.right - r.left;
m_nHeight = r.bottom - r.top;
m_bVSync = false;
// Create the D3D Object
Object1 = Direct3DCreate9(D3D_SDK_VERSION);
// Create our presentation parameters for our D3D Device
D3Dpp.hDeviceWindow = hWnd; // Handle to the window
D3Dpp.Windowed = bWindowed; // Windowed or Full-screen?
D3Dpp.BackBufferCount = 1; // Number of back-buffers
D3Dpp.BackBufferFormat = D3DFMT_X8R8G8B8; // Back-buffer pixel format
D3Dpp.BackBufferWidth = m_nWidth; // Back-buffer width
D3Dpp.BackBufferHeight = m_nHeight; // Back-buffer height
D3Dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // Swap effect
D3Dpp.PresentationInterval = m_bVSync ? D3DPRESENT_INTERVAL_DEFAULT : D3DPRESENT_INTERVAL_IMMEDIATE;
D3Dpp.FullScreen_RefreshRateInHz = bWindowed ? 0 : D3DPRESENT_RATE_DEFAULT;
D3Dpp.EnableAutoDepthStencil = TRUE; // Enable depth and stencil buffer
D3Dpp.AutoDepthStencilFormat = D3DFMT_D24S8; // Depth/Stencil buffer bit format
D3Dpp.Flags = D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL; // Discard the depth/stencil buffer upon Present()
D3Dpp.MultiSampleQuality = 0; // MSAA quality
D3Dpp.MultiSampleType = D3DMULTISAMPLE_NONE; // MSAA type
// TODO: Determine supported vertex processing modes
// Create D3D Device
Object1->CreateDevice(
D3DADAPTER_DEFAULT, // Default display adapter
D3DDEVTYPE_HAL, // Device type to use
hWnd, // Handle to our window
D3DCREATE_HARDWARE_VERTEXPROCESSING, // Vertex Processing Behavior Flags (PUREDEVICE, HARDWARE_VERTEXPROCESSING, SOFTWARE_VERTEXPROCESSING)
&D3Dpp, // Presentation parameters
&Device1); // Return a created D3D Device
///////////////////////////////////////////////////////
//eye position, look at position, etc for e3 image
/////////////////////////////////////////////////////
eyePos = D3DXVECTOR3(0, 2, -10);
LookAt = D3DXVECTOR3(0, 0, 0);
upVec = D3DXVECTOR3(0, 1, 0);
///////////////////////////////////////////////////
//call the functions to display 3d images
//////////////////////////////////////////////////
D3DXMatrixLookAtLH(&WorldMat, &eyePos, &LookAt, &upVec);
Device1->SetTransform(D3DTS_VIEW, &WorldMat);
D3DXMatrixPerspectiveFovLH(&ProjMat, D3DX_PI/3, float(m_nWidth)/float(m_nHeight), 1.0f, 1000.0f);
Device1->SetTransform(D3DTS_PROJECTION, &ProjMat);
Device1->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
// create the sprite COM object
D3DXCreateSprite(Device1, &Sprite1);
////////////////////////////////////////////////
//initalize the font object
///////////////////////////////////////////////
D3DXCreateFont(Device1, 30, 0, FW_BOLD, 0, true, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Delicious-Roman"), &Font);