将图像加载到backbuffer / direct3d / c ++

时间:2011-12-23 01:39:10

标签: c++ directx direct3d

这些是变量:

std::wstring        wsPath = L"./LIFE.bmp"; // path to the image
IDirect3DSurface9   *Surface = NULL;    // image surface
IDirect3DSurface9   *BackBuffer = NULL; // back buffer surface

这是render()函数:

void render(void)
{
    // Check to make sure you have a valid Direct3D device
    if (NULL == pd3dDevice) return;

    pd3dDevice -> Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0);   // clear the back buffer to a blue color

    if (SUCCEEDED(pd3dDevice -> BeginScene()))
    {
        D3DXIMAGE_INFO Info;

        D3DXGetImageInfoFromFile(wsPath.c_str(), &Info);
        pd3dDevice -> CreateOffscreenPlainSurface(Info.Width, Info.Height, Info.Format, D3DPOOL_SYSTEMMEM, &Surface, NULL);

        D3DXLoadSurfaceFromFile(Surface, NULL, NULL, wsPath.c_str(), NULL, D3DX_FILTER_NONE, 0, NULL);

        pd3dDevice -> GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &BackBuffer);
        pd3dDevice -> UpdateSurface(Surface, NULL, BackBuffer, NULL);

        // End the scene
        pd3dDevice -> EndScene();
    }

    // Present the back buffer contents to the display
    pd3dDevice -> Present(NULL, NULL, NULL, NULL);
}

我一直收到这个奇怪的错误:

1>DIRECTX_001.obj : error LNK2019: unresolved external symbol _D3DXLoadSurfaceFromFileW@32 referenced in function "void __cdecl render(void)" (?render@@YAXXZ)
1>DIRECTX_001.obj : error LNK2019: unresolved external symbol _D3DXGetImageInfoFromFileW@8 referenced in function "void __cdecl render(void)" (?render@@YAXXZ)

你能解释一下这里发生了什么吗?谢谢!

1 个答案:

答案 0 :(得分:2)

链接器让你知道它找不到函数D3DXLoadSurfaceFromFile和D3DXGetImageInfoFromFile。

检查链接器设置以确保包含所需的库。

有问题的图书馆是D3dx9.lib。