コード例 #1
0
ファイル: Magnify.cpp プロジェクト: KNeal/Oculus
void Magnify::RenderMagnifiedRegion()
{
	m_Sprite.SetUVs( ( m_nPositionX - m_nHalfPixelRegion ) / (float)m_nSourceResourceWidth,
		( m_nPositionY - m_nHalfPixelRegion ) / (float)m_nSourceResourceHeight,
		( m_nPositionX + m_nHalfPixelRegion ) / (float)m_nSourceResourceWidth,
		( m_nPositionY + m_nHalfPixelRegion ) / (float)m_nSourceResourceHeight );

	if( m_bDepthFormat )
	{
		D3DXCOLOR Color( 0xffffffff );
		m_Sprite.SetBorderColor( Color );

		if( m_nSourceResourceSamples > 1 )
		{
			// Get the current render and depth targets, so we can later revert to these
			ID3D10RenderTargetView *pRenderTargetView;
			ID3D10DepthStencilView *pDepthStencilView;
			DXUTGetD3D10Device()->OMGetRenderTargets( 1, &pRenderTargetView, &pDepthStencilView );

			// Bind our render target view to the OM stage
			DXUTGetD3D10Device()->OMSetRenderTargets( 1, (ID3D10RenderTargetView* const*)&pRenderTargetView, NULL );
			
			m_Sprite.RenderSpriteAsDepthMS( m_pSourceResourceSRV1, (m_nPositionX - m_nHalfPixelRegion * m_nScale), 
				(m_nPositionY + m_nHalfPixelRegion * m_nScale), (m_nPixelRegion * m_nScale), 
				(m_nPixelRegion * m_nScale), m_nSourceResourceWidth, m_nSourceResourceHeight, true, 
				m_fDepthRangeMin, m_fDepthRangeMax, m_nSubSampleIndex );

			// Bind back to the original render, depth target, and viewport
			DXUTGetD3D10Device()->OMSetRenderTargets( 1, (ID3D10RenderTargetView* const*)&pRenderTargetView, pDepthStencilView );

			// Decrement the counter on these resources
			SAFE_RELEASE( pRenderTargetView );
			SAFE_RELEASE( pDepthStencilView );
		}
		else
		{
			m_Sprite.RenderSpriteAsDepth( m_pCopySourceResourceSRV, (m_nPositionX - m_nHalfPixelRegion * m_nScale), 
				(m_nPositionY + m_nHalfPixelRegion * m_nScale), (m_nPixelRegion * m_nScale), 
				(m_nPixelRegion * m_nScale), true, m_fDepthRangeMin, m_fDepthRangeMax );
		}
	}
    else
    {
        D3DXCOLOR Color( 0xff000000 );
        m_Sprite.SetBorderColor( Color );

        if( m_nSourceResourceSamples > 1 )
        {
            m_Sprite.RenderSprite( m_pResolvedSourceResourceSRV, (m_nPositionX - m_nHalfPixelRegion * m_nScale), 
                (m_nPositionY + m_nHalfPixelRegion * m_nScale), (m_nPixelRegion * m_nScale), 
                (m_nPixelRegion * m_nScale), false, true ); 
        }
        else
        {
            m_Sprite.RenderSprite( m_pCopySourceResourceSRV, (m_nPositionX - m_nHalfPixelRegion * m_nScale), 
                (m_nPositionY + m_nHalfPixelRegion * m_nScale), (m_nPixelRegion * m_nScale), 
                (m_nPixelRegion * m_nScale), false, true ); 
        }
    }
}
コード例 #2
0
/**
 * @fn ~CDXRTRestorer()
 *
 * @brief Class destructor
 *
 * @note Sets the current render targets and viewports on the output device,
 *       releases all render target views and the depth stencil view
 */
CDXRTRestorer::~CDXRTRestorer()
{
    DXUTGetD3D10Device()->OMSetRenderTargets(MAX_RTVS, m_ppRTVs, m_pDSV);
    DXUTGetD3D10Device()->RSSetViewports(m_numViewports, m_viewports);
    for (int i = 0; i < MAX_RTVS; i++)
    {
        SAFE_RELEASE(m_ppRTVs[i]);
    }
    SAFE_RELEASE(m_pDSV);
}
コード例 #3
0
/**
 * @fn SetIt()
 *
 * @brief Sets the device render target views and the viewport on the output device
 */
void CDXRenderTarget::SetIt()
{
    // Set the device render targets
    DXUTGetD3D10Device()->OMSetRenderTargets(1, &m_pRTV, NULL);
    // Define the viewport
    D3D10_VIEWPORT viewport;
    viewport.TopLeftX = 0;
    viewport.TopLeftY = 0;
    viewport.Width  = m_width;
    viewport.Height = m_height;
    viewport.MinDepth = 0.0f;
    viewport.MaxDepth = 1.0f;
    // Then set it.
    DXUTGetD3D10Device()->RSSetViewports(1, &viewport);
}
コード例 #4
0
/*
NB:the input data of vertex shader should be
float3 Position	: POSITION; //not float4
float3 Normal	: NORMAL;   //not float4
float2 UV		: TEXCOORD0;//not float4
It all depends on the sdkmesh that you are using. 
*/
void InitCGRambler()
{
	g_pSceneManager=SceneManager::getSingleton();
	g_pSceneManager->init( DXUTGetD3D10Device());

	g_pCamera=g_pSceneManager->getCamera();
	g_pCamera->setPosition(D3DXVECTOR3(0.0f,0.0f,-3));

	LightPtr light=g_pSceneManager->createLight("SpotLight",D3DXVECTOR3(20.0f,20.0f,-14.0f),D3DXVECTOR3(0.0f,0.0f,0.0f), D3DXVECTOR4(1.0f,1.0f,1.0f,1.0f),30.0f,2.0f);

	//	EffectPtr pEffect=g_pSceneManager->createEffect("effectName","Phong.fx");
	EffectPtr pEffect=g_pSceneManager->createEffect("effectName","Phong.fx");

	int i;
	int num=1;
	float offset=4;
	for(i=0;i<num;i++)
	{
		MeshInstancePtr pMesh=g_pSceneManager->createMesh("meshName","dragon.sdkmesh","");
		pMesh->setLOD(false,2);
		pMesh->setPosition( D3DXVECTOR3( 0 , 0.0f , (i-num/2)*offset ));
		// pMesh->setDirection( D3DXVECTOR3(-1,0,0) );
		// pMesh->setSize( D3DXVECTOR3(0.01f,0.01f,0.01f) );
		pEffect->addMesh(pMesh);
	}


}
コード例 #5
0
//--------------------------------------------------------------------------------------
// Handles the GUI events
//--------------------------------------------------------------------------------------
void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext )
{
    switch( nControlID )
    {
        case IDC_TOGGLEFULLSCREEN:
            DXUTToggleFullScreen(); break;
        case IDC_TOGGLEREF:
            DXUTToggleREF(); break;
        case IDC_CHANGEDEVICE:
            g_D3DSettingsDlg.SetActive( !g_D3DSettingsDlg.IsActive() ); break;
        case IDC_TOGGLEWARP:
            DXUTToggleWARP(); break;
        case IDC_TOGGLE_BLUR:
            g_bUseMotionBlur = !g_bUseMotionBlur;
            break;
        case IDC_RENDER_OGRE:
            g_bRenderOgre = !g_bRenderOgre;
            break;
        case IDC_SAMPLE_COUNT:
        {
            CDXUTComboBox* pComboBox = ( CDXUTComboBox* )pControl;

            g_MSAASampleCount = ( UINT )PtrToInt( pComboBox->GetSelectedData() );

            HRESULT hr = S_OK;
            ID3D10Device* pd3dDevice = DXUTGetD3D10Device();
            if( pd3dDevice )
                V( CreateRenderTarget( pd3dDevice, g_BackBufferWidth, g_BackBufferHeight, g_MSAASampleCount, 0 ) );
        }
            break;
    }
}
コード例 #6
0
/**
 * @fn Render()
 *
 * @brief Renders the quad
 */
void CDXQuad::Render()
{
    // Get the output device
    ID3D10Device *pDev = DXUTGetD3D10Device();
    // Set the output topology
    pDev->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
    // Set the vertex buffer and input layout, then render
    UINT offset = 0;
    pDev->IASetVertexBuffers(0, 1, &m_pVBuff, (UINT*)&m_vertexSize, &offset);
    pDev->Draw(4, 0);
}
コード例 #7
0
/**
 * @fn Resize (int w, int h)
 *
 * @brief Resizes the render target, creates new textures and views 
 *
 * @param w - New resource width
 *
 * @param h - New resource height
 */
void CDXRenderTarget::Resize(int resW, int resH)
{
    HRESULT hr;

    SAFE_RELEASE(m_pSRV);
    SAFE_RELEASE(m_pRTV);
    SAFE_RELEASE(m_pTexture);
    SAFE_RELEASE(m_pTextureCPU); 
    
    // Save the new values
    m_width = resW;
    m_height = resH;

    // Get the device
    ID3D10Device *pDev = DXUTGetD3D10Device();

    // Create the texture here
    CD3D10_TEXTURE2D_DESC desc(m_fmt, resW, resH, 1, 1);
    desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
    desc.Usage     = D3D10_USAGE_DEFAULT;
    hr = pDev->CreateTexture2D(&desc, NULL, &m_pTexture);
    assert(hr == S_OK);

    // Create the CPU version of the texture here
    CD3D10_TEXTURE2D_DESC descCPU(m_fmt, resW, resH, 1, 1);
    descCPU.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
    descCPU.Usage          = D3D10_USAGE_DYNAMIC;
    hr = pDev->CreateTexture2D(&descCPU, NULL, &m_pTextureCPU);
    assert(hr == S_OK);

    // Create the shader resource view
    D3D10_SHADER_RESOURCE_VIEW_DESC resDesc;
    resDesc.Format = m_fmt;
    resDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
    resDesc.Texture2D.MipLevels = 1;
    resDesc.Texture2D.MostDetailedMip = 0;
    hr = pDev->CreateShaderResourceView(m_pTexture, &resDesc, &m_pSRV);
    assert(hr == S_OK);

    // Create the render target view
    D3D10_RENDER_TARGET_VIEW_DESC rtDesc;
    rtDesc.Format = m_fmt;
    rtDesc.ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2D;
    rtDesc.Texture2D.MipSlice = 0;
    
    hr = pDev->CreateRenderTargetView(m_pTexture, &rtDesc, &m_pRTV);
    assert(hr == S_OK);

} // End of resize()
コード例 #8
0
ファイル: Interface.cpp プロジェクト: apjones6/Tetris
	void Panel::Initialize()
	{
		HRESULT hr;
		ID3D10Device* pd3dDevice = DXUTGetD3D10Device();

		const float lt = mX - mW / 2.0f;
		const float rt = mX + mW / 2.0f;
		const float tp = mY + mH / 2.0f;
		const float bm = mY - mH / 2.0f;

		// Static vertex data
		dxut::Vertex v[] = 
			{
				{ D3DXVECTOR3(lt, bm, 1.0f), mColor },
				{ D3DXVECTOR3(lt, tp, 1.0f), mColor },
				{ D3DXVECTOR3(rt, bm, 1.0f), mColor },
				{ D3DXVECTOR3(rt, tp, 1.0f), mColor }
			};

		D3D10_BUFFER_DESC bufferDesc;
		D3D10_SUBRESOURCE_DATA initData;

		// Create vertex buffer
		bufferDesc.Usage = D3D10_USAGE_IMMUTABLE;
		bufferDesc.ByteWidth = sizeof(dxut::Vertex) * 4;
		bufferDesc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
		bufferDesc.CPUAccessFlags = 0;
		bufferDesc.MiscFlags = 0;
		initData.pSysMem = v;
		V(pd3dDevice->CreateBuffer(&bufferDesc, &initData, &mVB));

		// Create index data
		DWORD indices[] =
			{
				0, 1, 2,
				1, 3, 2
			};

		// Create index buffer
		bufferDesc.Usage = D3D10_USAGE_DEFAULT;
		bufferDesc.ByteWidth = sizeof(DWORD) * 6;
		bufferDesc.BindFlags = D3D10_BIND_INDEX_BUFFER;
		bufferDesc.CPUAccessFlags = 0;
		bufferDesc.MiscFlags = 0;
		initData.pSysMem = indices;
		V(pd3dDevice->CreateBuffer(&bufferDesc, &initData, &mIB));
	}
コード例 #9
0
/**
 * @fn Quad()
 *
 * @brief Class constructor, initializes resource data and creates a D3D10 device buffer
 */
CDXQuad::CDXQuad()
{
    m_vertexSize = sizeof(D3DXVECTOR2);
    m_numIndices = 4;

    D3DXVECTOR2 quad[4] = { D3DXVECTOR2(0.0f, 0.0f), D3DXVECTOR2(0.0f, 1.0f), D3DXVECTOR2(1.0f, 0.0f), D3DXVECTOR2(1.0f, 1.0f) };

    D3D10_SUBRESOURCE_DATA initData;
    initData.pSysMem          = quad;
    initData.SysMemPitch      = 0;
    initData.SysMemSlicePitch = 0;

    CD3D10_BUFFER_DESC desc(4 * sizeof(D3DXVECTOR2), D3D10_BIND_VERTEX_BUFFER, D3D10_USAGE_IMMUTABLE);
    HRESULT hr = DXUTGetD3D10Device()->CreateBuffer(&desc, &initData, &m_pVBuff);
    assert(hr == S_OK);
    hr;
}
コード例 #10
0
//--------------------------------------------------------------------------------------
// Load new model
//--------------------------------------------------------------------------------------
static void LoadNewModel(bool bNeedUI = false)
{
    BOOL bResult = TRUE;
    if( bResult )
    {
        g_MeshScene.Destroy();
        // setup the camera view parameters
		static const UINT static_obj_num = 2;
		LPCTSTR	pSceneFileNames[static_obj_num] = {
			STATIC_OBJECT_SOURCE0,
			STATIC_OBJECT_SOURCE1,
		};

		if( g_MeshScene.Create( WARRIOR_MESH_SOURCE,
								WARRIOR_ANIM_SOURCE,
								WINDMILL_BASE_SOURCE,
								WINDMILL_FAN_SOURCE,
								PLANE_SOURCE,
								pSceneFileNames,
								static_obj_num,
								(D3D10_INPUT_ELEMENT_DESC*)suitlayout,//defined in OGRE_LAYOUT.H
								(D3D10_INPUT_ELEMENT_DESC*)bodylayout,//defined in OGRE_LAYOUT.H
								(D3D10_INPUT_ELEMENT_DESC*)scenemeshlayout,//defined in OGRE_LAYOUT.H
								DXUTGetD3D10Device()
								)
		   )

        {
            MessageBox(DXUTGetHWND(), L"Could not load geometry from sunclock.x", L"Error", MB_OK);
            exit(0);
        }
        D3DXVECTOR3 vLight[NUM_LIGHT]		= LIGHT_POS;
        D3DXVECTOR3 vLookAt		= LOOK_AT_POS;

		//light management
		for( int light_idx = 0; light_idx < NUM_LIGHT; ++light_idx )
		{
			g_LCamera[light_idx].SetViewParams(&vLight[light_idx], &vLookAt);
		}

    }
}
コード例 #11
0
/**
 * @fn RenderBoundary(XFormMaterial &mat, int techIndex)
 *
 * @brief Renders the quad
 *
 * @param mat - The material to render
 *
 * @param techIndex - Technique index
 */
void CDXQuadWithBoundary::RenderBoundary(XFormMaterial &mat, int techIndex)
{
    D3DXVECTOR4 xform[2];

    // Construct the transformation vector
    Region2XForm(xform[0], -1.0f, -1.0f, 1.0f, 1.0f);
    Region2XForm(xform[1], 0.0f, 0.0f, 1.0f, 1.0f);
    // Set it
    mat.SetXForm(xform);
    // Apply the rendering techique
    mat.Apply(techIndex);

    // Get the device
    ID3D10Device *pDev = DXUTGetD3D10Device();
    // Set the output topology
    pDev->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP);
    // Set the index buffer
    pDev->IASetIndexBuffer(m_pIB, DXGI_FORMAT_R32_UINT, 0);
    // Set the vertex buffer and input layout, then render
    UINT offset = 0;
    pDev->IASetVertexBuffers(0, 1, &m_pVBuff, (UINT*)&m_vertexSize, &offset);
    // Draw four lines
    pDev->DrawIndexed(4, 0, 0);
}
コード例 #12
0
ファイル: MagnifyTool.cpp プロジェクト: KNeal/Oculus
void MagnifyTool::CreateDepthStencil( ID3D10Device* pd3dDevice, IDXGISwapChain *pSwapChain, 
		const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext )
{
    DXGI_FORMAT DepthFormat;
    HRESULT hr;

    SAFE_RELEASE( m_pDepthStencil );
    SAFE_RELEASE( m_pDSV );
    SAFE_RELEASE( m_pRState );

    switch( DXUTGetDeviceSettings().d3d10.AutoDepthStencilFormat )
    {
        case DXGI_FORMAT_D32_FLOAT:
            DepthFormat = DXGI_FORMAT_R32_TYPELESS;
            break;

        case DXGI_FORMAT_D24_UNORM_S8_UINT:
            DepthFormat = DXGI_FORMAT_R24G8_TYPELESS;
            break;

        case DXGI_FORMAT_D16_UNORM:
            DepthFormat = DXGI_FORMAT_R16_TYPELESS;
            break;

        default:
            DepthFormat = DXGI_FORMAT_UNKNOWN;
            break;
    }
    assert( DepthFormat != DXGI_FORMAT_UNKNOWN );

    // Create depth stencil texture
    D3D10_TEXTURE2D_DESC descDepth;
    descDepth.Width = pBackBufferSurfaceDesc->Width;
    descDepth.Height = pBackBufferSurfaceDesc->Height;
    descDepth.MipLevels = 1;
    descDepth.ArraySize = 1;
    descDepth.Format = DepthFormat;
    descDepth.SampleDesc.Count = DXUTGetDeviceSettings().d3d10.sd.SampleDesc.Count;
    descDepth.SampleDesc.Quality = DXUTGetDeviceSettings().d3d10.sd.SampleDesc.Quality;
    descDepth.Usage = D3D10_USAGE_DEFAULT;
    descDepth.BindFlags = D3D10_BIND_DEPTH_STENCIL;

    if( ( descDepth.SampleDesc.Count == 1 ) || DXUTGetD3D10Device1() )
    {
        descDepth.BindFlags |= D3D10_BIND_SHADER_RESOURCE;
    }

    descDepth.CPUAccessFlags = 0;
    descDepth.MiscFlags = 0;
    hr = pd3dDevice->CreateTexture2D( &descDepth, NULL, &m_pDepthStencil );
    assert( D3D_OK == hr );
       
    // Create the depth stencil view
    D3D10_DEPTH_STENCIL_VIEW_DESC descDSV;
    descDSV.Format = DXUTGetDeviceSettings().d3d10.AutoDepthStencilFormat;
    if( descDepth.SampleDesc.Count > 1 )
    {
        descDSV.ViewDimension = D3D10_DSV_DIMENSION_TEXTURE2DMS;
    }
    else
    {
        descDSV.ViewDimension = D3D10_DSV_DIMENSION_TEXTURE2D;
    }
    descDSV.Texture2D.MipSlice = 0;

    hr = pd3dDevice->CreateDepthStencilView( m_pDepthStencil, &descDSV, &m_pDSV );
    assert( D3D_OK == hr );
      
    // Create a default rasterizer state that enables MSAA
    D3D10_RASTERIZER_DESC RSDesc;
    RSDesc.FillMode = D3D10_FILL_SOLID;
    RSDesc.CullMode = D3D10_CULL_BACK;
    RSDesc.FrontCounterClockwise = FALSE;
    RSDesc.DepthBias = 0;
    RSDesc.SlopeScaledDepthBias = 0.0f;
    RSDesc.DepthBias = 0;
    RSDesc.DepthClipEnable = TRUE;
    RSDesc.ScissorEnable = FALSE;
    RSDesc.AntialiasedLineEnable = FALSE;
    if( descDepth.SampleDesc.Count > 1 )
    {
        RSDesc.MultisampleEnable = TRUE;
    }
    else
    {
        RSDesc.MultisampleEnable = FALSE;
    }

    hr = pd3dDevice->CreateRasterizerState( &RSDesc, &m_pRState );
    assert( D3D_OK == hr );

    pd3dDevice->RSSetState( m_pRState );

    // Get the current render and depth targets, so we can later revert to these.
    ID3D10RenderTargetView *pRenderTargetView;
    DXUTGetD3D10Device()->OMGetRenderTargets( 1, &pRenderTargetView, NULL );

    // Bind our render target view to the OM stage.
    DXUTGetD3D10Device()->OMSetRenderTargets( 1, (ID3D10RenderTargetView* const*)&pRenderTargetView, m_pDSV );

    // Decrement the counter on these resources
    SAFE_RELEASE( pRenderTargetView );
}
コード例 #13
0
ファイル: Magnify.cpp プロジェクト: KNeal/Oculus
void Magnify::CreateInternalResources()
{
    HRESULT hr;

    SAFE_RELEASE( m_pResolvedSourceResourceSRV );
    SAFE_RELEASE( m_pCopySourceResourceSRV );
    SAFE_RELEASE( m_pSourceResourceSRV1 );
    SAFE_RELEASE( m_pResolvedSourceResource );
    SAFE_RELEASE( m_pCopySourceResource );

    D3D10_TEXTURE2D_DESC Desc;
    ZeroMemory( &Desc, sizeof( Desc ) );
    Desc.Width = m_nBackBufferWidth;
    Desc.Height = m_nBackBufferHeight;
    Desc.MipLevels = 1;
    Desc.ArraySize = 1;
    Desc.Format = ( m_bDepthFormat ) ? ( m_DepthFormat ) : ( m_SourceResourceFormat );
    Desc.SampleDesc.Count = 1;
    Desc.Usage = D3D10_USAGE_DEFAULT;
    Desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;

    hr = DXUTGetD3D10Device()->CreateTexture2D( &Desc, NULL, &m_pResolvedSourceResource );
    assert( D3D_OK == hr );

    Desc.SampleDesc.Count = m_nSourceResourceSamples;

    hr = DXUTGetD3D10Device()->CreateTexture2D( &Desc, NULL, &m_pCopySourceResource );
    assert( D3D_OK == hr );

    if( m_bDepthFormat )
    {
        if( m_nSourceResourceSamples > 1 )
        {
            if( NULL != DXUTGetD3D10Device1() )
            {
                D3D10_SHADER_RESOURCE_VIEW_DESC1 SRDesc1;
                SRDesc1.Format = m_DepthSRVFormat;
                SRDesc1.ViewDimension = D3D10_1_SRV_DIMENSION_TEXTURE2DMS;

                hr = DXUTGetD3D10Device1()->CreateShaderResourceView1( m_pSourceResource, &SRDesc1, &m_pSourceResourceSRV1 );
                assert( D3D_OK == hr );
            }
        }
        else
        {
            D3D10_SHADER_RESOURCE_VIEW_DESC SRDesc;
            SRDesc.Format = m_DepthSRVFormat;
            SRDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
            SRDesc.Texture2D.MostDetailedMip = 0;
            SRDesc.Texture2D.MipLevels = 1;

            hr = DXUTGetD3D10Device()->CreateShaderResourceView( m_pCopySourceResource, &SRDesc, &m_pCopySourceResourceSRV );
            assert( D3D_OK == hr );
        }
    }
    else
    {
        if( m_nSourceResourceSamples > 1 )
        {
            hr = DXUTGetD3D10Device()->CreateShaderResourceView( m_pResolvedSourceResource, NULL, &m_pResolvedSourceResourceSRV );
            assert( D3D_OK == hr );
        }
        else
        {
            hr = DXUTGetD3D10Device()->CreateShaderResourceView( m_pCopySourceResource, NULL, &m_pCopySourceResourceSRV );
            assert( D3D_OK == hr );
        }
    }
}
コード例 #14
0
ファイル: Magnify.cpp プロジェクト: KNeal/Oculus
void Magnify::RenderBackground()
{
	if( m_bDepthFormat )
	{
		if( m_nSourceResourceSamples == 1 )
		{
			DXUTGetD3D10Device()->CopyResource( m_pCopySourceResource, m_pSourceResource );
		}
	}
	else
	{
		if( m_nSourceResourceSamples > 1 )
		{
			DXUTGetD3D10Device()->ResolveSubresource( m_pResolvedSourceResource, 0, 
				m_pSourceResource, 0, m_SourceResourceFormat );
		}
		else
		{
			DXUTGetD3D10Device()->CopyResource( m_pCopySourceResource, m_pSourceResource );

		}
	}

	if( m_bDepthFormat )
	{
		if( m_nSourceResourceSamples > 1 )
		{
			// Get the current render and depth targets, so we can later revert to these.
			ID3D10RenderTargetView *pRenderTargetView;
			ID3D10DepthStencilView *pDepthStencilView;
			DXUTGetD3D10Device()->OMGetRenderTargets( 1, &pRenderTargetView, &pDepthStencilView );

			// Bind our render target view to the OM stage.
			DXUTGetD3D10Device()->OMSetRenderTargets( 1, (ID3D10RenderTargetView* const*)&pRenderTargetView, NULL );
			
			m_Sprite.SetUVs( 0.0f, 0.0f, 1.0f, 1.0f );

			m_Sprite.RenderSpriteAsDepthMS( m_pSourceResourceSRV1, 0, m_nBackBufferHeight, 
				m_nBackBufferWidth, m_nBackBufferHeight, m_nBackBufferWidth, m_nBackBufferHeight, 
				false, m_fDepthRangeMin, m_fDepthRangeMax, m_nSubSampleIndex );

			// Bind back to the original render, depth target, and viewport
			DXUTGetD3D10Device()->OMSetRenderTargets( 1, (ID3D10RenderTargetView* const*)&pRenderTargetView, pDepthStencilView );

			// Decrement the counter on these resources
			SAFE_RELEASE( pRenderTargetView );
			SAFE_RELEASE( pDepthStencilView );
		}
		else
		{
			m_Sprite.SetUVs( 0.0f, 0.0f, 1.0f, 1.0f );

			m_Sprite.RenderSpriteAsDepth( m_pCopySourceResourceSRV, 0, m_nBackBufferHeight, 
				m_nBackBufferWidth, m_nBackBufferHeight, false, m_fDepthRangeMin, m_fDepthRangeMax );
		}
	}
	else
	{
		m_Sprite.SetUVs( 0.0f, 0.0f, 1.0f, 1.0f );

		if( m_nSourceResourceSamples > 1 )
		{
			m_Sprite.RenderSprite( m_pResolvedSourceResourceSRV, 0, m_nBackBufferHeight, 
				m_nBackBufferWidth, m_nBackBufferHeight, false, false );
		}
		else
		{
			m_Sprite.RenderSprite( m_pCopySourceResourceSRV, 0, m_nBackBufferHeight, 
				m_nBackBufferWidth, m_nBackBufferHeight, false, false );
		}
	}
}
コード例 #15
0
/**
 * @fn CDXRTRestorer()
 *
 * @brief Class constructor
 *
 * @note Gets the current render targets and viewports from the output device
 */
CDXRTRestorer::CDXRTRestorer()
{
    DXUTGetD3D10Device()->OMGetRenderTargets(MAX_RTVS, m_ppRTVs, &m_pDSV);
    m_numViewports = MAX_RTVS;
    DXUTGetD3D10Device()->RSGetViewports(&m_numViewports, m_viewports);
}