Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


C# Form flashing in DX9

This topic is 5278 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
public bool InitFullscreen(int Width, int Height, int BPP, Control Parent)
				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);


					// 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;

				// Initalized without error
				return true;
				// There was an error initializing DirectDraw
				return false;

Share this post

Link to post
Share on other sites
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);

Share this post

Link to post
Share on other sites
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

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!