DIrectX Problem(d3d8.h)

Started by
1 comment, last by liquid_ice_programmer 20 years, 12 months ago
THIS IS MY CODE: // Include Files #include <windows.h> #include <d3d8.h> #include <d3d8xtex.h> #include <dxerr8.h> // Function Prototypes LRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); void RegisterWindowClass(HINSTANCE hInstance); void CreateAppWindow(HINSTANCE hInstance); WPARAM StartMessageLoop(); HRESULT InitFullScreenDirect3D(); void Render(); void CleanUpDirect3D(); // Global Variable HWND g_hWnd; IDirect3D8* g_pIDirect3D = NULL; IDirect3DDevice8* g_pDirect3DDevice = NULL; IDirect3DSurface8* g_pBitmapSurface = NULL; HRESULT g_hResult = D3D_OK; char g_seErrorMsg[256]; ////////////////// // WindMain() ////////////////// INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, INT) { RegisterWindowClass(hInstance); CreateAppWindow(hInstance); ShowWindow(g_hWnd, SW_SHOWDEFAULT); UpdateWindow(g_hWnd); HRESULT hResult = InitFullScreenDirect3D(); if (SUCCEEDED(hResult)) WPARAM result = StartMessageLoop(); CleanUpDirect3D(); CloseWindow(hWnd); if (g_phResult != D3D_OK) DXTRACE_ERR(g_szErrorMsg, g_hResult); return 0; } /////////////// // WndProc /////////////// LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: return 0; case WM_DESTROY: PostQuitMessage( 0 ); return 0; case WM_PAINT: ValidateRect(g_hWnd, NULL); return 0; case WM_KEYDOWN: switch(waparam) { case VK_ESCAPE: PostQuitMessage(WM_QUIT); break; } } return DefWindowProc(hWnd, msg, wParam, lParam); } ///////////////////////////// // RegisterWindowClass() ///////////////////////////// void RegisterWindowClass(HINSTANCE hInstance) { WNDCLASSEX wc; wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = (HCURSOR)LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = "SurfaceApp"; wc.hIconSm = NULL; RegisterClassEx(&wc); } ///////////////////////// // CreateAppWindow() ///////////////////////// void CreateAppWindow(HINSTANCE hInstance) { g_hWnd = CreateWindowEx( NULL, "SurfaceApp", "Direct3D Surface Application", WS_OVERLAPPEDWINDOW, 100, 100, 648, 514, GetDesktopWindow(), NULL, hInstance, NULL); } ////////////////////////// // StartMessageLoop() ////////////////////////// WPARAM StartMessageLoop() { MSG msg; while(1) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } else { // Use idle time here Render(); } } return msg.wParam; } //////////////////////////////// // InitFullScreenDirect3D() //////////////////////////////// HRESULT InitFullScreenDirect3D() { g_pDirect3D = Direct3DCreate(D3D_SDK_VERSION); if (g_pDirect3D == NULL); { MessageBox(g_hWnd, "DirectX Could Not Load", "DIRECTX ERROR", MB_OK); return E_FAIL; } D3DPRESENT_PARAMETERS D3DPresentParams; ZEROMEMORY(&D3DPresentParams, sizeof(D3DPRESNT_PARAMETERS); D3DPresentParams.Windowed = FALSE; D3DPresentParams.BackBufferCount = 1; D3DPresentParams.BackBufferWidth = 640; D3DPresentParams.BackBufferHieght = 480 D3DPresentParams.BackBufferFormat = D3DFMT_X8R8G8B8; D3DPresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD; D3DPresentParams.hDeviceWindow = g_hWnd; hResult = g_pDirect3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &D3DPresentParams, &g_pDirect3DDevice); if (FAILED(hResult)) { MessageBox(g_hWnd, "DirectX Could Not Load", "DIRECTX ERROR", MB_OK); return E_FAIL; } g_hResult = g_pDirect3DDevice->CreateImageSurface(604, 480, D3DFMT_X8R8G8B8, &g_pBitmapSurface); if (FAILED(g_hResult)) { strcpy(g_szErrorMsg, "Error Creating File."); PostMessage(WM_QUIT); } g_hResult = D3DXLoadSurfaceFromFile(g_pBItmapSurface, NULL, NULL, "test.bmp", NULL, D3DX_DEFAULT, 0, NULL); if (FAILED(g_hResult)) { strcpy(g_szErrorMsg, "Error Loading File."); PostMessage(WM_QUIT); } return D3D_OK; } ///////////////////////// // CleanUpDirect3D() ///////////////////////// void CleanUpDirect3D() { if (g_pBitmapSurface) g_pBitmapSurface->Release(); if (g_pDirect3DDevice) g_pDirect3DDevice->Release(); if (g_pDirect3D) g_pDirect3D->Release(); } //////////////// // Render() //////////////// void Render() { IDirect3DSurface8* pBackBuffer = NULL; g_hResult = g_pDirect3DDevice->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer); if (FAILED(g_hResult)) { strcpy(g_szErrorMsg, "Error Getting Back Buffer."); PostMessage(WM_QUIT); } g_hResult = g_pDirect3DDevice->CopyRects(g_pBitmapSurface, NULL, 0, pBackBuffer, NULL); if (FAILED(g_hResult)) { strcpy(g_szErrorMsg, "Error Copying Image Buffer."); PostMessage(WM_QUIT); } g+pDirect3DDevice->Present(NULL, NULL, NULL, NULL); if (pBackBuffer) pBackBuffer->Release(); } THIS IS MY ERROR: --------------------Configuration: SurfaceApp - Win32 Debug-------------------- Compiling... SurfaceApp.cpp C:\Windows\Desktop\C++ Folder\General Windows\SurfaceApp\SurfaceApp.cpp(3) : fatal error C1083: Cannot open include file: ''d3d8.h'': No such file or directory Error executing cl.exe. SurfaceApp.exe - 1 error(s), 0 warning(s) I AM USING VISUAL STUDIO 6.0(C++) AND WHY WILL IT NOT READ d3d8.h FILE. IT READ THE OTHER 2 DXSDK FILES?
Advertisement
AFAIK the compiler only outputs 1 include error, so it likely will not include the other two too
copy you''re SDK headers in the includes folder of VC or add the folder where they are to the include list (dunno how to do that for VC6)
Somedays I wish I had moderator rights so I could trim that down...

Posting code that is relevant to your problem is a good thing. Posting all of your code isn''t. Also, before unloading a ton of code, it''s generally a good idea to state what your problem is rather than doing it at the end. That way we know what the problem is while we''re looking at the code, rather than afterwards.

In this case, you likely didn''t set the include paths in VC++.
Tools->Options->Directories->Include Files.

Add the SDK Include directory to the list and bump it to the top. Then do the same for libraries. That should fix it.



Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena

This topic is closed to new replies.

Advertisement