WPF XEN Control

Apr 5, 2013 at 10:34 AM
So I created a little custom control in WPF that hosts an XNA program by just using a graphics device to present stuff (outside of the game class). I'd love to use the power of Xen to aid me in making cool stuff (I'm a huge fan), but I can't. With XNA it's easy to make my own game wrapper object to fit into my UI- just make the graphics device and present it at my own intervals on my own Window Handler, but with Xen, everything is so inter-dependent (which, generally is a good thing? Just not in this case). I MUST call app.Run() in order for the content to get initialized and get everything to work, but if I call app.Run(), I have no choice but to get a new game window I don't want. Besides, even if I could create an Xen program without the Application class, I cannot make my own UpdateState's or FrameState's to use in my own class because there is no constructor for those classes and those classes are sealed. There's probably additional issues I haven't considered since Xen is not designed for this use, but ya, a system where I can opt out of creating an XNA game window and a system where I can present the GraphicsDevice myself would be magic on top of this already magical API. Perhaps an addition (to the Application class) of BeginInit() to do all of the initialization logic minus running the game, and then something similar to the Game's Tick() function which calls Update() and Draw()? That is if you are doing any additional releases-- and it's an easy thing to do. In case anybody is curious, I'm developing tools for my games, and a contained 3D display is... well.. nice. Especially if it is Xen's. Also, if I get this working, I'll be a very happy man, and I'd be just as happy to share my solution for WPF support.
Developer
Apr 5, 2013 at 3:44 PM
You probably already know that this awesome API is no longer supported by the original author. I've been trying to follow up in cases where I already know the answer to a given question because I've already done it myself, but in this case I don't :)

So, sadly, I don't think you're going to really get much support or a response on how to implement this. I'd be very surprised if you do. My guess, and best bet is that you just have to dig in and modify the XEN API yourself, and if you manage to get what you want, then post your solution on what you did.

That said, maybe I can provide one suggestion. I'm thinking that your best bet is to create your own window, and simply pass in the GDI window handle to XEN instead of having XEN create its own one. That might get your going for a bit, but you'll also have to make sure your properly hook into all of the callbacks including window resizing, mouse input etc. Just my $0.02.
Coordinator
Apr 5, 2013 at 5:45 PM
Edited Apr 5, 2013 at 5:49 PM
Hi.

I created Xen all those years ago. I periodically check these forums (as you'd imagine, they are quite quiet).
As Abuzer has mentioned, I no longer support the project. I work full time in the game industry (currently for Guerrilla Games) so I simply don't have the energy to maintain the project anymore. (And haven't for several years)

Previous versions of Xen had support for running inside a WinForms control - however in the transition to XNA 4.0 I removed this (I simply didn't have the time to look into it). However, on reflection it appears to be a fairly simple thing to get it working again. The code for this class is still present in the project - just not included (WinFormsHost.cs and WinFormsExample). However they are not hooked in, and also have not been updated to changes in XNA 4.0 - so they require uncommenting some code in Application.cs :-) and reworking how CreateDevice is implemented in WinFormsHost. Just make sure to force it to not be fullscreen, otherwise it just crashes with no obvious error.

I've promoted Abuzer to developer, so I'm quite happy for you to take care of the project. If you are unhappy about this then please let me know, I don't want this to feel like a responsibility - more if you want to make an improvement, you have my go ahead. You have stuck with the project, often helping people out it my absence which I greatly appreciate.
The nature of running a project like this is it has a lot of subtle pressures, so I absolutely don't want to feel like I'm shifting these over to you. Even simple things end up taking a surprising amount of time and effort (I never did fix the broken and out of date source depo :)

I'm actually on holiday right now (in the sense I'm catching up on lost sleep and playing games) which is why I'm replying. :-)

Take care, and thanks for the kind words.
Apr 6, 2013 at 4:11 AM
Wow!!! Really fast replies, thanks! So uh... I cracked open the source code, and I got it working!!! So that's really good. It took me all day, and some of the things I did to it was- shall we say- hack-ish, but it works now. The only remaining issue is that after I initialize it, I can't seem change the destination rectangle of the rendering- even though I am calling graphicsDevice.Present() (Yes, I am doing that because I have to) with the correct source and destination rectangles. Actually, on second thought, I'll bet you it has something to do with the DrawTargetScreen... ah gosh I dunno, but unless the answer to that one is obvious to either of you, I'm going to call it "good enough" and just restrict any resizing of the display. Oh and my solution should also work nearly seamlessly for WinForms. I can't share it right now because I need to finish my High School Senior project (which this is a part of) ASAP, but once I turn it in I'll come back here, clean it up a bit, and share it.

I'm trying to bump up my current projects to Xen because it is soooo nice compared to good 'ole XNA. (This is mainly projects Crucible and Space found on http://www.fridaygamestudios.com/ ) I'm also developing tools for these games, hence why I made this control.

Also- completely unrelated, but YOU WORK AT GUERILLA??? I want to be you one day! Do you have any advice for somebody like me who is trying to break in to the industry? (not necessarily games-- I'd be happy with any programming job haha)
-Patrick