d3dpp.Windowed = false时CreateOffscreenPlainSurface处发生0xC0000005: 读取位置 0x00000000
在win32中提取图片并播放,在运行时总是在g_pd3dDevice->CreateOffscreenPlainSurface(gImageWidth*2, gImageHeight,D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &gImageSrc, NULL)处发生 0xC0000005: 读取位置 0x00000000 时发生访问冲突。
当我把d3dpp.Windowed = false改为d3dpp.Windowed = true时可以正常播放。哪位高手可以告诉我为什么吗?
我的代码
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = false;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hWnd;
d3dpp.BackBufferFormat =D3DFMT_A8R8G8B8;
d3dpp.BackBufferWidth = 1600;
d3dpp.BackBufferHeight = 1200;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
d3dpp.BackBufferCount = 1;
d3dpp.Flags=0;
d3dpp.FullScreen_RefreshRateInHz=D3DPRESENT_RATE_DEFAULT;
g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,hWnd,vp, &d3dpp,&g_pd3dDevice);
//create offscreenplainsurface and load the stereo image "TestPic.bmp" ( width is gImageWidth*2 and height is gImageHeight )
g_pD3D->Release();
g_pd3dDevice->CreateOffscreenPlainSurface(gImageWidth*2, gImageHeight,D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &gImageSrc, NULL);
D3DXLoadSurfaceFromFile(gImageSrc, NULL, NULL,L"E:/猪猪.bmp", NULL, D3DX_FILTER_NONE, 0, NULL);
[解决办法]
能设置1600和1200的后备表面大小吗?