繁体   English   中英

在 ID3D11Texture2D 纹理上添加自定义 cursor

[英]Add Custom cursor on ID3D11Texture2D texture

我对 DirectX 完全陌生。 但我将它用于我的屏幕捕获应用程序。 我正在使用桌面复制 API 捕获屏幕。 现在,我要更新Z1791A97A8403730EE0760489A2AEB92Z,而不是原始的Z1791A97A97A8403760489A2AEB992AE2AE2AE2AE2AE2AE2AE2AEYBB92AEENEND9.BINESTAIE DABEYNYPAIE ANDER SHAILE 7917A8407373737371776777776.1AMASENYENEEYN转请帮我看看怎么做?

我有 PTR_INFO(这包含指针的 position、DXGI_OUTDUPL_POINTER_SHAPE_INFO)、ID3D11DeviceContext、ID3D11Device 和ID3D11Texture2D ,我想在其上执行此操作。

提前致谢。

我找到了解决方案。 我试图在下面解释它:

首先,使用以下命令获取 DXGISurface:

hr =ID3D11Texture2D->QueryInterface(IID_PPV_ARGS(&lIDXGISurface1)); // ID3D11Texture2D is the catured texture

下一步是为 CURSORINFO 创建一个 object 以存储有关 cursor 的信息:


lCursorInfo.cbSize = sizeof(lCursorInfo);

auto lBoolres = GetCursorInfo(&lCursorInfo);

if (lBoolres == TRUE)
{
    if (lCursorInfo.flags == CURSOR_SHOWING)
    {
        // currently lCursorInfo.hCursor has the shape of actual cursor that is coming to your system to modify it you can use the below line

        std::string path = "cursor.cur"; // this is path to the file where .cur file available in your system
        lCursorInfo.hCursor = LoadCursorFromFileA(path.c_str());
        // You can refer https://docs.microsoft.com/en-us/windows/win32/menurc/using-cursors for creating your own cursor

        auto lCursorPosition = lCursorInfo.ptScreenPos;
        auto lCursorSize = lCursorInfo.cbSize;
        HDC  lHDC;
        lIDXGISurface1->GetDC(FALSE, &lHDC); // getting handle to draw the cursor
        // Draw the cursor
        DrawIconEx(
            lHDC,
            lCursorPosition.x,
            lCursorPosition.y,
            lCursorInfo.hCursor,
            0,
            0,
            0,
            0,
            DI_NORMAL | DI_DEFAULTSIZE);
        // Release the handle
        lIDXGISurface1->ReleaseDC(nullptr);
    }
}

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM