Render DirectX in Windows Form

Started by
6 comments, last by ~Helgon 11 years, 2 months ago

Hi, approximately a month ago I already posted a question a little bit like this one. Back then I wanted to know what would be the best "Library/ Way of doing it" to render my DirectX Frame into a GUI. I proposed Qt, Windows Forms, wxWidgets. The feedback was pretty different. So I started to learn Qt and it seems to be a very powerful tool, but maybe a little bit to complex to learn it (with all the different Models etc. and how to implement them for everything ...). So I decided to switch back to "native" Windows Forms (As i anyway use DirectX Qt would not have any advantages because I don't need cross-platform compatibility). So I started to look for some samples how to achieve my goal. In the end I got it working with this (http://www.codeproject.com/Articles/42121/DirectX-9-SDK-with-NET-Forms-C) tutorial but I've encountered a huge problem: the interface between C++/CLI and the managed and unmanaged code is so "strange" that I almost can't use anything because it's "unmanged". Is this normal? Am I doing it wrong? Is there another way to how to solve this problem (Render into WindowsForms)? Or does someone maybe has a tutorial therefore or a sample of one of his projects? I would appreciate any help very much. Best regards

from time to time i find time

Advertisement

I think what you are trying to do might be more difficult than its worth, if you don't mind me asking for what purpose?

Do you just want easy to use GUI buttons and stuff?

I want to make a level-animation-etc. editor. To be able to have for example a tree view where I can select assets and then have them in the directX frame to place them. Or Slider to change the area of effect of an terrain-displacement tool, or when I select a entity to get the properties. Just the basic GUI you have when u start up a game editor. For example:

Warcr303.jpg


Do you know what I mean?

How would you approach the problem if not in the way i described it. Of course I could do the GUI by myself directly as elements in the DirectX frame or use Crazy Eddies , but why should it be that complicated? Maybe I just don't know the right way.

Regards

from time to time i find time

Unless you're absolutely set on creating your own bindings to access DirectX from .NET, might I recommend either SlimDX or SharpDX?

http://slimdx.org/

http://code.google.com/p/sharpdx/

Both are managed wrappers around DirectX. SlimDX is older and supports D3D9 through D3D11; SharpDX only supports D3D10/11. SlimDX diverges slightly from directly wrapping the DirectX spec; SharpDX is auto-generated from the headers and therefore cleaves very closely.

Either one of these should let you render into a .NET Windows Form with minimal effort.

Oh, I totally forgot them both..
For me just SharpDX is an option because I want DX11 and it's near to the c++ version.
The only thing bugging me is that there aren't any "introduction" tutorials. Just to get a feel for how SharpDX syntax looks like but this probably is the best way because I anyway am a Java guy so it's more to my main language.

Thank you very much for the hint. As I said i totally forgot this happy.png

I already googeled some SharpDX Tutorials but if you can suggest me one I'm open for them smile.png

Thank you very much for the hint.

Edit: Just saw that there are samples in the SDK, but still open for suggestions :P

from time to time i find time

SlimDX has a set of 3 intro tutorials on their site that will get drawing a triangle in a DirectX Context on a Windows Form.

When I say SlimDX diverges slightly, it is only very slightly. IIRC, the state blocks (BlendState, RasterizerState, DepthStencilState) and some of the Desc structs have members slightly reorganized from their native cousins. I've managed to port a fairly extensive C# graphics project from library to the other with minimal effort: other than changing the #using from SlimDX.whatever to SharpDX.whatever, and the mismatches in descs and states, almost everything behaves similarly and usually has the same name.

Because of that, I'll bet you could follow the SlimDX tutorials using SharpDX with some name substitution and get pretty close. You'll find more help resources for SlimDX than SharpDX, so maybe you should consider using that. They both support DX11, and both are good libraries.

You do not need to create any binding for DirectX if you are doing everything in C++/Cli. To Render to an Form all you need to do is convert Form Handle to an HWND and pass that as your window handle. Then all your rendering will take place on the form. I did that for one of my editor and works perfectly. Do not listen to the comments that the people above are saying. I just hate when someone has no idea about something, yet they still post an answer.

Hi, thanks for your suggestion. It would be great if just this was my whole problem. I gonna give it later today a shot and reply if it works or not.

Regards

from time to time i find time

This topic is closed to new replies.

Advertisement