当前位置: 首页>>代码示例>>C++>>正文


C++ SmartPtr::GetWindowWidthAndHeight方法代码示例

本文整理汇总了C++中SmartPtr::GetWindowWidthAndHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ SmartPtr::GetWindowWidthAndHeight方法的具体用法?C++ SmartPtr::GetWindowWidthAndHeight怎么用?C++ SmartPtr::GetWindowWidthAndHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SmartPtr的用法示例。


在下文中一共展示了SmartPtr::GetWindowWidthAndHeight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetViewWidthAndHeight

HRESULT CameraMoveTool::GetViewWidthAndHeight(__in IViewController *pView, __out UINT &width, __out UINT &height)
{
	HRESULT hr;

	SmartPtr<IViewControllerScene> spViewSceneController;
	hr = pView->QueryInterface(&spViewSceneController);

	if (SUCCEEDED(hr))
	{
		SmartPtr<IRenderer> spRenderer;
		hr = spViewSceneController->GetRenderer(&spRenderer);
		if (SUCCEEDED(hr))
		{
			spRenderer->GetWindowWidthAndHeight(width, height);
		}
	}
	return hr;
}
开发者ID:kovacik,项目名称:DeepZoom,代码行数:18,代码来源:CameraMoveTool.cpp

示例2: Draw

HRESULT RenderableText::Draw(UINT passIndex, __in IRendererHandler *pRenderer)
{	
    UNREFERENCED_PARAMETER(passIndex);

    XMMATRIX viewMatrix, projectionMatrix;
    HRESULT hr = pRenderer->GetCameraMatrices(&viewMatrix, &projectionMatrix);
    IF_FAILED_RETURN(hr);

    // Get suitable renderer
    SmartPtr<IRenderer> spRenderer;
    hr = pRenderer->QueryInterface(&spRenderer);
    IF_FAILED_RETURN(hr);

    UINT screenWidth = 0, screenHeight = 0;
    spRenderer->GetWindowWidthAndHeight(screenWidth, screenHeight);

    // Transform text position to screen coordinates
    XMFLOAT3 screenCoordinatesPosition;
    XMMATRIX worldMatrix = m_spSceneObjectText.CastTo<ISceneObject>()->GetWorldTransform();
    XMVECTOR textPosition = XMLoadFloat3(&m_spSceneObjectText->GetPosition());
    XMVECTOR transformedTextPosition = XMVector3Project(textPosition, 0, 0, (FLOAT)screenWidth, (FLOAT)screenHeight, 0.0f, 1.0f, projectionMatrix, viewMatrix, worldMatrix);  
    XMStoreFloat3(&screenCoordinatesPosition, transformedTextPosition);
    
    // Draw only if within view port
    if (screenCoordinatesPosition.x < 0.0f || screenCoordinatesPosition.x > screenWidth ||
        screenCoordinatesPosition.y < 0.0f || screenCoordinatesPosition.y > screenHeight ||
        screenCoordinatesPosition.z > 1.0f || screenCoordinatesPosition.z < 0.0f)
    {
        return hr;
    }

    // Update text vertices according to new screen coordinates
    hr = UpdateDynamicVertexBuffer(screenCoordinatesPosition, screenWidth, screenHeight);
    IF_FAILED_RETURN(hr);

    // Return if no text graphics created
    if (m_IndexCount == 0 || m_VertexCount == 0)
        return hr;

    // Get font shader wrapper
    SmartPtr<IShader> spShaderWrapper;
    hr = pRenderer->GetShaderInterface(__uuidof(IFontShader), &spShaderWrapper);
    IF_FAILED_RETURN(hr);

    // Get 2D projection matrices
    projectionMatrix = XMMatrixOrthographicLH((FLOAT)screenWidth, (FLOAT)screenHeight, 1.0f, 1000.0f);
	viewMatrix = XMMatrixLookAtLH(XMLoadFloat3(&XMFLOAT3(0.0f, 0.0f, -1.0f)), XMLoadFloat3(&XMFLOAT3(0.0f, 0.0f, 0.0f)), XMLoadFloat3(&XMFLOAT3(0.0f, 1.0f, 0.0f)));

    // Fill shader constants with transformation matrices
    hr = spShaderWrapper.CastTo<IFontShader>()->SetShaderParametersAndTexture(worldMatrix, viewMatrix, projectionMatrix, m_spFontSheet);
    IF_FAILED_RETURN(hr);

    spShaderWrapper->SetVertextAndPixelShader();

    pRenderer->TurnOnAlphaBlending();

    pRenderer->DrawIndexedPrimitive(&m_spVertexBuffer.p, sizeof(TexturedVertexType), m_spIndexBuffer, DXGI_FORMAT_R32_UINT, 
        m_IndexCount, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

    pRenderer->TurnOffAlphaBlending();		

    return hr;
}
开发者ID:kovacik,项目名称:GeometryDebugger,代码行数:63,代码来源:RenderableText.cpp

示例3: Draw

HRESULT RenderableImage::Draw(UINT passIndex, __in IRendererHandler *pRenderer)
{	
    UNREFERENCED_PARAMETER(passIndex);
    HRESULT hr;

    // Get suitable renderer
    SmartPtr<IRenderer> spRenderer;
    hr = pRenderer->QueryInterface(&spRenderer);
    IF_FAILED_RETURN(hr);
    
    // Calibrate
    //
    SmartPtr<ICalibrable> spCalibrable = m_spSceneObject.CastTo<ICalibrable>();
    if (spCalibrable && !spCalibrable->IsCalibrated())
    {
        XMMATRIX viewMatrix, projectionMatrix;
        SmartPtr<ISceneObjectCamera> spCamera;
        hr = spRenderer->GetCamera(&spCamera);
        IF_FAILED_RETURN(hr);

        hr = CalibrateCamera(spCamera);
        IF_FAILED_RETURN(hr);

        spCalibrable->SetCalibrated();
    }

    SmartPtr<IRendererHandler> spRendererHandler(pRenderer);

    XMMATRIX viewMatrix, projectionMatrix;
    hr = spRendererHandler->GetCameraMatrices(&viewMatrix, &projectionMatrix);
    IF_FAILED_RETURN(hr);

    // Get object world transform
	XMMATRIX worldMatrix = m_spSceneObject->GetWorldTransform();

    UINT screenWidth = 0, screenHeight = 0;
    spRenderer->GetWindowWidthAndHeight(screenWidth, screenHeight);

    SmartPtr<ISceneObjectCamera> spCamera;
    hr = spRenderer->GetCamera(&spCamera);
    IF_FAILED_RETURN(hr);

    UINT level = 0;
    hr = DetermineLevelFromCamera(spCamera, (FLOAT)screenWidth, (FLOAT)screenHeight, level);
    IF_FAILED_RETURN(hr);

    // Get suitable shader
	SmartPtr<IShader> spShader;
    hr = pRenderer->GetShaderInterface(__uuidof(ITextureShader), &spShader);
    IF_FAILED_RETURN(hr);
		

    for (UINT i = 0; i < m_LevelTiles[level].Length(); ++i)
    {
        if (m_LevelTiles[level][i]->IsVisible(viewMatrix, projectionMatrix, worldMatrix, (FLOAT)screenWidth, (FLOAT)screenHeight))
        {
            SmartPtr<ID3D11ShaderResourceView> spTexture;
            hr = m_LevelTiles[level][i]->LockTexture(&spTexture);
            IF_FAILED_RETURN(hr);

            // Fill shader constants with transformation matrices
            hr = spShader.CastTo<ITextureShader>()->SetShaderParametersAndTexture(worldMatrix, viewMatrix, projectionMatrix, spTexture);
            IF_FAILED_RETURN(hr);

            spShader->SetVertextAndPixelShader();

            D3D_PRIMITIVE_TOPOLOGY primitiveTopology;
            UINT vertexCount = 0, indexCount = 0;
            SmartPtr<ID3D11Buffer> spVertexBuffer, spIndexBuffer;
            hr = m_LevelTiles[level][i]->GetBuffersAndPrimitiveTopology(&spVertexBuffer, vertexCount, &spIndexBuffer, indexCount, primitiveTopology); 
            IF_FAILED_RETURN(hr);      

            ID3D11Buffer* vertexBuffer = spVertexBuffer;
            pRenderer->DrawIndexedPrimitive(&vertexBuffer, sizeof(TexturedVertexType), spIndexBuffer, DXGI_FORMAT_R32_UINT, 
                                            indexCount, primitiveTopology);
        }
        else
        {
            m_LevelTiles[level][i]->ReleaseTexture();
        }

    }

    return hr;
}
开发者ID:kovacik,项目名称:DeepZoom,代码行数:85,代码来源:RenderableImage.cpp


注:本文中的SmartPtr::GetWindowWidthAndHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。