[C++] Ogre + .NET form

Rodrigue

05-04-2006 22:16:14

Hello,

I'm developping a C++ .NET software for the moment. Is it possible to use Ogre in Microsoft Visual Studio 2003 with .NET form ? Do I have to use a wrapper ?

Cordially,
Rodrigue

EagleEye

05-04-2006 23:24:40

I don't think you can use a .NET form using native C++... so yes, you'd have to use OgreDotNet, but you would probably have to use C# instead of managed C++ to develop in.

rastaman

05-04-2006 23:37:08

Actualy you can in managed c++, C++/CRL aren't they the same.
Thats what this thread is all about.
As for .Net Forms I would think so, DemoWinForms here in ODN does.

Robert Isele

05-04-2006 23:49:57

Hi,
You could try the following:
Create a System.Windows.Forms.Control (i.e. a Panel or a UserControl) which serves as a render destination. Use its 'Handle' property to retrieve a windows handle:

int hWnd = (int)panel->Handle->ToInt32();

This should be enough to create a new ogrewindow with root.CreateRenderWindow(...)

Robert Isele

05-04-2006 23:57:09

About the language:
Is it possible to use the .Net framework without the c++ managed extensions? I don't think so. You're propably using 'MANAGED C++' (no native C++), right?

Rodrigue

06-04-2006 08:43:02

Hello,

Thanks a lot for your responses! I'm not sure I have all understood ;) but I can't use managed C++ (which is mandatory when you develop software with .NET) so, I think I have to use an another solution.
I'm trying to see which GUI I could use with Ogre which looks professional? I would like to have an interface like 3DSMax etc. If the code can be compiled on linux and windows, it will be great!

Cordially,
Rodrigue

Bekas

06-04-2006 11:47:34

I see you say you "can't use managed c++" but just FYI there's a thread that discusses using native Ogre with .NET forms, without a wrapper but with C++/CLI, here:
http://www.ogre3d.org/phpBB2/viewtopic.php?t=18921

the_cX

06-04-2006 19:46:01

Rodrigue:

if it helps, currently one of my projects is using managed c++ .net 2.0 that uses the ogre dlls directly.

screenshot:


additionally, ive uploaded a little archive that is a barebones project showing basically how to do it. uses vs 8.0 and ogre 1.2:
http://www.like-a-mug.com/development/o ... eForms.rar

you dont have to use OgreDotNet and C# to use .net if you dont want to.

Rodrigue

07-04-2006 09:34:51

:D :D :D
God, it's incredibly nice ! Thank you very much ... It's just what I would like to do. I installed Visual C++ 2005 Express Edition just for you ;) (normally I develop on MSVC2003). I'm trying to compile it... but I got this error message :
Compiling...
XuCamera.cpp
c:\source\ogreforms\ogre\xucamera\../../app/stdafx.h(6) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory

It's weird, normally it should find it easily but I don't know MSV2005 so,... I'm not sure.
Also when I open XuMainForm.cpp, the background of the form is green! I don't have the panels...
And finally, I saw that you put Common Language Support to /clr:oldSyntax. What does it mean ?

Could you help me, please! I'm so excited...

Thanks a lot!
Rodrigue

Rodrigue

07-04-2006 09:49:13

Ok, for the error about "windows.h", I read a tutorial on Internet: I have to install PSDK. I don't know if it'll solve the problem...

Rodrigue

07-04-2006 14:34:24

It works yeaaaaaaaaah ! :D
Thank you!

But I don't have the panels like you. What components are you using ?

Note: when I compile, it's very slow (I only have 256Mo wit XP-SP2, I think it's not enough)

the_cX

07-04-2006 17:08:15

@Rodrigue:

glad it works for you. :)

about the panels(im guessing you mean user interface controls by this), this archive wasnt meant to draw any interface type stuff. it was to merely demostrate how to render ogre to a panel using .net forms and managed/unmanaged c++. so in terms of the interface, your gonna have to draw that on your own. :p

as for the old syntax flag in the project settings, that is because that project used to originally be a vs 7.1 project, and when it was automatically converted that is what the vs wizard did. the difference between the 7.1 and 8.0 syntax for managed c++ is significant, and sometimes not trivial. i have been working on an OgreDotNet project mostly since then, however im guessing that its entirely possible to convert that whole project to the new 8.0 managed sytnax.

in fact, as a nice practice, why dont you converting it? :D

it may indeed help those slow compile times.

Rodrigue

18-04-2006 11:19:46

Sorry my internet connexion failed during all the holydays (yes I know I don't have luck :wink:).
Maybe it's possible to convert the project to C++/CLI (instead of managed C++, isn't that?) but I'm not very sure how to do it ... Is it a big job ?
If you have some advices, I would be glad to do it.

Cordially,
Rodrigue

Bekas

19-04-2006 01:17:33

Here's some useful links to get you started:

http://msdn2.microsoft.com/en-us/library/b23b94s7.aspx
http://msdn2.microsoft.com/en-us/library/ms235289.aspx