PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Any .NET wrappers?

I was just curious if there os an easy way to use this in .NET. Thanks
Unfortunately not. I would love to add support for it though. I am not sure what is involved though.

Anyone has an idea? Is a wrapper the right way? Or can "managed C++" be used on the PPC? Ideally I would prefer not to have an extra project.
I have done managed wrappers for gapidraw and hekkus. I was going to do one for pocketfrog as well, but don't have the time anymore.

It is fairly straightforward, you need to create a dll that wraps the c++ functions into c functions. Typically I place the object as the first parameter (this is similar to how c++ functions are exported, but it needs to be done with c style mangling and calling).

Then in .net, you write a wrapper object(s) that calls the dll. See my hekkus code if you want an example.


To do pocketfroq would take a couple of days.

Managed c++ can't be used on the ppc.
Thanks for the info Sean.
Oh Please, that would be great!
Is anyone currently working on this?
Mr X:

Would you put the c style c++ wrapping functions in a separate dll from PockeFrog, or would you just add them to the PocketFrog dll?

Also, in your gapidraw .net wrappers do you support windowed mode or just fullscreen?

Thanks in advance!
I don't have the time to do it myself, but I will assist anyone else who wants to have a go.

It is best to have the wrapping functions in the same dll. Makles it harder for them to get out of sync.


gd.net supports windowed mode. The curent version uses a helper dll, the next version won't need it. There is a windowed example in current version.
I am going to give it a go although it will have to be only a couple hours a night. Any information you can lend me will be greatly appreciated. I am going to look into your grapidraw & hekkus wrappers tonight.
The hukkus wrappers will be more use as they include hte dll source as well.

Email me if you have any questions.
So in order to write the .net wrapper I first have to make PF a dll or at least wrap it in a dll, right?

Before I attempt this does anyone know of any reasons that PF wouldn't work as a dll? If not, why isn't there a dll version already? :)
There is no reason for PF not to work as a DLL.

As to why it isn't: DLLs generally bring more problems then they solve. In particular, DLLs are not recommanded on Windows CE as they can cause other apps to not load properly (or at all).

Other issues are: 1) DLLs use more space (the linker cannot remove functions/objects you don't use, 2) Configuration management issues (installtion for example, keeping track of versions).

Anyways, just search for "DLL HELL" in Google and you will have days of interesting reading about DLLs and why you should stay away from them.

BTW, I am not saying DLLs don't have their usage. They can be really useful for certain things. .NET wrappers come to mind =)
Heh, I know all about DLL HELL and DLLs in general. I hadn't known about the issues with windows ce or with the linker removing non-used code though. Thanks.
Looks simple enough. I should have something in a week. :)
My "C wrapper" dll built last night, yay! Wish me luck as I test it tonight and start on the .net side. :) So far it has been smooth sailing.
jweldin, I'm also interested in wrapping PF for .NET/CF, and was planning to devote a couple days to it next week. Perhaps we can combine our efforts?

-dave
because eVC is coming to end of life is that why PocketHAL needs to be used in .NET ?
EVC is coming to to end of life ?

No, don't tell me they are going to switch Kernel and GDI development to NET ?

:)
abiemann,
I want to port it because I like to code in C# and I love the .net IDE and framework. Not all of my ideas for games will require C++ for speed, so i would like to take advantage of what .net has to offer.


Dave,
I am planning on hitting it pretty hard over the weekend. I will let you know where I am on Monday and maybe we can help each other out.
abiemann wrote:because eVC is coming to end of life is that why PocketHAL needs to be used in .NET ?


I've heard 10 years ago that C++ was going away.
abiemann wrote:because eVC is coming to end of life is that why PocketHAL needs to be used in .NET ?


Visual Studio 2005 will compile c++ directly to the arm processor so there will be no need for evc.

Currently I am doing all my ppc work in vs 2005. much nicer.
Status: I haven't had time to work on the wrappers for a couple weeks. I plan on picking it up again mid week.

Mr X: Does VS 2005 allow managed c++ to be run on ppc?
AFAIAA, vs 2005 still only supports managed c# abd vb, not managed c++. It does support native c++ for the arm though.
Any update on this?
No update yet. Seems every time I get into a PPC project some crazy shit happens in my life. :) I am still planning on finishing up the wrappers, but going much slower than I had planned due to lack of free time.

Has anyone else gotten closer to wrappers?
Mr X wrote:Currently I am doing all my ppc work in vs 2005. much nicer.

I've been told it's damn buggy thing currently. No problems? Btw, how do you like the new emulator? It should be the first ARM one, can it actually run any app?
jaguard":2x97a7yu]

I only use the c++ side of things and it is quite nice. I haven't tried the emulator, I debug mostly on the ppc.

It has a few bugs, but vs2003 is as buggy as vs2005.
jweldin · 29 Jan 2005, 04:08 UTC — Some help?
I am knee deep in the dot net wrappers. I have a few questions that I am hoping someone can answer for me.

How do you pass objects by ref in a dllimported function like the one below or do you have to modify the cwrapper to do that for you?
Code:
POCKETFROGCWRAPPER_API void __stdcall rect_extendusingpoint(Rect * pRect, const Point& point);


How do I handle operator overrides? Such as Point overrides the + operator.

How do I handle enums that don't specify values?

I am sure I will have some more questions, but those are the ones that I came accross today.

Thank you in advance to anyone that can help!
Can someone tell me how to create a duplicate of this function
Code:
Rect( const RECT& r ) { *static_cast<RECT*>(this) = r; }
but with the signature of
Code:
Rect( const RECT* r )
please.
I give up. :(

PocketFrog is much more difficult to wrap for dotnet than Hekkus or GapiDraw. PF doesn't have as nice of an interface as hekkus or gapidraw. Both have very clean interfaces with only pointers and simple types as parameters to external functions. Their enums are also exported explicitly. PF was not designed to be a dll and therefore exporting some of the functionalty is a "nut grabber" experience. With that and my limited knowledge of p/invoke and the lack of good documentation on p/invoke for compact framework I feel as though I am wasting my time. If anyone else wishes to pick up the task I can point you in what I believe is the right direction.

However, if anyone would like to convert the PF library to a clean dll with pointers and simple types as the only inputs or outputs to functions, then we might have something to work with.
I take it the ref keyword didn't work?

Function(ref Type t);

I'm curious about this answer as well. I'll dig around and see if I can't find an answer for you.

EDIT:
Okay ref is used for straight pointers, so obviously ref won't work. :) Still looking...

EDIT 2:
Perhaps you could create a new function and call it from there?

Code:

Function(Type* t)
{
RefFunc(*t);
}
Um, yeah that should work. I have been staring at code so long that I didn't even think of that. I have just been trying to find a way to marshal to a reference type in c++. I didn't think of just implementing that in the cwrapper dll.

Thank you!
That is working fine so far... back on track. :)
jweldin wrote:That is working fine so far... back on track. :)


Glad to hear it. :)
I've been doing some marshal stuff lately and here are a few comments that may be helpful:
- IntPtr is a good one to fall back on when nothing else works :)
- there seem to be differences in how structures and classes are handled - sometimes a structure worked, sometimes I had to use a class but I don't understand why
- there are heaps of useful methods on the Marshal class for converting things back and forth between managed .net and unmanaged.
Thank you for the tips. I am about 85% done I think. I have to iron out a few small issues such as the marshaling of a few structs. I also need to implement the Game class for the "framework". I'm getting there. Unfortunately I don't get much time to work on these types of things during the week, so it may have to wait until the weekend to progress anymore.

If you have any samples of how to Marshal a struct as a class could you share them?
This should shed some light on struct vs class in .NET:

Structs are value types, and are always passed by value. Meaning, their values are copied one by one.

Classes are reference types, and are always passed by reference. Meaning, a pointer is passed, and values are not copied.

I know this is common knowledge, but when working with C++ where anything can be a value or reference type, it's easy to forget that .NET works a little differently.
This info should help:

Passing Parameters (value and reference types):
http://msdn.microsoft.com/library/defau ... meters.asp

Passing Parameters with ref:
http://msdn.microsoft.com/library/defau ... lrfref.asp

Passing Parameters with out:
http://msdn.microsoft.com/library/defau ... lrfout.asp

NOTE: I believe passing parameters with the out keyword is the solution for dllimporting functions with reference types. Maybe try this:

In C++:
void func(type& t) { t.val = someVal; }

In C#:
// dll import
void func(out type t);

type t;
func(out t);

Something like that anyway. Check the links above to make sure I got it right, then test. :) I have a feeling it may work!
Thank you for the info. I will read through them tonight. I think I know why the marshaling of my struct is failing. I am trying to pass a struct with an enum as a member as if it were a simple struct with all blittable members. I have some ideas now on how to tackle it. Can't wait to try them.
PocketFrogNet Lives!!!

Tonight I had some time to work on PFN and got it working on my desktop and pocketpc. I still have to flesh out the Game class and do testing to ensure the that functionality all works, but it is definitely downhill from here.

I hope to have something to show by early next week.
Nice. :) Be sure to do some benchmarking and compare performances for us!
Wow, that really sounds like something I could use. Jweldin, would you mind sharing it? I am making a game in C# (.NET) and this could really help me. If you do not have any server space at hand, could you e-mail it to me at: per at cepa dot dk

Thanks in advance.
I do fully intend on sharing it. I had planned on finishing up a couple weeks ago but once again I had to start taking work from my day job home with me at night. Hopefully I will have something of beta quality up for everyone to play with in the next week or so.
Would you mind sending it to me in its current state? It is OK that it is not finish. I only need some very basic functions (initialisation, surface blitting, no croma or anything). I do not need the game framework either.

I know I could make a wrapper for this in a day or two, but it would probably be much faster to build upon what you have.
I don't mind sending what I have but its rough, I'll send it to you sometime this weekend.
Have you send it? I have not recieved anything.
Sorry I got sick and was out of commission for a week with bronchitis. I will send you something tonight. Thank you for your interest.
I STILL have not recieved anything. Did you mail it to the right address?
per @ cepa . dk without the spaces, correct? Yeah I sent it last night. Does your ISP allow large zip attachments? I can re-send when I get home if you still haven't gotten it. Let me know if you don't get it by tonight and we can talk about alternate ways to transfer it.
Yes, that is the correct address. How big is the zip? I just tried to send a 1 mb zip from another account and it worked just fine.

You can also try to send it to perrs at diku dot dk. Just send it to both.

You can also try to send it to via messenger. My email in messenger is perrs at hotmail dot com. I will be up until midnight (CET).

Thanks for your effort!
Okay, I'll try all those tonight when I get home. I should be able to get it out to you before Midnight.. that's 8PM EST, correct? I don't get home until 6PM EST, so don't bother looking for them before that. :)


Later.
Did you get the files?
Yes, thanks alot. I have not had time to look at it yet, though.
This is a good news. I can't wait to try it too.
If you want / can, send it to me please. Thanks in advance.

mail : boris (@) fardoux . com
One of the problems that I am having is producing a display that is not 320x240. No matter what values I pass to create the display I get 320x240. I had hoped to be able to host the display in controls and at least display it on the client part of a window with the title and border still showing. I can change the location of the top/left corner, but that's it... the surface always sets itself to 320x240.

Any ideas/suggestions?
I just realised that windowed mode for pocketpc wasn't added to pockethal until version .8 so I will try that.
Hi, could u pls mail me? rtprtcp at mail.ru
Thanks