public bool InitFullscreen(int Width, int Height, int BPP, Control Parent)
{
try
{
if (Parent != null)
{
// The user specified a form handle to render to
SurfaceDescription description = new SurfaceDescription(); // Used to describe a surface
mParent = Parent;
mDisplay = new Device();
// Link DirectDraw to the form handle given and tell it we are going to run in fullscreen
mDisplay.SetCooperativeLevel(Parent, CooperativeLevelFlags.FullscreenExclusive);
// Set the resolution and color depth
mDisplay.SetDisplayMode(Width, Height, BPP, 0, false);
// Define the attributes for the primary surface
description.SurfaceCaps.PrimarySurface = true;
description.SurfaceCaps.Flip = true;
description.SurfaceCaps.Complex = true;
// We are using Double Buffering, so start with one backbuffer.
// NOTE: To change to Tripple Buffering, set this value to 2
description.BackBufferCount = 1;
// Create the primary surface
mPrimary = new Surface(description, mDisplay);
description.Clear();
// A Caps is a set of attributes used by most DirectX objects
SurfaceCaps caps = new SurfaceCaps();
// Yes, we are using a backbuffer
caps.BackBuffer = true;
// Associate the primary buffer to backbuffer with specified caps
mBackbuffer = mPrimary.GetAttachedSurface(caps);
// Create the clipper
mClipper = new Clipper(mDisplay);
// Set the region to the parent
mClipper.Window = Parent;
// Set the clipper for the primary surface
mPrimary.Clipper = mClipper;
description.Clear();
}
// Initalized without error
return true;
}
catch
{
// There was an error initializing DirectDraw
return false;
}
}
C# Form flashing in DX9
Hey, I initialized DX9 in fullscreen, setting the cooperative level to a form, with FullscreenExclusive.
When I render, I can see the form... border and all... flashing on the screen.
Does anybody know how to stop that?
My initialization code is as follows
Tell Windows Forms not to do its own rendering, that dirty bastard Call this code somewhere within your form''s initialization (constructor for instance):
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
Now the background of the form doesnt show up, but I can still see the border, and I can see part of the IDE behind it :o
I don''t know if this is the best way, but for now I just set the FormBorderStyle to none and the BackColor to black.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement