I'm having difficulties rendering just a single pixel which is on the defined coords of viewport. I'm using D3DXMatrixPerspectiveOffCenter function, but the result is not what I expected.
Here is how I calculate the parameters for the function:
// pCamera is the actual camera used to render full screen picture // what is the width and height of camera near plane in Camera Space double dHeight = 2 * pCamera->m_dNear * (tan(pCamera->m_dFOVy/2.0)); double dWidth = dHeight * pCamera->m_dRatioXY; // what is the pixel size in Camera space double dHeightReduced = (dHeight / pCamera->m_dViewportHeight) * CAMERA_1x1px_SIZE; double dWidthReduced = (dWidth / pCamera->m_dViewportWidth) * CAMERA_1x1px_SIZE; // mouse pixel position in Camera space double dCamSpaceX = -0.5*dWidth + double(uiMousePosX) / pCamera->m_dViewportWidth * dWidth; double dCamSpaceY = -0.5*dHeight + double(uiMousePosY) / pCamera->m_dViewportHeight * dHeight; // create matrix D3DXMatrixPerspectiveOffCenterRH( &m_mProjection, (float)(dCamSpaceX), (float)(dCamSpaceX+dWidthReduced), (float)(dCamSpaceY), (float)(dCamSpaceY+dHeightReduced), (float)m_dNear, (float)m_dFar );
(I set CAMERA_1x1px_SIZE = 100 to see a part of the scene, but I see the scene distorted and it's definitely NOT just the cut-off of the original)
How do I need to calc the params to make it work?