Skip to main content
gamedev.net
🔒 Locked

C# Custom Control

Started by pogsworth Jan 6, 2006 at 2:09 PM 2 replies 800+ views
Original Post
pogsworth
pogsworth
I'm working on a 3d editor in C#, drawing mostly on ideas from a DX editor I wrote in C++. I want to have multiple viewports open at once, up to 4. I have created a View3D class derived from Windows.Forms.Control. I'm trying to create the device without attaching it to any window (passing in null for the window), and just creating a small primary swapchain that I never use to present data. My design is to create a secondary swap chain for each View3D. But I can't create the device without passing in a window handle (or control reference). The DX help says I can do that, as long as I pass in a window during the present call. But I keep getting InvalidCallException during the Device constructor. I had it sort of working when I had the control check to see if there was a valid device and create it if it wasn't. That control would then use the default swapchain from the device. I had some problems keeping track whether a View3D was using the primary swapchain or not so I'm trying this other way. Anyone done anything like this? Any help/suggestions would be appreciated. Paul p.s. I'm still using June SDK, for various reasons. I'm still using VS.NET 2003 also.
circlesoft
circlesoft
Quote:
Original post by pogsworth
But I can't create the device without passing in a window handle (or control reference). The DX help says I can do that, as long as I pass in a window during the present call. But I keep getting InvalidCallException during the Device constructor.

What does the debug runtime say about it? It may provide some instruction that clears up exactly what you need to be doing. D3D Devices and HWNDs definitely aren't always clear - D3D10 works to simplify this quite a bit.

Also, if you need to pass the HWND among Present() anyways, why not just pass it once at initialization?
pogsworth
pogsworth
Thanks for taking pity, I finally did get somewhere on my own...

I did end up passing in the main form to initialize DirectX, but I never call device.Present - always using the swapchains associated with the custom controls.

It's all working very nicely now. I'm finally getting a grip on events etc. in C#. Part of my problems before was not resetting the swapchains when the device was getting reset.

Do you mean turning on debug output from the runtime. Does it show up in the Output window of the debugger? I'll have to try that and see...

Thanks.
Nypyren
Nypyren
I wasn't able to get the DirectX debug messages in a C# debugging session. I had to use some external thing (DebugView?) that watched for it.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.