본문 바로가기

일하면서 사용한 짧은 지식/C++, DirectX11

Direct2D에서 SetTransform으로 설정한 값 초기화하기

1. 상황

 

Direct2D를 이용하여 기존 이미지를 Transform하여 렌더링할 필요가 있었다. 

ID2D1DeviceContext2의 SetTransform 메서드에

Matrix3x2F::Scale(D2D1_SIZE_F,D2D1_POINT_2F)를 전달하여

원하는 모양으로 렌더링하였다.

 

하지만 이렇게만 하니 이 과정 이후에 진행되는

기존에 Direct2D를 통해 렌더링하던 부분도 SetTransform으로 설정한 영향을 받게 되었다.

 

 

2.  SetTranform을 호출하고 적용하면 이후 drawing에서도 해당 설정이 남아있다.

 

The transform is applied to all later drawing operations until you call SetTransform again.

 

 

3.  만약 설정했던 SetTranform 영향을 없애고 싶다면 identity matrix를 적용하면 된다.

 

To remove the current transform, call SetTransform with the identity matrix.

To create the identity matrix, call the Matrix3x2F::Identity function.

 

pRenderTarget->SetTransform(D2D1::Matrix3x2F::Identity());

 

 

 

https://docs.microsoft.com/en-us/windows/win32/learnwin32/applying-transforms-in-direct2d

 

Applying Transforms in Direct2D - Win32 apps

Applying Transforms in Direct2D

docs.microsoft.com