D3DImage를 통해 내 Direct9 엔진을 새 WPF 응용 프로그램에 통합하려고합니다. Z 버퍼를 제외한 모든 것이 작동합니다. AutoDepthStencil을 false로 설정하면 메시를 렌더링 할 수 있지만 깊이는 작동하지 않습니다. AutoDepthStencil을 활성화하면 아무 것도 그려지지 않습니다.DirectX 9 엔진 Z 버퍼가 D3DImage와 작동하지 않습니다.
m_graphics->GetDeviceD3D()->SetRenderState(D3DRS_LIGHTING, TRUE); // turn off the 3D lighting
m_graphics->GetDeviceD3D()->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(50,50,50));
m_graphics->GetDeviceD3D()->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
m_graphics->GetDeviceD3D()->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);
m_graphics->GetDeviceD3D()->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL);
m_graphics->GetDeviceD3D()->SetRenderState(D3DRS_SPECULARENABLE, TRUE);
m_graphics->GetDeviceD3D()->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); // both sides of the triangles
m_graphics->GetDeviceD3D()->SetRenderState(D3DRS_ZENABLE, TRUE); // turn on the z-buffer
m_graphics->GetDeviceD3D()->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);
m_graphics->GetDeviceD3D()->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESS);
m_graphics->GetDeviceD3D()->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
m_graphics->GetDeviceD3D()->LightEnable(0, TRUE);
재설정 :
m_graphics->GetDeviceD3D()->Clear(0, NULL, D3DCLEAR_TARGET , D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0);
m_graphics->GetDeviceD3D()->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
표면 및 장치 제작 일 동안 둘러보고 및 여성용 프레젠테이션의
MEQ 도움이 아무것도 발견되지 필자는 것은
ZeroMemory(m_pp, sizeof(m_pp));
m_pp->AutoDepthStencilFormat = D3DFMT_D16;
m_pp->BackBufferCount = 1;
m_pp->MultiSampleQuality = 0;
m_pp->Windowed = Windowed;
m_pp->MultiSampleType = D3DMULTISAMPLE_8_SAMPLES;
m_pp->EnableAutoDepthStencil = FALSE;
m_pp->PresentationInterval = D3DPRESENT_INTERVAL_ONE;
m_pp->Windowed = TRUE;
m_pp->BackBufferHeight = 1;
m_pp->BackBufferWidth = 1;
m_pp->SwapEffect = D3DSWAPEFFECT_DISCARD;
m_pp->BackBufferFormat = D3DFMT_A8R8G8B8;
renderStates 매개 변수 :
if (FAILED(m_pD3D9->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWnd,
dwVertexProcessing,
m_pp, NULL, GetDevicePtr())))
{
return NULL;
}
// obtain the standard D3D device interface
if (FAILED(GetDeviceD3D()->QueryInterface(__uuidof(IDirect3DDevice9), reinterpret_cast<void **>(GetDevicePtr()))))
{
return NULL;
}
// create and set the render target surface
// it should be lockable on XP and nonlockable on Vista
if (FAILED(GetDeviceD3D()->CreateRenderTarget(Width, Height,
D3DFMT_A8R8G8B8, D3DMULTISAMPLE_8_SAMPLES, 0,
false, // lockable
GetSurfacePtr(), NULL)))
{
return NULL;
}
GetDeviceD3D()->SetRenderTarget(0, m_surface);
매트릭스 : EnableAutoDepthStencil와
// set the projection transform
D3DXMATRIX matProjection; // the projection transform matrix
D3DXMatrixPerspectiveFovLH(&matProjection,
D3DXToRadian(45), // the horizontal field of view
1.f, // aspect ratio TODO
0.001f, // the near view-plane
1000.0f); // the far view-plane
m_graphics->GetDeviceD3D()->SetTransform(D3DTS_PROJECTION, &matProjection); // set the projection
//CAMERA
D3DXMATRIX matView;
D3DXMatrixLookAtLH(&matView,
&D3DXVECTOR3 (m_scene->Cam->Position.X, m_scene->Cam->Position.Y, m_scene->Cam->Position.Z), // the camera position
&D3DXVECTOR3 (m_scene->Cam->Target.X, m_scene->Cam->Target.Y, m_scene->Cam->Target.Z), // the look-at position
&D3DXVECTOR3 (m_scene->Cam->UpVector.X, m_scene->Cam->UpVector.Y, m_scene->Cam->UpVector.Z)); // the up direction
d3ddev->m_device->SetTransform(D3DTS_VIEW, &matView); // set the view transform to matView
더 나은 매개 변수로 확인 CreateRenderTarget가 같은 폭과 높이를 사용합니다. – zdd
슬프게도 그렇게하기 위해 10 명의 담당자가 필요합니다. gamedev 사이트에서 내 x-post를 확인할 수 있습니다. http://gamedev.stackexchange.com/questions/90290/directx9-engine-z-buffer-problem-with-d3dimage – Benchy
z 버퍼, 내가 짐작할 수있는 유일한 것은 단어 /보기 행렬이 틀렸다는 것입니다. – zdd