Jump to content
  • Advertisement
Sign in to follow this  
Guest

How to use swap chain managed directX c#

This topic is 3163 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

Guest
So i have 2 windows lets call them window 1 and window 2; Pretty much the code looks like this ///---------Window1-----------//// private void initializedevice { presentParams=.....; device=.....; } ///---------Window2-----------//// private void initializedevice { presentParams=.....; device=.....; } Now i get an error for device on window2 apparently because device 1 is already being used....Now how do i get over this error? Thankss!xxxx

Share this post


Link to post
Share on other sites
Advertisement

when i was doing it i just created a universal module and then loaded that dll into an application and then 'pasted' 2 of them into it ( i used 3 or 4 at one point to send them different data, but i could have had them as clones or had as many as i wanted).

i was using slimdx(10) and visual studio, and they make it easy.

my application is rather unique and i dont know what kind of datapaths you need between them but it worked fine for me.



[Edited by - ucfchuck on April 14, 2010 4:27:59 PM]

Edited by ucfchuck

Share this post


Link to post
Share on other sites
Guest
Slimdx doesnt help me as i need to know what sort of code to put in so i can render to multiple windows

Share this post


Link to post
Share on other sites
it doesnt have anything to do with slimdx, it was mostly just configuring everything in VS. if you write your directx stuff into its own library and then use that in your form you can just pull up multiple copies of the same dll and send each one different data or whatever and size and place them however.

im not sure but i dont think you can have one 'device' across multiple 'windows', i had one 'device' per 'window'.

Share this post


Link to post
Share on other sites
First off, D3D9 or 10? Doesn't really matter as the principles are the same.

You use a swap chain (as mentioned in your topic)... you don't create multiple devices, you create multiple swap chains. That's about all it takes. Each swap chain is associated with one window handle (HWND).

Share this post


Link to post
Share on other sites
Guest
how do you make one device per window? because i get an error:S

Share this post


Link to post
Share on other sites
Quote:
Original post by harminal
how do you make one device per window? because i get an error:S


Can't read? All the text got you down? Try a SnickersTM.

Share this post


Link to post
Share on other sites
Quote:

how do you make one device per window? because i get an error:S

You are doing it wrong, then.

Why don't you post some code (some actual code), and a detailed description of the exact error you're getting. Without that kind of detailed information nobody can really help more than has already been done.

Ideally you do want to create one device and use multiple swap chains, since that will let you share resources more easily between each window.

Furthermore, MDX is a dead technology. If at all possible you should consider upgrading to SlimDX or XNA (as appropriate for your project). The fundamental principles involved here are all the same, and the API is quite similar (although less so with XNA).

Share this post


Link to post
Share on other sites
Guest
--------///Window1
public void Initialize()
{

presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.EnableAutoDepthStencil = true;
presentParams.AutoDepthStencilFormat = DepthFormat.D16;
device = new Device(0, DeviceType.Hardware, panel1, CreateFlags.SoftwareVertexProcessing, presentParams);
LoadContent();

}


-----------///Window2

public void Initialize()
{
presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.EnableAutoDepthStencil = true;
presentParams.AutoDepthStencilFormat = DepthFormat.D16;

device = new Device(0, DeviceType.Hardware, panel1,
CreateFlags.MixedVertexProcessing,
presentParams);
}



InvalidCallException

Share this post


Link to post
Share on other sites
WHERE is the InvalidCallException thrown? WHAT do the debug runtimes say? Et cetera.

However, the first thing that appears like an obvious problem from this code is that you are using panel1 for the handle for both devices. Shouldn't do that. Create two panels, one for the first device and one for the second. You're also trying to use adapter 0 the first time and adapter 1 the second -- do you actually have two graphics adapters?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!