Sign in to follow this  

Linking problem with C++ and Direct3D......HELP!!!!

This topic is 4835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok the code compiles with no errors or warnings but it continues to come up with an error when trying to execute.....the errors ain.obj : error LNK2001: unresolved external symbol "long __cdecl InitD3D(struct HWND__ *,int,int,bool)" (?InitD3D@@YAJPAUHWND__@@HH_N@Z) and the code im using is....any idea's? #include <windows.h> #include <d3d9.h> IDirect3D9* pD3D9 = NULL; IDirect3DDevice9* pD3DDevice9 = NULL; HRESULT InitD3D(HWND hwnd, int width, int height, bool fullscreen); void Render(void); void Destroy(void); LRESULT CALLBACK MsgHandler(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { WNDCLASSEX AdamsClass; MSG msg; HWND hWnd = NULL; AdamsClass.cbSize = sizeof(WNDCLASSEX); AdamsClass.style = CS_HREDRAW | CS_VREDRAW; AdamsClass.lpfnWndProc = MsgHandler; AdamsClass.cbClsExtra = 0; AdamsClass.cbWndExtra = 0; AdamsClass.hInstance = hInstance; AdamsClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); AdamsClass.hCursor = LoadCursor(NULL, IDC_ARROW); AdamsClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); AdamsClass.lpszMenuName = NULL; AdamsClass.lpszClassName = "Adams"; AdamsClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO); if (!RegisterClassEx(&AdamsClass)) return 0; hWnd = CreateWindowEx(NULL, "Adams", "Adams", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 400, 400, NULL, NULL, hInstance, NULL); if (!hWnd) return 0; if (FAILED(InitD3D(hWnd, 800, 600, false))) { Destroy(); return 0; } while (TRUE) { PeekMessage(&msg, hWnd, NULL, NULL, PM_REMOVE); if (msg.message == WM_QUIT) break; else { Render(); TranslateMessage(&msg); DispatchMessage(&msg); } } Destroy(); UnregisterClass("window", hInstance); return (msg.wParam); } HRESULT Init3D(HWND hwnd, int width, int height, bool fullscreen) { pD3D9 = Direct3DCreate9(D3D_SDK_VERSION); if (pD3D9 == NULL) return E_FAIL; D3DDISPLAYMODE d3ddm; pD3D9->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm); D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.BackBufferWidth = 320; d3dpp.BackBufferHeight = 240; d3dpp.BackBufferCount = 1; d3dpp.BackBufferFormat = d3ddm.Format; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.Windowed = false; d3dpp.EnableAutoDepthStencil = true; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; if (FAILED(pD3D9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pD3DDevice9))) { return E_FAIL; } return S_OK; } void Render(void) { pD3DDevice9->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0); pD3DDevice9->BeginScene(); pD3DDevice9->EndScene(); pD3DDevice9->Present(NULL, NULL, NULL, NULL); } void Destroy(void) { if (pD3DDevice9) { pD3DDevice9->Release(); pD3DDevice9 = NULL; } if (pD3D9) { pD3D9->Release(); pD3D9 = NULL; } } LRESULT CALLBACK MsgHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: return 0; break; case WM_CLOSE: PostQuitMessage(0); return 0; break; case WM_DESTROY: PostQuitMessage(0); return 0; break; default: break; } return (DefWindowProc(hwnd, msg, wParam, lParam)); }

Share this post


Link to post
Share on other sites

This topic is 4835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this