c++ - unresolved external symbol _D3D10CreateDeviceAndSwapChain@32 referenced in function "public: bool -
having trouble creating swap chain. receive following error.
dx3dapp.obj : error lnk2019: unresolved external symbol _d3d10createdeviceandswapchain@32 referenced in function "public: bool __thiscall dx3dapp::initdirect3d(void)" (?initdirect3d@dx3dapp@@qae_nxz)
below code ive done far.
#include "dx3dapp.h" bool dx3dapp::init(hinstance hinstance, int width, int height) { mhinst = hinstance; mwidth = width; mheight = height; if(!windowsinit()) { return false; } if(!initdirect3d()) { return false; } } int dx3dapp::run() { msg msg = {0}; while (wm_quit != msg.message) { while (peekmessage(&msg, null, 0, 0, pm_remove) == true) { translatemessage(&msg); dispatchmessage(&msg); } render(); } return (int) msg.wparam; } bool dx3dapp::windowsinit() { wndclassex wcex; wcex.cbsize = sizeof(wndclassex); wcex.style = cs_hredraw | cs_vredraw; wcex.lpfnwndproc = (wndproc)wndproc; wcex.cbclsextra = 0; wcex.cbwndextra = 0; wcex.hinstance = mhinst; wcex.hicon = 0; wcex.hcursor = loadcursor(null, idc_arrow); wcex.hbrbackground = (hbrush)(color_window+1); wcex.lpszmenuname = null; wcex.lpszclassname = text("directxexample"); wcex.hiconsm = 0; registerclassex(&wcex); // resize window rect rect = { 0, 0, mwidth, mheight }; adjustwindowrect(&rect, ws_overlappedwindow, false); // create window class above mmainhwnd = createwindow(text("directxexample"), text("directxexample"), ws_overlappedwindow, cw_usedefault, cw_usedefault, rect.right - rect.left, rect.bottom - rect.top, null, null, mhinst, null); if (!mmainhwnd) { return false; } showwindow(mmainhwnd, sw_show); updatewindow(mmainhwnd); return true; } bool dx3dapp::initdirect3d() { dxgi_swap_chain_desc scd; zeromemory(&scd, sizeof(scd)); scd.buffercount = 1; scd.bufferdesc.width = mwidth; scd.bufferdesc.height = mheight; scd.bufferdesc.format = dxgi_format_b8g8r8a8_unorm; scd.bufferdesc.refreshrate.numerator = 60; scd.bufferdesc.refreshrate.denominator = 1; scd.bufferusage = dxgi_usage_render_target_output; scd.outputwindow = mmainhwnd; scd.sampledesc.count = 1; scd.sampledesc.quality = 0; scd.windowed = true; hresult hr = d3d10createdeviceandswapchain(null,d3d10_driver_type_reference, null, 0, d3d10_sdk_version, &scd, &mpswapchain, &mpd3ddevice); if(!hr != s_ok) { return false; } id3d10texture2d *pbackbuffer; return true; } void dx3dapp::render() { } lresult callback wndproc(hwnd hwnd, uint message, wparam wparam, lparam lparam) { switch (message) { // allow user press escape key end application case wm_keydown: switch(wparam) { // check if user hit escape key case vk_escape: postquitmessage(0); break; } break; // user hit close button, close application case wm_destroy: postquitmessage(0); break; } return defwindowproc(hwnd, message, wparam, lparam); }
you not linking against d3d library (d3d10.lib
).
add library linker options (project properties -> linker -> input -> additional dependencies). need make sure library location in "additional library directories" path well.
Comments
Post a Comment