   Program Help?
  Hi guys, I wrote the following program while following a book I purchased along with the DX9 tutorials on drunkenhyena.com.The program is meant to simply draw a cube at the origin.  The camera is 8 units back along the Z-axis (-8 LHW) looking towards the origin (ie. at the cube).However, all I see is a confusing mess of dots.  I took the vertex information straight from the tutorial so I don''t think that''s the problem.Could someone take a minute to look at this and see what''s wrong?  I would really appreciate it.   #include <d3dx9.h>const int WINDOW_HEIGHT = 640;const int WINDOW_WIDTH = 480;const DWORD FVF = D3DFVF_XYZ | D3DFVF_DIFFUSE;struct Vertex {float x, y, z;D3DCOLOR color;};IDirect3DDevice9 *gDevice = 0;IDirect3DVertexBuffer9 *gCubeVB = 0;bool Setup(){D3DXMATRIX mView, mProjection;D3DXVECTOR3 vEye, vLookAt, vUp;void *cubeVertices;float aspect;Vertex aCubeData[] = {// front face{-1.0f, -1.0f, -1.0f, 0xFF0000FF}, {-1.0f, 1.0f, -1.0f, 0xFF0000FF}, {1.0f, 1.0f, -1.0f, 0xFF0000FF},{1.0f, 1.0f, -1.0f, 0xFF0000FF}, {1.0f, -1.0f, -1.0f, 0xFF0000FF}, {-1.0f, -1.0f, -1.0f, 0xFF0000FF},// back face{1.0f, -1.0f, 1.0f, 0xFF0000FF}, {1.0f, 1.0f, 1.0f, 0xFF0000FF}, {-1.0f, 1.0f, 1.0f, 0xFF0000FF},{-1.0f, 1.0f, 1.0f, 0xFF0000FF}, {-1.0f, -1.0f, 1.0f, 0xFF0000FF}, {1.0f, -1.0f, 1.0f, 0xFF0000FF},// top face{-1.0f, 1.0f, -1.0f, 0xFFFF0000}, {-1.0f, 1.0f, 1.0f, 0xFFFF0000}, { 1.0f, 1.0f, 1.0f, 0xFFFF0000},{ 1.0f, 1.0f, 1.0f, 0xFFFF0000}, { 1.0f, 1.0f, -1.0f, 0xFFFF0000}, {-1.0f, 1.0f, -1.0f, 0xFFFF0000},// bottom face{1.0f, -1.0f, -1.0f, 0xFFFF0000}, {1.0f, -1.0f, 1.0f, 0xFFFF0000}, {-1.0f, -1.0f, 1.0f, 0xFFFF0000},{-1.0f,-1.0f, 1.0f, 0xFFFF0000}, {-1.0f, -1.0f, -1.0f, 0xFFFF0000}, { 1.0f, -1.0f, -1.0f, 0xFFFF0000},// left face{-1.0f, -1.0f, 1.0f, 0xFF00FF00}, {-1.0f, 1.0f, 1.0f, 0xFF00FF00}, {-1.0f, 1.0f, -1.0f, 0xFF00FF00},{-1.0f, 1.0f, -1.0f, 0xFF00FF00}, {-1.0f, -1.0f, -1.0f, 0xFF00FF00}, {-1.0f, -1.0f, 1.0f, 0xFF00FF00},// right face{1.0f, -1.0f, -1.0f, 0xFF00FF00}, {1.0f, 1.0f, -1.0f, 0xFF00FF00}, {1.0f, 1.0f, 1.0f, 0xFF00FF00},{1.0f, 1.0f, 1.0f, 0xFF00FF00}, {1.0f, -1.0f, 1.0f, 0xFF00FF00}, {1.0f, -1.0f, -1.0f, 0xFF00FF00}};gDevice->SetRenderState(D3DRS_LIGHTING, false); // no lighting heregDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); // defaultif (FAILED(gDevice->CreateVertexBuffer(sizeof(aCubeData), D3DUSAGE_WRITEONLY, FVF, D3DPOOL_MANAGED, &gCubeVB, 0)))return false;if (FAILED(gCubeVB->Lock(0, 0, &cubeVertices, 0)))return false;memcpy(cubeVertices, aCubeData, sizeof(aCubeData));gCubeVB->Unlock();vEye = D3DXVECTOR3(0.0f, 0.0f, -8.0f);vLookAt = D3DXVECTOR3(0.0f, 0.0f, 0.0f);vUp = D3DXVECTOR3(0.0f, 1.0f, 0.0f);D3DXMatrixLookAtLH(&mView, &vEye, &vLookAt, &vUp);gDevice->SetTransform(D3DTS_VIEW, &mView);aspect = ((float)WINDOW_WIDTH / (float)WINDOW_HEIGHT);D3DXMatrixPerspectiveFovLH(&mProjection, (D3DX_PI / 4), aspect, 1.0f, 100.0f);gDevice->SetTransform(D3DTS_PROJECTION, &mProjection);return true;}void Cleanup(){if (gDevice)gDevice->Release();if (gCubeVB)gCubeVB->Release();}LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParm, LPARAM lParm){switch (msg) {case WM_DESTROY:PostQuitMessage(0);break;case WM_KEYDOWN:if (wParm == VK_ESCAPE)DestroyWindow(hWnd);break;}return DefWindowProc(hWnd, msg, wParm, lParm);}bool Initialize(HINSTANCE hInstance){WNDCLASS cWnd;memset((void *)&cWnd, 0, sizeof(WNDCLASS));cWnd.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;cWnd.lpfnWndProc = WindowProc;cWnd.cbClsExtra = 0;cWnd.cbWndExtra = 0;cWnd.hInstance = hInstance;cWnd.hIcon = LoadIcon(0, IDI_APPLICATION);cWnd.hCursor = LoadCursor(0, IDC_ARROW);cWnd.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);cWnd.lpszMenuName = 0;cWnd.lpszClassName = "D3DScratch";if (! RegisterClass(&cWnd))return false;HWND hWnd;DWORD dwStyle = WS_OVERLAPPED | WS_SYSMENU | WS_VISIBLE | WS_EX_TOPMOST | WS_SIZEBOX;if (! (hWnd = CreateWindow("D3DScratch", "Direct3D Scratch", dwStyle, 0, 0, WINDOW_HEIGHT, WINDOW_WIDTH, 0, 0, hInstance, 0)))return false;ShowWindow(hWnd, SW_SHOW);UpdateWindow(hWnd);IDirect3D9 *d3d9 = 0;d3d9 = Direct3DCreate9(D3D_SDK_VERSION);D3DCAPS9 caps;d3d9->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps);int vp;if (caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT)vp = D3DCREATE_HARDWARE_VERTEXPROCESSING;else vp = D3DCREATE_SOFTWARE_VERTEXPROCESSING;D3DPRESENT_PARAMETERS d3dpp;d3dpp.BackBufferWidth = WINDOW_WIDTH;d3dpp.BackBufferHeight = WINDOW_HEIGHT;d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;d3dpp.BackBufferCount = 1;d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;d3dpp.MultiSampleQuality = 0;d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;d3dpp.hDeviceWindow = hWnd;d3dpp.Windowed = true;d3dpp.EnableAutoDepthStencil = true;d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;d3dpp.Flags = 0;d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;if (FAILED(d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, vp, &d3dpp, &gDevice)))return false;d3d9->Release();return true;}void RenderFrame(){D3DXMATRIX mRotate, mTranslate, mWorld;gDevice->Clear(0, 0, D3DCLEAR_TARGET, 0x00000000, 1.0f, 0);gDevice->BeginScene();gDevice->SetFVF(FVF);gDevice->SetStreamSource(0, gCubeVB, 0, sizeof(Vertex));//D3DXMatrixRotationYawPitchRoll(&mRotate, 1.0f, 1.0f, 1.0f);D3DXMatrixTranslation(&mTranslate, 0.0f, 0.0f, 0.0f);//D3DXMatrixMultiply(&mWorld, &mRotate, &mTranslate);gDevice->SetTransform(D3DTS_WORLD, &mTranslate);gDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 12);gDevice->EndScene();gDevice->Present(0, 0, 0, 0);}int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd){MSG msg; // holds current windows messagememset((void *)&msg, 0, sizeof(MSG)); // zero out msg structif (! Initialize(hInstance)) {MessageBox(0, "Direct3D Initalization Failed", "Init Failed", 0);return 0;}if (! Setup()) {MessageBox(0, "Application Setup Failed", "Setup Failed", 0);return 0;}while (msg.message != WM_QUIT) {if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {TranslateMessage(&msg);DispatchMessage(&msg);} else {RenderFrame();}}Cleanup();return 0;}   You can''''t kill the boogyman. 