GteDX11DrawTarget.cpp
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #include <GTEnginePCH.h>
10 using namespace gte;
11 
13  std::vector<DX11TextureRT*>& rtTextures, DX11TextureDS* dsTexture)
14  :
15  GEDrawTarget(target),
16  mRTTextures(rtTextures),
17  mDSTexture(dsTexture),
18  mRTViews(target->GetNumTargets()),
19  mDSView(nullptr),
20  mSaveRTViews(target->GetNumTargets()),
21  mSaveDSView(nullptr)
22 {
23  unsigned int const numTargets = mTarget->GetNumTargets();
24  for (unsigned int i = 0; i < numTargets; ++i)
25  {
26  mRTViews[i] = mRTTextures[i]->GetRTView();
27  mSaveRTViews[i] = nullptr;
28 #if defined(GTE_GRAPHICS_USE_NAMED_OBJECTS)
29  mRTTextures[i]->SetName(target->GetRTTexture(i)->GetName());
30 #endif
31  }
32 
33  if (mDSTexture)
34  {
36 #if defined(GTE_GRAPHICS_USE_NAMED_OBJECTS)
37  mDSTexture->SetName(target->GetDSTexture()->GetName());
38 #endif
39  }
40 }
41 
42 std::shared_ptr<GEDrawTarget> DX11DrawTarget::Create(DrawTarget const* target,
43  std::vector<GEObject*>& rtTextures, GEObject* dsTexture)
44 {
45  std::vector<DX11TextureRT*> dxRTTextures(rtTextures.size());
46  for (size_t i = 0; i < rtTextures.size(); ++i)
47  {
48  dxRTTextures[i] = static_cast<DX11TextureRT*>(rtTextures[i]);
49  }
50  DX11TextureDS* dxDSTexture = static_cast<DX11TextureDS*>(dsTexture);
51 
52  return std::make_shared<DX11DrawTarget>(target, dxRTTextures, dxDSTexture);
53 }
54 
55 void DX11DrawTarget::Enable (ID3D11DeviceContext* context)
56 {
57  UINT numViewports = 1;
58  context->RSGetViewports(&numViewports, &mSaveViewport);
59 
60  UINT const numTargets = (UINT)mTarget->GetNumTargets();
61  context->OMGetRenderTargets(numTargets, &mSaveRTViews[0], &mSaveDSView);
62 
63  D3D11_VIEWPORT viewport;
64  viewport.Width = static_cast<float>(mTarget->GetWidth());
65  viewport.Height = static_cast<float>(mTarget->GetHeight());
66  viewport.TopLeftX = 0.0f;
67  viewport.TopLeftY = 0.0f;
68  viewport.MinDepth = 0.0f;
69  viewport.MaxDepth = 1.0f;
70  context->RSSetViewports(1, &viewport);
71 
72  context->OMSetRenderTargets(numTargets, &mRTViews[0], mDSView);
73 }
74 
75 void DX11DrawTarget::Disable (ID3D11DeviceContext* context)
76 {
77  context->RSSetViewports(1, &mSaveViewport);
78 
79  UINT const numTargets = (UINT)mTarget->GetNumTargets();
80  context->OMSetRenderTargets(numTargets, &mSaveRTViews[0], mSaveDSView);
81  for (unsigned int i = 0; i < numTargets; ++i)
82  {
83  if (mSaveRTViews[i])
84  {
86  }
87  }
88  if (mSaveDSView)
89  {
91  }
92 }
93 
std::shared_ptr< TextureRT > const GetRTTexture(unsigned int i) const
unsigned int GetWidth() const
unsigned int GetHeight() const
std::vector< DX11TextureRT * > mRTTextures
std::shared_ptr< TextureDS > const GetDSTexture() const
DrawTarget * mTarget
std::vector< ID3D11RenderTargetView * > mRTViews
DX11DrawTarget(DrawTarget const *target, std::vector< DX11TextureRT * > &rtTextures, DX11TextureDS *dsTexture)
DX11TextureDS * mDSTexture
GLenum target
Definition: glcorearb.h:1662
virtual void SetName(std::string const &name)
ID3D11DepthStencilView * mSaveDSView
static std::shared_ptr< GEDrawTarget > Create(DrawTarget const *target, std::vector< GEObject * > &rtTextures, GEObject *dsTexture)
unsigned int GetNumTargets() const
ULONG SafeRelease(T *&object)
ID3D11DepthStencilView * mDSView
void Disable(ID3D11DeviceContext *context)
typedef UINT(WINAPI *PFNWGLGETGPUIDSAMDPROC)(UINT maxCount
D3D11_VIEWPORT mSaveViewport
void Enable(ID3D11DeviceContext *context)
ID3D11DepthStencilView * GetDSView() const
std::vector< ID3D11RenderTargetView * > mSaveRTViews


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:59