D2BeginDraw command

Requires: Direct2D.lg32

Purpose

Initiates drawing on this render target.

Syntax

D2BeginDraw RT [, argbColClear]

RT: Object expr
argbColClear: integer expresion

Description

The D2BeginDraw method must be called before rendering (drawing) operations can be called. Drawing operations can only be issued between a D2BeginDraw and D2EndDraw call. After D2BeginDraw is called, a render target will normally build up a batch of rendering commands, but defer processing of these commands until D2EndDraw is called. The D2EndDraw function causes any batched drawing operations to complete, and then returns an HRESULT indicating the success of the operations.

Optionally, D2BeginDraw can be passed the render target object, which will then be used as the current active render target. D2BeginDraw than performs an implicit D2SetRT.

In addition, the application can pass an ARGB color value to clear the render target. This prevents the use of an explicit D2Clear.

Example

'

' D2BeginDraw sample

'

$Library "direct2d"

Global Object Win1RT

OpenW 1, 0, 0, 320, 260, ~15

Set Win1RT = D2GetRT(Me.hWnd, 640, 480) ' window

Do

Sleep

Until Me Is Nothing

 

Sub Win_1_Paint

D2BeginDraw Win1RT

D2Clear D2C_ForestGreen

D2DefFill D2C_Beige

D2PCircle 320, 240, 100

D2EndDraw

EndSub

Remarks

Calling D2BeginDraw twice on a render target puts the target into an error state where nothing further is drawn.

See Also

D2EndDraw, D2GetRT, D2SetRT

{Created by Sjouke Hamstra; Last updated: 15/03/2021 by James Gaite}