?
Solved

creating surfaces in directx 9 and c#

Posted on 2003-03-19
5
Medium Priority
?
894 Views
Last Modified: 2013-12-08
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
Comment
Question by:aepurniet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 4

Expert Comment

by:joachimc
ID: 8172431
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
 
LVL 1

Accepted Solution

by:
PurpleFlux earned 100 total points
ID: 8561914
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
 

Expert Comment

by:CleanupPing
ID: 9464649
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
 
LVL 1

Expert Comment

by:PurpleFlux
ID: 9464694
I believe my comment is still correct.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month7 days, 20 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question