2013-07-30 5 views
3
내 lib 디렉토리로 지정되어
  // include the basic windows header file 
      #include <windows.h> 
      #include <windowsx.h> 
      #include <d3d11.h> 
      #include <d3dx11.h> 
      #include <d3dx10.h> 

      // include the Direct3D Library file 
      #pragma comment (lib, "d3d11.lib") 
      #pragma comment (lib, "d3dx11.lib") 
      #pragma comment (lib, "d3dx10.lib") 

      // global declarations 
      IDXGISwapChain *swapchain;    // the pointer to the swap chain interface 
      ID3D11Device *dev;      // the pointer to our Direct3D device interface 
      ID3D11DeviceContext *devcon;   // the pointer to our Direct3D device context 

      // function prototypes 
      void InitD3D(HWND hWnd);  // sets up and initializes Direct3D 
      void CleanD3D(void);   // closes Direct3D and releases memory 



      HRESULT D3D11CreateDeviceAndSwapChain(
       IDXGIAdapter *pAdapter, 
       D3D_DRIVER_TYPE DriverType, 
       HMODULE Software, 
       UINT Flags, 
       D3D_FEATURE_LEVEL *pFeatureLevels, 
       UINT FeatureLevels, 
       UINT SDKVersion, 
       DXGI_SWAP_CHAIN_DESC *pSwapChainDesc, 
       IDXGISwapChain **ppSwapChain, 
       ID3D11Device **ppDevice, 
       D3D_FEATURE_LEVEL *pFeatureLevel, 
       ID3D11DeviceContext **ppDeviceContext); 



      // the WindowProc function prototype 
      LRESULT CALLBACK WindowProc(HWND hWnd, 
            UINT message, 
            WPARAM wParam, 
            LPARAM lParam); 



      // the entry point for any Windows program 
      int WINAPI WinMain(HINSTANCE hInstance, 
           HINSTANCE hPrevInstance, 
           LPSTR lpCmdLine, 
           int nCmdShow) 
      { 
       // the handle for the window, filled by a function 
       HWND hWnd; 
       // this struct holds information for the window class 
       WNDCLASSEX wc; 

       // clear out the window class for use 
       ZeroMemory(&wc, sizeof(WNDCLASSEX)); 

       // fill in the struct with the needed information 
       wc.cbSize = sizeof(WNDCLASSEX); 
       wc.style = CS_HREDRAW | CS_VREDRAW; 
       wc.lpfnWndProc = WindowProc; 
       wc.hInstance = hInstance; 
       wc.hCursor = LoadCursor(NULL, IDC_ARROW); 
       wc.hbrBackground = (HBRUSH)COLOR_WINDOW; 
       wc.lpszClassName = L"WindowClass1"; 

       // register the window class 
       RegisterClassEx(&wc); 

       RECT wr = {0, 0, 500, 400}; // set the size, but not the position 
       AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); // adjust the size 

       // create the window and use the result as the handle 
       hWnd = CreateWindowEx(NULL, 
             L"WindowClass1", // name of the window class 
             L"Our First Windowed Program", // title of the window 
             WS_OVERLAPPEDWINDOW, // window style 
             300, // x-position of the window 
             300, // y-position of the window 
             500, // width of the window 
             400, // height of the window 
             NULL, // we have no parent window, NULL 
             NULL, // we aren't using menus, NULL 
             hInstance, // application handle 
             NULL); // used with multiple windows, NULL 

       // display the window on the screen 
       ShowWindow(hWnd, nCmdShow); 

       // enter the main loop: 
       // enter the main loop: 

       // this struct holds Windows event messages 
       MSG msg = {0}; 

       // Enter the infinite message loop 
       while(TRUE) 
       { 
        // Check to see if any messages are waiting in the queue 
        if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) 
        { 
         // translate keystroke messages into the right format 
         TranslateMessage(&msg); 

         // send the message to the WindowProc function 
         DispatchMessage(&msg); 

         // check to see if it's time to quit 
         if(msg.message == WM_QUIT) 
          break; 
        } 
        else 
        { 
         // Run game code here 
         // ... 
         // ... 
        } 
       } 

       // return this part of the WM_QUIT message to Windows 
       return msg.wParam; 
      } 

      // this is the main message handler for the program 
      LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 
      { 
       // sort through and find what code to run for the message given 
       switch(message) 
       { 
        // this message is read when the window is closed 
        case WM_DESTROY: 
         { 
          // close the application entirely 
          PostQuitMessage(0); 
          return 0; 
         } break; 
       } 

       // Handle any messages the switch statement didn't 
       return DefWindowProc (hWnd, message, wParam, lParam); 
      } 

      // this function initializes and prepares Direct3D for use 
      void InitD3D(HWND hWnd) 
      { 
       // create a struct to hold information about the swap chain 
       DXGI_SWAP_CHAIN_DESC scd; 

       // clear out the struct for use 
       ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC)); 

       // fill the swap chain description struct 
       scd.BufferCount = 1;         // one back buffer 
       scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;  // use 32-bit color 
       scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;  // how swap chain is to be used 
       scd.OutputWindow = hWnd;        // the window to be used 
       scd.SampleDesc.Count = 4;        // how many multisamples 
       scd.Windowed = TRUE;         // windowed/full-screen mode 

       // create a device, device context and swap chain using the information in the scd struct 
       D3D11CreateDeviceAndSwapChain(NULL, 
               D3D_DRIVER_TYPE_HARDWARE, 
               NULL, 
               NULL, 
               NULL, 
               NULL, 
               D3D11_SDK_VERSION, 
               &scd, 
               &swapchain, 
               &dev, 
               NULL, 
               &devcon); 
      } 

      // this is the function that cleans up Direct3D and COM 
      void CleanD3D() 
      { 
       // close and release all existing COM objects 
       swapchain->Release(); 
       dev->Release(); 
       devcon->Release(); 
      } 

      Error 29 error LNK2019: unresolved external symbol "long __cdecl D3D11CreateDeviceAndSwapChain(struct IDXGIAdapter *,enum D3D_DRIVER_TYPE,struct HINSTANCE__ *,unsigned int,enum D3D_FEATURE_LEVEL *,unsigned int,unsigned int,struct DXGI_SWAP_CHAIN_DESC *,struct IDXGISwapChain * *,struct ID3D11Device * *,enum D3D_FEATURE_LEVEL *,struct ID3D11DeviceContext * *)" ([email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z) referenced in function "void __cdecl InitD3D(struct HWND__ *)" ([email protected]@[email protected]@@Z) C:\Users\Eric\Documents\Visual Studio 2012\Projects\d3dinit\d3dinit\Source.obj d3dinit 

:Directx11 링커 오류

C : \의 Program Files (x86) \ 마이크로 소프트의 DirectX SDK (6 월 2010) \ lib 디렉토리 \ 64

뿐만 아니라 내 링커 설정 지정 이러한 libs가 :

d3d11.lib d3dx11.lib d3dx10.lib

내가 코드 블록의 끝 부분에 붙여 넣은 링커 오류. 링커 오류의 원인이 무엇일까 궁금합니다. 사전에

감사합니다 ...

+0

언제든지 VS에서 프로젝트의 디버그 구성을 컴파일하고 있습니까? – JBL

+0

예. x86이나 x64를 사용할 라이브러리를 찾는 데 어려움이있었습니다. x64 프로세서가 있지만 x86 라이브러리와 함께 프로그램이 가장 잘 작동하는 것 같습니다. 이유는 확실하지 않습니다. – Giuseppe

답변

3

D3D11CreateDeviceAndSwapChain 앞으로 선언은 잘못된 것입니다. pFeatureLevels 및 pSwapChainDesc에 대한 포인터는 const 여야합니다. 이것은 링커가 약간 다른 D3D11CreateDeviceAndSwapChain 함수를 찾고 찾을 수 없다는 것을 의미합니다. 가장 간단한 방법은 D3D11CreateDeviceAndSwapChain 전달 선언을 제거하는 것입니다.

BTW dx11을 사용할 때 dx10 헤더 및 링크 dx10 라이브러리를 포함 할 필요가 없습니다. 또한 DXSDK는 더 이상 사용되지 않으며 Windows8 SDK으로 대체되었습니다.