Requires: Direct2D.lg32
Activates the specified render target when using Direct2D.
D2SetRT RT
RT | : Object |
D2SetRT makes the specified render target RT the current render target for drawing commands and device dependent resource creation functions (brushes and bitmaps). Many D2 commands and functions operate only when the render target is set. The render target is automatically activated when a new render target is obtained using D2GetRT. (A render target is an ID2D1RenderTarget COM object, which provides many functions to create draw shapes, create images and brushes. Sometimes, before using one of the resource creation functions, the proper render target must be set explicitly using D2SetRT. However, most often the current render target is already activated using D2GetRT and/or D2BeginDraw.
The current render target is set to Nothing in D2EndDraw. After D2EndDraw finishes there is no longer a current render target active. Use D2BeginDraw or D2SetRT again when using a D2 function that requires a render target. If possible, group D2 commands and functions after setting the current render target.
'
' D2SetRT sample (dpi-unaware)
'
$Library "direct2d"
Global Object Win1RT
OpenW 1, 0, 0, 320, 260, ~15
Set Win1RT = D2GetRT(Me.hWnd, 640, 480) ' window
' Here: create Win_1 render target resources
Do
Sleep
Until Me Is Nothing
Sub Win_1_Paint
D2SetRT Win1RT ' or Set D2CurRT = Win1RT
D2BeginDraw Win1RT
D2BackColor = D2C_Bisque
D2Clear
D2DefLine , 4
D2Circle 320, 240, 100
D2EndDraw
EndSub
The current render target can be set with D2BeginDraw as well.
D2GetRT, D2BeginDraw, D2EndDraw
{Created by Sjouke Hamstra; Last updated: 15/03/2021 by James Gaite}