Converting C++ to C# (hopefully quite easy)

  • Thread starter Thread starter Bonj
  • Start date Start date
B

Bonj

I have got the starting bits of a game that I am trying to
write. I did start to write it in VC++6, but found the
basic windows GDI to be of general poor performance for
animation. So I decided to switch to GDI+, and as far as
I've found on my operating system (WinXP, VS6 and VS.NET
2002) C# is the only language that seems to be capable of
using GDI+, as it does so intrinsically (C++ coughs up
about 100 errors from the <gdiplus.h> so that's out of the
question, whether I do it managed or unmanaged), so I've
decided to convert it to C#, and now i think about it I'm
happier with that, as long as C# can work in the way that
I want, which it seems to be able to.
My question though, is that would the following
architecture sound OK? In C++, I have got two animator
classes which run in separate threads, one which draws to
the buffer, and one which copies the buffer to the screen.
These classes are started by having a Start method, this
kicks off a new thread starting at a static member
function with a 'this' pointer, the thread then repeatedly
calls a non-static member function belonging to 'this'
pointer. In C++, each of these classes get an HDC passed
to them on construction (the copier class has two, one for
the screen aswell) but I would expect in C# they would
create a graphics during the non-static frame function
from the Form that they are passed.

2 questions:
Does it sound faesible to convert this architecture to C#,
and does it have any limitations that I need to watch out
for

Does C# have any powerful features that I would probably
want to take advantage of? It seems to be a very powerful
language from what I've seen.

I've read a bit up on how to create a thread in C#. But
how would I pass a reference (pointer?) to the Form as a
parameter to the thread start function, and how would I
ensure that it's a pointer rather than a copy of the Form
object?
 
Bonj,

While I have no doubt that this can be done in C#, I think that for what
you are trying to do, the DirectX framework might be more appropriate. It
has everything you need for high-perf rendering, leaving you to do more game
coding, and less engine coding. Also, there is a managed wrapper for the
latest version of DirectX, version 9.

Hope this helps.
 
Sorry I think i should have said I am getting some books
on directx but they haven't come yet. So I want to do this
as a preliminary, 'basic' project.

-----Original Message-----
Bonj,

While I have no doubt that this can be done in C#, I think that for what
you are trying to do, the DirectX framework might be more appropriate. It
has everything you need for high-perf rendering, leaving you to do more game
coding, and less engine coding. Also, there is a managed wrapper for the
latest version of DirectX, version 9.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I have got the starting bits of a game that I am trying to
write. I did start to write it in VC++6, but found the
basic windows GDI to be of general poor performance for
animation. So I decided to switch to GDI+, and as far as
I've found on my operating system (WinXP, VS6 and VS.NET
2002) C# is the only language that seems to be capable of
using GDI+, as it does so intrinsically (C++ coughs up
about 100 errors from the <gdiplus.h> so that's out of the
question, whether I do it managed or unmanaged), so I've
decided to convert it to C#, and now i think about it I'm
happier with that, as long as C# can work in the way that
I want, which it seems to be able to.
My question though, is that would the following
architecture sound OK? In C++, I have got two animator
classes which run in separate threads, one which draws to
the buffer, and one which copies the buffer to the screen.
These classes are started by having a Start method, this
kicks off a new thread starting at a static member
function with a 'this' pointer, the thread then repeatedly
calls a non-static member function belonging to 'this'
pointer. In C++, each of these classes get an HDC passed
to them on construction (the copier class has two, one for
the screen aswell) but I would expect in C# they would
create a graphics during the non-static frame function
from the Form that they are passed.

2 questions:
Does it sound faesible to convert this architecture to C#,
and does it have any limitations that I need to watch out
for

Does C# have any powerful features that I would probably
want to take advantage of? It seems to be a very powerful
language from what I've seen.

I've read a bit up on how to create a thread in C#. But
how would I pass a reference (pointer?) to the Form as a
parameter to the thread start function, and how would I
ensure that it's a pointer rather than a copy of the Form
object?


.
 
Back
Top