IDirect3DDevice9 :: GetFrontBufferData失败,出现分段错误 [英] IDirect3DDevice9::GetFrontBufferData fails with segmentation fault

查看:190
本文介绍了IDirect3DDevice9 :: GetFrontBufferData失败,出现分段错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个非常简单的DirectX程序来捕获屏幕。它在我的机器上运行良好,但在以下一行中的另一台机器上却出现分段错误(SIGSEV):

I created a really simple DirectX program to capture the screen. It works well on my machine, but fails on another machine in the following line with a segmentation fault (SIGSEV):

g_pd3dDevice->GetFrontBufferData(0, g_pSurface);

以下函数用于初始化DirectX:

The following function is used to initialize DirectX:

HRESULT InitD3D(HWND hWnd)
{
D3DDISPLAYMODE  ddm;
D3DPRESENT_PARAMETERS   d3dpp;

if((g_pD3D=Direct3DCreate9(D3D_SDK_VERSION))==NULL)
{
    ErrorMessage("Unable to Create Direct3D ");
    return E_FAIL;
}

if(FAILED(g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&ddm)))
{
    ErrorMessage("Unable to Get Adapter Display Mode");
    return E_FAIL;
}

ZeroMemory(&d3dpp,sizeof(D3DPRESENT_PARAMETERS));

d3dpp.Windowed=WINDOW_MODE;
d3dpp.Flags=D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
d3dpp.BackBufferFormat=ddm.Format;
d3dpp.BackBufferHeight=nDisplayHeight=gScreenRect.bottom =ddm.Height;
d3dpp.BackBufferWidth=nDisplayWidth=gScreenRect.right =ddm.Width;
d3dpp.MultiSampleType=D3DMULTISAMPLE_NONE;
d3dpp.SwapEffect=D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow=hWnd;
d3dpp.PresentationInterval=D3DPRESENT_INTERVAL_DEFAULT;
d3dpp.FullScreen_RefreshRateInHz=D3DPRESENT_RATE_DEFAULT;

if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_REF,hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING ,&d3dpp,&g_pd3dDevice)))
{
    ErrorMessage("Unable to Create Device");
    return E_FAIL;
}

if(FAILED(g_pd3dDevice->CreateOffscreenPlainSurface(ddm.Width, ddm.Height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &g_pSurface, NULL)))
{
    ErrorMessage("Unable to Create Surface");
    return E_FAIL;
}

return S_OK;
}

有什么想法为什么会引起分割错误?

Any ideas why this would throw a segmentation fault?

推荐答案

解决方案:DirectX驱动程序未正确安装。

Solution: The DirectX driver was not correctly installed.

这篇关于IDirect3DDevice9 :: GetFrontBufferData失败,出现分段错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆