Sign in to follow this  
tlc660

DirectX9 : Backbuffer?

Recommended Posts

tlc660    122
me are new to DirectX9. to start my first C# DirectX9 2D application me have grab a tutorial from MSDN WebCast which a project call "StarTrooper". by following the tutorial from start to end, me have success to create my first 2D snake game with Direct3D.Sprite class. but there have few quetion are confusing me. me have did a 2D application with DirectX8 DirectDraw and VB6 long long time ago. as me memorized, in DirectDraw we have to create a device(same to Direct3D now) and 2 Surface(one for the primary Surface and another for the backbuffer), after we draw on the backbuffer and flip it to primary surface. but which in "StarTrooper", me cant found any called "backbuffer". here my code
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.DeviceWindow = myGameWin;
presentParams.PresentationInterval = PresentInterval.Immediate;

device = new Device(0, DeviceType.Hardware, myGameWin, CreateFlags.HardwareVertexProcessing, presentParams);
Sprite scene = new Sprite(device);

device.Clear(ClearFlags.Target, Color.Black, 1.0f, 0);
device.BeginScene();

scene.Begin(SpriteFlags.AlphaBlend);
// my render code here
scene.End();

device.EndScene();
device.Present();

is it Direct3D.Sprite already handle the "backbuffer" automatically? thanks a lot and sorry for my poor english. [Edited by - tlc660 on August 19, 2006 11:09:10 AM]

Share this post


Link to post
Share on other sites
When you create a D3D device it allocate it's front and back buffer(s). In the presentation parameters you pass to create device is a back buffer count, and a back buffer format. You can pass D3DFMT_UNKNOWN (or 0) as the format when using windowed mode to get a backbuffer format that's the same as the desktop. The backbuffer size can also be specified here. If it's set to 0, it will default to the size of the window's client area. For fullscreen, the mode and backbuffer sizes must be specified as they describe which full screen display mode and resoltion to switch to.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this