Okay so I went ahead and learned most of C# Mainly because I heard you can make function calls to it from C++. I am unsure of this though. My goal with C# is to use components of the XNA engine with my own engine, mainly so I can develop for the Xbox 360. The way I plan to do this so far with what little information I have been able to find is(Taking into account I can only do stuff with processing and graphics so far): I would have a duplication of my sprite class in C#. The only difference would be that it would have special functionality to use the XNA sprite's instead sfml sprites and send the data about things like the sprites position to C++ (and when I get to sound and networking I will have to do the same thing). I am unsure of how to do this though and surfing google has not provided much incite. I have thought of maybe using lua as a middle man for this process but I am: A.) not sure lua can be used with C# and B.) not sure if that would work at all. I know I have thrown a bunch of unorganized info out there so what I am wondering is:
A.) Can I call C# functions in C++?
B.) Can I do the opposite of A?
C.) Will lua work with C# and C++ at the same time?
D.) Is this reasonable?
E.) If I am not using C++ for things like graphics and sound can I use it for the background processing on the Xbox 360?
Thank you for reading :-D
P.s I know I sometimes have a hard time getting my point across please let me know if any further explanation is needed.
C++, C# and lua
Moderator: Coders of Rage
- THe Floating Brain
- Chaos Rift Junior
- Posts: 284
- Joined: Tue Dec 28, 2010 7:22 pm
- Current Project: RTS possible Third Person shooter engine.
- Favorite Gaming Platforms: PC, Wii, Xbox 360, GAME CUBE!!!!!!!!!!!!!!!!!!!!!!
- Programming Language of Choice: C/C++, Python 3, C#
- Location: U.S
C++, C# and lua
"Why did we say we were going to say we were going to change the world tomorrow yesterday? Maybe you can." - Myself
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: C++, C# and lua
A) Yes, but not on the 360
B) Yes, but not on the 360
C) Yes, because of the wrapper created by A and B
D) Absolutely not
E) No
There are some serious issues with your design. First of all, you most likely are not going to be getting either Lua or C++ running on the 360. If you had a normal .NET platform and were using "normal" C#, you would be fine to do it. Xbox 360 Development and the XNA suite literally force you to go through C# by design. You cannot invoke any external unmanaged C++ code. Lua is a completely unmanaged, unsafe, low level C library. You aren't going to get it running on the 360 (without porting it) without C++ support, which you aren't going to get. Period.
The .NET framework allows you to communicate with "unsafe" C++ code through a thin layer of wrapping called "managed C++." This managed C++ layer is essentially a layer of communication allowing you to talk to C# from C++ or C++ from C#. Unfortunately, the XNA framework on the XBox360 does NOT permit invoking unsafe code (or even any sort of non C# managed code).
Either way, I honestly have to say that this is a terrible idea regardless. C# is already a JIT compiled language running on the .NET framework. It already has plenty of overhead (garbage collection, JIT compilation, run-times, etc) as opposed to a statically compiled language. Adding ANOTHER run-time compiled/interpreted language such as Lua (which is even slower) AND the necessary bindings/wrappings to get your C++ code, your Lua code, and your C# code to talk to each other is not only going to be a nightmare resource wise, but a waste of time development wise. You'll spend more time wrapping code than actually getting anything done.
Regardless of whether it's a good idea or not, you are stuck with C# for XNA development. And honestly, developing on a platform with JIT-compilation really destroys the entire purpose of embedding a scripting language within an engine anyway.
B) Yes, but not on the 360
C) Yes, because of the wrapper created by A and B
D) Absolutely not
E) No
There are some serious issues with your design. First of all, you most likely are not going to be getting either Lua or C++ running on the 360. If you had a normal .NET platform and were using "normal" C#, you would be fine to do it. Xbox 360 Development and the XNA suite literally force you to go through C# by design. You cannot invoke any external unmanaged C++ code. Lua is a completely unmanaged, unsafe, low level C library. You aren't going to get it running on the 360 (without porting it) without C++ support, which you aren't going to get. Period.
The .NET framework allows you to communicate with "unsafe" C++ code through a thin layer of wrapping called "managed C++." This managed C++ layer is essentially a layer of communication allowing you to talk to C# from C++ or C++ from C#. Unfortunately, the XNA framework on the XBox360 does NOT permit invoking unsafe code (or even any sort of non C# managed code).
Either way, I honestly have to say that this is a terrible idea regardless. C# is already a JIT compiled language running on the .NET framework. It already has plenty of overhead (garbage collection, JIT compilation, run-times, etc) as opposed to a statically compiled language. Adding ANOTHER run-time compiled/interpreted language such as Lua (which is even slower) AND the necessary bindings/wrappings to get your C++ code, your Lua code, and your C# code to talk to each other is not only going to be a nightmare resource wise, but a waste of time development wise. You'll spend more time wrapping code than actually getting anything done.
Regardless of whether it's a good idea or not, you are stuck with C# for XNA development. And honestly, developing on a platform with JIT-compilation really destroys the entire purpose of embedding a scripting language within an engine anyway.
- THe Floating Brain
- Chaos Rift Junior
- Posts: 284
- Joined: Tue Dec 28, 2010 7:22 pm
- Current Project: RTS possible Third Person shooter engine.
- Favorite Gaming Platforms: PC, Wii, Xbox 360, GAME CUBE!!!!!!!!!!!!!!!!!!!!!!
- Programming Language of Choice: C/C++, Python 3, C#
- Location: U.S
Re: C++, C# and lua
Thank you very much that is very helpful :-D I think il just stick to dev'ing for the PC
"Why did we say we were going to say we were going to change the world tomorrow yesterday? Maybe you can." - Myself