This documentation is archived and is not being maintained.

Device.BeginScene Method

Updated: April 2009

Represents the beginning of a scene.

Namespace:  Microsoft.WindowsMobile.DirectX.Direct3D
Assembly:  Microsoft.WindowsMobile.DirectX (in Microsoft.WindowsMobile.DirectX.dll)

public void BeginScene()

ExceptionCondition
InvalidCallException

The method call is invalid. This occurs when BeginScene is called while already in a BeginScene and EndScene pair. Never call BeginScene twice without first calling EndScene.

This method attempts to lock the back buffer which is used for drawing graphical objects. Every call to BeginScene should eventually be followed by a call to EndScene before the display is updated with Device.

If the method fails, the device was unable to begin the scene, and there is no need to call EndScene. Calls to EndScene fail if the previous call to BeginScene fails.

The following code example shows how to begin and end a scene.

protected override void OnPaint(PaintEventArgs eventg)
{
    device.Clear(ClearFlags.Target, Color.Black, 0.0f, 0);
    device.BeginScene();
    sprite.Begin(SpriteFlags.None);
    sprite.Draw(texture, Vector3.Empty, new Vector3(10, 10, 0), 0x00ffffff);
    sprite.End();
    device.EndScene();
    device.Present();
}

Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Compact Framework

Supported in: 3.5, 2.0

Date

History

Reason

April 2009

Added descriptive information.

Customer feedback.

Show: