#include "D3DRender.h"
CD3DRender::CD3DRender()
{
m_pDirect3D9 = NULL;
m_pDirect3DDevice = NULL;
m_pDirect3DSurfaceRender = NULL;
m_bDeviceLost = false;
m_nWidth = 0;
m_nHeight = 0;
ZeroMemory(&m_d3dpp, sizeof(m_d3dpp));
}
CD3DRender::~CD3DRender()
{
}
void CD3DRender::Cleanup()
{
std::lock_guard(&m_D3DMutex);
ReleaseResource();
}
int CD3DRender::Init(HWND hwnd, unsigned int nWidth, unsigned int nHeight, bool isYuv)
{
//已经初始化过
if (m_pDirect3D9)
{
//分辨率发生变化,重新初始化
if (m_nWidth != nWidth || m_nHeight != nHeight)
{
Cleanup();
}
else
{
return 0;
}
}
std::lock_guard(&m_D3DMutex);
HRESULT lRet = -1;
do
{
m_pDirect3D9 = Direct3DCreate9(D3D_SDK_VERSION);
if (m_pDirect3D9 == NULL)
{
break;
}
m_d3dpp.Windowed = TRUE;
m_d3dpp.hDeviceWindow = hwnd;
m_d3dpp.SwapEffect = D3DSWAPEFFECT_COPY;
m_d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
m_d3dpp.EnableAutoDepthStencil = FALSE;
m_d3dpp.Flags = D3DPRESENTFLAG_VIDEO;
m_d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
m_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
m
DirectX 3D渲染yuv/RGB数据模块--D3DRender.cpp
最新推荐文章于 2022-05-19 10:55:40 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)