Diligent Engine API Reference
SwapChainBase.h
1 /* Copyright 2015-2018 Egor Yusov
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
12  *
13  * In no event and under no legal theory, whether in tort (including negligence),
14  * contract, or otherwise, unless required by applicable law (such as deliberate
15  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
16  * liable for any damages, including any direct, indirect, special, incidental,
17  * or consequential damages of any character arising as a result of this License or
18  * out of the use or inability to use the software (including but not limited to damages
19  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
20  * all other commercial damages or losses), even if such Contributor has been advised
21  * of the possibility of such damages.
22  */
23 
24 #pragma once
25 
28 
29 #include "SwapChain.h"
30 #include "DeviceObjectBase.h"
31 #include "Errors.h"
32 
33 namespace Diligent
34 {
35 
37 
42 template<class BaseInterface>
43 class SwapChainBase : public ObjectBase<BaseInterface>
44 {
45 public:
47 
52  SwapChainBase( IReferenceCounters *pRefCounters,
53  IRenderDevice *pDevice,
54  IDeviceContext *pDeviceContext,
55  const SwapChainDesc& SCDesc ) :
56  TObjectBase(pRefCounters),
57  m_pRenderDevice(pDevice),
58  m_wpDeviceContext(pDeviceContext),
59  m_SwapChainDesc(SCDesc)
60  {
61  }
62 
63  ~SwapChainBase()
64  {
65  }
66 
67  IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_SwapChain, TObjectBase )
68 
69 
70  virtual const SwapChainDesc& GetDesc()const override final
71  {
72  return m_SwapChainDesc;
73  }
74 
75 protected:
76  bool Resize( Uint32 NewWidth, Uint32 NewHeight, Int32 Dummy = 0/*To be different from virtual function*/ )
77  {
78  if( NewWidth != 0 && NewHeight != 0 &&
79  (m_SwapChainDesc.Width != NewWidth || m_SwapChainDesc.Height != NewHeight) )
80  {
81  m_SwapChainDesc.Width = NewWidth;
82  m_SwapChainDesc.Height = NewHeight;
83  LOG_INFO_MESSAGE("Changing display resolution to ", m_SwapChainDesc.Width, "x", m_SwapChainDesc.Height);
84  return true;
85  }
86 
87  return false;
88  }
89 
92 
96 
99 
100 private:
101  SwapChainBase( const SwapChainBase& );
103  const SwapChainBase& operator = ( const SwapChainBase& );
104  const SwapChainBase& operator = ( SwapChainBase&& );
105 };
106 
107 }
Swap chain description.
Definition: GraphicsTypes.h:912
Render device interface.
Definition: RenderDevice.h:55
SwapChainBase(IReferenceCounters *pRefCounters, IRenderDevice *pDevice, IDeviceContext *pDeviceContext, const SwapChainDesc &SCDesc)
Definition: SwapChainBase.h:52
Template class implementing base functionality for an object.
Definition: ObjectBase.h:62
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Diligent::RefCntAutoPtr< IRenderDevice > m_pRenderDevice
Strong reference to the render device.
Definition: SwapChainBase.h:91
Base implementation of the swap chain.
Definition: SwapChainBase.h:43
virtual const SwapChainDesc & GetDesc() const override final
Implementation of ISwapChain::GetDesc()
Definition: SwapChainBase.h:70
Device context interface.
Definition: DeviceContext.h:443
Diligent::RefCntWeakPtr< IDeviceContext > m_wpDeviceContext
Weak references to the immediate device context. The context holds the strong reference to the swap c...
Definition: SwapChainBase.h:95
Implementation of weak pointers.
Definition: RefCntAutoPtr.h:38
SwapChainDesc m_SwapChainDesc
Swap chain description.
Definition: SwapChainBase.h:98
Template class that implements reference counting.
Definition: RefCntAutoPtr.h:71
Uint32 Height
The swap chain height. Default value is 0.
Definition: GraphicsTypes.h:918
Uint32 Width
The swap chain width. Default value is 0.
Definition: GraphicsTypes.h:915