简体   繁体   English

函数“ public:bool”中引用的未解析的外部符号_D3D10CreateDeviceAndSwapChain @ 32

[英]unresolved external symbol _D3D10CreateDeviceAndSwapChain@32 referenced in function "public: bool

Having trouble creating my swap chain. 创建我的交换链时遇到问题。 I receive the 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 is the code ive done so 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 the window
    RECT rect = { 0, 0, mWidth, mHeight };
    AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);

    // create the window from the 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 the user to press the escape key to end the application
        case WM_KEYDOWN:
            switch(wParam)
            {
                // Check if the user hit the escape key
                case VK_ESCAPE:
                    PostQuitMessage(0);
                break;
            }
        break;

        // The user hit the close button, close the application
        case WM_DESTROY:
            PostQuitMessage(0);
        break;
    }
    return DefWindowProc(hWnd, message, wParam, lParam);
}

You are not linking against the D3D library ( D3D10.lib ). 您没有针对D3D库( D3D10.lib )进行链接。

Add that library to your linker options (Project properties -> Linker -> Input -> Additional Dependencies). 将该库添加到链接器选项(项目属性->链接器->输入->其他依赖项)。 You will need to make sure the library location is in the "Additional Library Directories" path as well. 您还需要确保库位置也在“其他库目录”路径中。

您是否链接到D3D10.lib

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 1&gt; main.obj:错误LNK2001:未解析的外部符号_D3D10CreateDeviceAndSwapChain @ 32 - 1>main.obj : error LNK2001: unresolved external symbol _D3D10CreateDeviceAndSwapChain@32 D3D11CreateDeviceAndSwapChain Unresolved External - D3D11CreateDeviceAndSwapChain Unresolved External 函数中引用的未解析的外部符号 - Unresolved external symbol referenced in function 通过学习现代3D图形编程中的功能代码____tmainCRTStartup中引用的未解析的外部符号_main来编译失败代码 - Compiling failure code from Learning Modern 3D Graphics Programming unresolved external symbol _main referenced in function ___tmainCRTStartup 函数_main中引用的未解析的外部符号“” - unresolved external symbol “” referenced in function _main 函数_main中引用的未解析的外部符号“ *” - Unresolved external symbol “*” referenced in function _main 函数___tmainCRTStartup中引用的未解析的外部符号_main - unresolved external symbol _main referenced in function ___tmainCRTStartup 未解析的外部符号“public:<function_name> ”</function_name> - Unresolved external symbol “public: <function_name>” 未解析的外部符号D3DXSaveSurfaceToFileW - unresolved external symbol D3DXSaveSurfaceToFileW 使用Direct2D的未解析外部符号 - Unresolved external symbol using Direct2D
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM