• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 896
  • Last Modified:

creating surfaces in directx 9 and c#

i seem to get a System.ArguementException when i try to initialize a second surface.  here is a peek at my code:

   form = new Form();
   ...
   form.Show();
 
   device = new Device();
   device.SetCooperativeLevel(form, CooperativeLevelFlags.Normal);

   frontDescription = new SurfaceDescription();
   frontDescription.SurfaceCaps.PrimarySurface = true;
   frontBuffer = new Surface(frontDescription, device);

   backDescription = new SurfaceDescription();
   backDescription.SurfaceCaps.OffScreenPlain = true;
*  backBuffer = new Surface(backDescription, device);  
^
|
+- I get the exception, what exactly am i doing wrong and how come microsoft documentation stinks? okay just the first part. I still get this if I take out the OffScreenPlain, I add in the dimensions of the surface, or a lot of other playing around with the caps.  But I know I am missing something.  what is it?
0
aepurniet
Asked:
aepurniet
  • 2
1 Solution
 
joachimcCommented:
I don't know C# so I can't tell you exactly whats wrong here. But if you don't exactly need the back buffer surface (you know exactly what you are doing and why :). Then this looks very much like DX7 code and it's not really used that way anymore in DX8 and 9. Take a look at the the C# tutorials under samples in the dxsdk dir.

0
 
PurpleFluxCommented:
You'll be happy to know that I can answer your question.
You need to tell the backsurface how big it is.  The front surface is attached to the screen so it already knows how big it is.

Add this code before you create the actual backbuffer surface and you should be good to go.

backDescription.Width = frontBuffer .SurfaceDescription.Width
backDescription.Height = frontBuffer .SurfaceDescription.Height
0
 
CleanupPingCommented:
aepurniet:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
PurpleFluxCommented:
I believe my comment is still correct.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now