UI in C# with c++ or only c++ ?

Started by
8 comments, last by i24021 18 years, 11 months ago
Hi i'm starting my way into the wonderfull world of directx 9.0 :-). I have a great experience in c# and java but almost none in c++. I've already decided to learn c++ and i'm making great progress. But before i start my project i was wondering if it's possible to build the external shell of my program with C# (because it's easier to build ui's in windows forms) and the rest with pure c++ with directx 9.0. Maybe inside a panel. I would like to use this shell to configure parameters in my project. I don't know even if this is the best way... I have read that WTL is a good library for windows interfaces and besides i can always use MFC or even to change the settings in the context of the demo using some controls drawn to emulate the tradicional controls in windows... What is the best way to do something like this ? Tnks in advance
Advertisement
I dont know anything about c# so this may be way wrong. But I would assume there is a c# way to import functions from a dll. if that possible you could just write all your c++ stuff in a dll and call it from c#. All you need to pass to directx is an hwnd i think. I could be way off though I have done something similar in visual basic.
Save yourself the trouble and don't do it, Either do it all in C#, or all in C++... you could ofcourse use the WinForms in Managed C++.
Quote:Original post by Arelius
Save yourself the trouble and don't do it, Either do it all in C#, or all in C++... you could ofcourse use the WinForms in Managed C++.


Ok, and what is the best gui library in C++ ? It's hard to decide there's a lot of implementations...
OP > Any quick and dirty tools you need, you may as well develop in C# as you are already familiar.

As for C++ using C#... well that will mean you will need the .Net runtime regardless (obviously).

If I were to take that approach (C# for some of the UI), I would go the ActiveX / COM route. C++ should be able to use C# COM / ActiveX controls as it would any other COM control.
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=187

This partition of responsibility between view and business logic would probably actually be pretty useful in terms of a decent design actually.

If you are lucky enough to have Visual Studio .Net - I would try and learn the forms designer stuff built in to Visual C++ .Net. http://www.codeproject.com/ has tons of tutorials for C++ and C#.

As for graphics libaries, unless you are concerned with cross platform stuff then you may as well just use the MFC (eek) and whatever else is in Visual Studio... as the MSDN has tons of tutorials on how to get stuff done, and the DirectX SDK has loads of UI examples too.

As another poster said though, this is probably creating unnecessary headaches for yourself - COM is not an easy subject, though you are already using it if you are using DirectX. It's probably best to just keep to C++ if that's your chosen language.
Anything posted is personal opinion which does not in anyway reflect or represent my employer. Any code and opinion is expressed “as is” and used at your own risk – it does not constitute a legal relationship of any kind.
Quote:Original post by paulecoyote
OP > Any quick and dirty tools you need, you may as well develop in C# as you are already familiar.

As for C++ using C#... well that will mean you will need the .Net runtime regardless (obviously).

If I were to take that approach (C# for some of the UI), I would go the ActiveX / COM route. C++ should be able to use C# COM / ActiveX controls as it would any other COM control.
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=187

This partition of responsibility between view and business logic would probably actually be pretty useful in terms of a decent design actually.

If you are lucky enough to have Visual Studio .Net - I would try and learn the forms designer stuff built in to Visual C++ .Net. http://www.codeproject.com/ has tons of tutorials for C++ and C#.

As for graphics libaries, unless you are concerned with cross platform stuff then you may as well just use the MFC (eek) and whatever else is in Visual Studio... as the MSDN has tons of tutorials on how to get stuff done, and the DirectX SDK has loads of UI examples too.

As another poster said though, this is probably creating unnecessary headaches for yourself - COM is not an easy subject, though you are already using it if you are using DirectX. It's probably best to just keep to C++ if that's your chosen language.


Ok tnks a lot for your help i will try to do everithing in C++ probably with MFC

I've heard of people creating their interface using Visual Basic (because it's so easy to do), and writing the back end of their program in a C++ DLL.

I have absolutely no experience of writing DLLs though, but it's just a thought.

HTH,

ukdeveloper.
wtf is wrong with you? you know c#, can do UI there, want to learn c++ and you will now start using MFC? sounds like you are going backwards to the stonge age. next thing you want to do is using assembler for everything?

there is no need to use 2 languages simultaneously, you will have a lot of troubles passing stuff over. sometimes it can be helpful to write some smaller parts in c++ (libraries, low level hardware access) and call in in c# or the other way around (you have your engine in c++ and write tools in c# because it is faster).

but i never heard from anyone coming from c# going to c++ just to use MFC. there must be something wrong here.
Microsoft DirectX MVP. My Blog: abi.exdream.com
You can use Unmanaged DLL's(non-.NET dll's) with .NET languages.

Here is what you need to do it.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                                          
Looking for video game music? Check out some of my samples at http://www.youtube.c...ser/cminortunes            
                                                          
I'm currently looking to create music for a project, if you are interested e-mail me at cminortunes@gmail.com    
                                                          
Please only message me for hobby projects, I am not looking to create music for anything serious.
Quote:Original post by abnormal
wtf is wrong with you? you know c#, can do UI there, want to learn c++ and you will now start using MFC? sounds like you are going backwards to the stonge age. next thing you want to do is using assembler for everything?

there is no need to use 2 languages simultaneously, you will have a lot of troubles passing stuff over. sometimes it can be helpful to write some smaller parts in c++ (libraries, low level hardware access) and call in in c# or the other way around (you have your engine in c++ and write tools in c# because it is faster).

but i never heard from anyone coming from c# going to c++ just to use MFC. there must be something wrong here.


It's a simple problem, i know that c++ is THE language to program games. So i need to learn c++ and i'm doing it. But now i need to do a GUI to set some properties like for example: use antialising, use anisotropic filtering in what level and so on. I want to see these changes in a panel or something like that with my 3d scene. I want to build something like the EfectEdit utility that cames with directx sdk.

There is 4 ways to do that :
- Use Managed directx and windows forms (it's easy since i know windows forms programming very well) (Not what i want since using c++ is a requisite)
- Use some api in c++ for the GUI and the engine
- A mix of the two choices
- Implement the controls in directx 9.0

What i want to know is the best way to do it...

Tnks in advance

This topic is closed to new replies.

Advertisement