Giter Site home page Giter Site logo

direct3d8to9's People

Contributors

actboy168 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

direct3d8to9's Issues

dx8to9之后 疑似 IDirect3DDevice8::CopyRects 失效

在写魔兽后台截图, 发现在ydwe 1.24 以d3d9的模式进游戏 截出来的是全黑的图片 width height信息是正确的
下面这段代码在1.24 dx8的情况下是正常的 疑似 8to9之后 CopyRects 没有正确的把后台缓冲区复制到贴图里。

typedef void(__stdcall* OnCaputeFinish)(const void* buffer, int w, int h);

long OutputDx8Buffer(IDirect3DDevice8* device, OnCaputeFinish callback)
{
IDirect3DSurface8* surface = nullptr;

HRESULT hr = device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &surface);

if (FAILED(hr)) return hr;

D3DSURFACE_DESC surface_desc;
hr = surface->GetDesc(&surface_desc);
if (FAILED(hr)) return hr;

IDirect3DTexture8* texture = nullptr;

IDirect3DSurface8* tex_surface;
hr = device->CreateTexture(surface_desc.Width,
    surface_desc.Height,
    1,
    0,
    surface_desc.Format,
    D3DPOOL_SYSTEMMEM, //必须为这个
    &texture);
if (hr < 0) {
    return hr;
}
hr = texture->GetSurfaceLevel(0, &tex_surface);

if (hr < 0)return hr;


hr = device->CopyRects(surface, NULL, 0, tex_surface, NULL);

D3DLOCKED_RECT d3drc;

texture->LockRect(0, &d3drc, NULL, D3DLOCK_READONLY);

/*取像素*/
d3drc.Pitch >>= 2;

if (callback)
{
    callback(d3drc.pBits, surface_desc.Width, surface_desc.Height);
}

texture->UnlockRect(0);

tex_surface->Release();

texture->Release();

surface->Release();

return hr;

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.