CD3D11_VIEWPORT class

Represents a viewport and provides convenience methods for creating viewports.

Members

The CD3D11_VIEWPORT class inherits from D3D11_VIEWPORT. CD3D11_VIEWPORT also has these types of members:

  • Constructors
  • Methods

Constructors

The CD3D11_VIEWPORT class has these constructors.

Constructor Description
CD3D11_VIEWPORT()

Instantiates a new instance of an uninitialized CD3D11_VIEWPORT structure.

CD3D11_VIEWPORT(D3D11_VIEWPORT_values)(FLOAT,FLOAT,FLOAT,FLOAT,FLOAT,FLOAT)

Instantiates a new instance of a CD3D11_VIEWPORT structure that is initialized with D3D11_VIEWPORT values.

CD3D11_VIEWPORT(D3D11_VIEWPORT_values2)(ID3D11Buffer,ID3D11RenderTargetView,FLOAT,FLOAT,FLOAT)

Instantiates a new instance of a CD3D11_VIEWPORT structure that is initialized with D3D11_BUFFER_RTV values.

CD3D11_VIEWPORT(D3D11_VIEWPORT_values3)(ID3D11Texture1D,ID3D11RenderTargetView,FLOAT,FLOAT,FLOAT)

Instantiates a new instance of a CD3D11_VIEWPORT structure that is initialized with D3D11_TEX1D_RTV or D3D11_TEX1D_ARRAY_RTV values.

CD3D11_VIEWPORT(D3D11_VIEWPORT_values4)(ID3D11Texture2D,ID3D11RenderTargetView,FLOAT,FLOAT,FLOAT,FLOAT)

Instantiates a new instance of a CD3D11_VIEWPORT structure that is initialized with 2D texture values.

CD3D11_VIEWPORT(D3D11_VIEWPORT_values5)(ID3D11Texture3D,ID3D11RenderTargetView,FLOAT,FLOAT,FLOAT,FLOAT)

Instantiates a new instance of a CD3D11_VIEWPORT structure that is initialized with 3D texture values.

 

Methods

The CD3D11_VIEWPORT class has these methods.

Method Description
~CD3D11_VIEWPORT()

Destroys an instance of a CD3D11_VIEWPORT structure.

CD3D11_VIEWPORT(D3D11_VIEWPORT)(const &D3D11_VIEWPORT)

Instantiates a new instance of a CD3D11_VIEWPORT structure that is initialized with a D3D11_VIEWPORT structure.

D3D11_VIEWPORT()

This operator returns the address of a D3D11_VIEWPORT structure that contains the data from the CD3D11_VIEWPORT instance.

 

Remarks

Here is how D3D11.h defines CD3D11_VIEWPORT:


struct CD3D11_VIEWPORT : public D3D11_VIEWPORT
{
    CD3D11_VIEWPORT()
    {}
    explicit CD3D11_VIEWPORT( const D3D11_VIEWPORT& o ) :
        D3D11_VIEWPORT( o )
    {}
    explicit CD3D11_VIEWPORT(
        FLOAT topLeftX,
        FLOAT topLeftY,
        FLOAT width,
        FLOAT height,
        FLOAT minDepth = D3D11_MIN_DEPTH,
        FLOAT maxDepth = D3D11_MAX_DEPTH )
    {
        TopLeftX = topLeftX;
        TopLeftY = topLeftY;
        Width = width;
        Height = height;
        MinDepth = minDepth;
        MaxDepth = maxDepth;
    }
    explicit CD3D11_VIEWPORT(
        _In_ ID3D11Buffer*,
        _In_ ID3D11RenderTargetView* pRTView,
        FLOAT topLeftX = 0.0f,
        FLOAT minDepth = D3D11_MIN_DEPTH,
        FLOAT maxDepth = D3D11_MAX_DEPTH )
    {
        D3D11_RENDER_TARGET_VIEW_DESC RTVDesc;
        pRTView->GetDesc( &RTVDesc );
        UINT NumElements = 0;
        switch (RTVDesc.ViewDimension)
        {
        case D3D11_RTV_DIMENSION_BUFFER:
            NumElements = RTVDesc.Buffer.NumElements;
            break;
        default: break;
        }
        TopLeftX = topLeftX;
        TopLeftY = 0.0f;
        Width = NumElements - topLeftX;
        Height = 1.0f;
        MinDepth = minDepth;
        MaxDepth = maxDepth;
    }
    explicit CD3D11_VIEWPORT(
        _In_ ID3D11Texture1D* pTex1D,
        _In_ ID3D11RenderTargetView* pRTView,
        FLOAT topLeftX = 0.0f,
        FLOAT minDepth = D3D11_MIN_DEPTH,
        FLOAT maxDepth = D3D11_MAX_DEPTH )
    {
        D3D11_TEXTURE1D_DESC TexDesc;
        pTex1D->GetDesc( &TexDesc );
        D3D11_RENDER_TARGET_VIEW_DESC RTVDesc;
        pRTView->GetDesc( &RTVDesc );
        UINT MipSlice = 0;
        switch (RTVDesc.ViewDimension)
        {
        case D3D11_RTV_DIMENSION_TEXTURE1D:
            MipSlice = RTVDesc.Texture1D.MipSlice;
            break;
        case D3D11_RTV_DIMENSION_TEXTURE1DARRAY:
            MipSlice = RTVDesc.Texture1DArray.MipSlice;
            break;
        default: break;
        }
        const UINT SubResourceWidth = TexDesc.Width / (UINT( 1 ) << MipSlice);
        TopLeftX = topLeftX;
        TopLeftY = 0.0f;
        Width = (SubResourceWidth ? SubResourceWidth : 1) - topLeftX;
        Height = 1.0f;
        MinDepth = minDepth;
        MaxDepth = maxDepth;
    }
    explicit CD3D11_VIEWPORT(
        _In_ ID3D11Texture2D* pTex2D,
        _In_ ID3D11RenderTargetView* pRTView,
        FLOAT topLeftX = 0.0f,
        FLOAT topLeftY = 0.0f,
        FLOAT minDepth = D3D11_MIN_DEPTH,
        FLOAT maxDepth = D3D11_MAX_DEPTH )
    {
        D3D11_TEXTURE2D_DESC TexDesc;
        pTex2D->GetDesc( &TexDesc );
        D3D11_RENDER_TARGET_VIEW_DESC RTVDesc;
        pRTView->GetDesc( &RTVDesc );
        UINT MipSlice = 0;
        switch (RTVDesc.ViewDimension)
        {
        case D3D11_RTV_DIMENSION_TEXTURE2D:
            MipSlice = RTVDesc.Texture2D.MipSlice;
            break;
        case D3D11_RTV_DIMENSION_TEXTURE2DARRAY:
            MipSlice = RTVDesc.Texture2DArray.MipSlice;
            break;
        case D3D11_RTV_DIMENSION_TEXTURE2DMS:
        case D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY:
            break;
        default: break;
        }
        const UINT SubResourceWidth = TexDesc.Width / (UINT( 1 ) << MipSlice);
        const UINT SubResourceHeight = TexDesc.Height / (UINT( 1 ) << MipSlice);
        TopLeftX = topLeftX;
        TopLeftY = topLeftY;
        Width = (SubResourceWidth ? SubResourceWidth : 1) - topLeftX;
        Height = (SubResourceHeight ? SubResourceHeight : 1) - topLeftY;
        MinDepth = minDepth;
        MaxDepth = maxDepth;
    }
    explicit CD3D11_VIEWPORT(
        _In_ ID3D11Texture3D* pTex3D,
        _In_ ID3D11RenderTargetView* pRTView,
        FLOAT topLeftX = 0.0f,
        FLOAT topLeftY = 0.0f,
        FLOAT minDepth = D3D11_MIN_DEPTH,
        FLOAT maxDepth = D3D11_MAX_DEPTH )
    {
        D3D11_TEXTURE3D_DESC TexDesc;
        pTex3D->GetDesc( &TexDesc );
        D3D11_RENDER_TARGET_VIEW_DESC RTVDesc;
        pRTView->GetDesc( &RTVDesc );
        UINT MipSlice = 0;
        switch (RTVDesc.ViewDimension)
        {
        case D3D11_RTV_DIMENSION_TEXTURE3D:
            MipSlice = RTVDesc.Texture3D.MipSlice;
            break;
        default: break;
        }
        const UINT SubResourceWidth = TexDesc.Width / (UINT( 1 ) << MipSlice);
        const UINT SubResourceHeight = TexDesc.Height / (UINT( 1 ) << MipSlice);
        TopLeftX = topLeftX;
        TopLeftY = topLeftY;
        Width = (SubResourceWidth ? SubResourceWidth : 1) - topLeftX;
        Height = (SubResourceHeight ? SubResourceHeight : 1) - topLeftY;
        MinDepth = minDepth;
        MaxDepth = maxDepth;
    }
    ~CD3D11_VIEWPORT() {}
    operator const D3D11_VIEWPORT&() const { return *this; }
};

Requirements

Minimum supported client

Windows 7 [desktop apps | UWP apps]

Minimum supported server

Windows Server 2008 R2 [desktop apps | UWP apps]

Header

D3D11.h

Library

D3D11.lib

See also

D3D11_VIEWPORT

CD3D11 Helper Structures