void CameraEffect::beginScene(unsigned int clearMode, const Vector4f& clearColor) { _effectBlocked = true; assert( Camera::_currentCamera == NULL ); Camera::_currentCamera = this; // frame synchronization phase Frame::synchronizeAll(); _dxCR( iDirect3DDevice->SetViewport( &_viewPort ) ); if( _currentEffect == engine::pfxNone || _currentEffect == engine::pfxBloom ) { IDirect3DSurface9* iDirect3DSurface; _renderTarget->iDirect3DTexture()->GetSurfaceLevel( 0, &iDirect3DSurface ); _dxCR( _rts->BeginScene( iDirect3DSurface, &_viewPort ) ); iDirect3DSurface->Release(); } else { IDirect3DSurface9* iDirect3DSurface; _newImage->iDirect3DTexture()->GetSurfaceLevel( 0, &iDirect3DSurface ); _dxCR( _rts->BeginScene( iDirect3DSurface, &_viewPort ) ); iDirect3DSurface->Release(); } if( clearMode ) _dxCR( iDirect3DDevice->Clear( 0, NULL, clearMode, wrap( clearColor ), 1.0f, 0L ) ); // setup transformation matrices if( _frame ) { D3DXMatrixInverse( &Camera::viewMatrix, NULL, &_frame->LTM ); _dxCR( iDirect3DDevice->SetTransform( D3DTS_VIEW, &Camera::viewMatrix ) ); } Camera::projectionMatrix = _projection; _dxCR( iDirect3DDevice->SetTransform( D3DTS_PROJECTION, &_projection ) ); Camera::viewPort = _viewPort; Camera::eyePos = dxPos( &_frame->LTM ); Camera::eyeDirection = dxAt( &_frame->LTM ); Camera::fov = _fov; Camera::nearClipPlane = _nearClipPlane; Camera::farClipPlane = _farClipPlane; // normalize camera eye D3DXVec3Normalize( &eyeDirection, &eyeDirection ); // frustrum planes updateFrustrum(); }
void ScreenCamera::beginScene(unsigned int clearMode, const Vector4f& clearColor) { assert( Camera::_currentCamera == NULL ); Camera::_currentCamera = this; // frame synchronization phase Frame::synchronizeAll(); _dxCR( iDirect3DDevice->SetViewport( &_viewPort ) ); if( clearMode ) _dxCR( iDirect3DDevice->Clear( 0, NULL, clearMode, wrap( clearColor ), 1.0f, 0L ) ); _dxCR( iDirect3DDevice->BeginScene() ); // setup transformation matrices if( _frame ) { D3DXMatrixInverse( &viewMatrix, NULL, &_frame->LTM ); _dxCR( iDirect3DDevice->SetTransform( D3DTS_VIEW, &viewMatrix ) ); } projectionMatrix = _projection; _dxCR( iDirect3DDevice->SetTransform( D3DTS_PROJECTION, &_projection ) ); viewPort = _viewPort; eyePos = dxPos( &_frame->LTM ); eyeDirection = dxAt( &_frame->LTM ); fov = _fov; nearClipPlane = _nearClipPlane; farClipPlane = _farClipPlane; // normalize camera eye D3DXVec3Normalize( &eyeDirection, &eyeDirection ); // update frustrum planes updateFrustrum(); }