This project is read-only.

gameTime and more

Jul 20, 2009 at 3:24 PM

Hey there,

I've just started using your API and I'm really happy with it so far. I've used your 2D graphics API to produce some visual controls like a progress bar for example. However I would like to integrate Neoforce controls but not quite sure how I would go about it.

The first problem I've arrived at is gameTime. In order to call the draw and update methods on the Neoforce manager I must provide a gametime, how would I get the gameTime from the Xen Update and Draw states? I've seen some properties for times in ticks and seconds but not suire if Im using the right ones

I guessed it might be something like this...

GameTime gt = new GameTime(TimeSpan.FromSeconds(state.TotalTimeSeconds), TimeSpan.FromSeconds(state.DeltaTimeSeconds), TimeSpan.FromTicks(state.TotalTimeTicks), TimeSpan.FromTicks(state.DeltaTimeTicks));

However I can't get the Neoforce controls to draw to the screen. I did at first ( dont know how lol) but it was replacing anything Xen related on the screen. But interestingly, even though the xen controls (such as text element) were disapearing if I added drawstatistics and pressed F12 to show all the xen stuff would show with it?Also the Neoforce cursor seems to be working fine  when I override InitialisePlayerInput and set playerInput[PlayerIndex.One].InputMapper.MouseVisible = true;

The Neoforce manager is created like this

guiManager = new Manager((Game)this, graphicsManager, "Default", true);

I get the xnaGame from the application and the graphicsManager by overriding SetupGraphicsDeviceManager in the application. Is this correct?

Forgive my ignorance I'm new to XNA and haven't touched C# in over a year!

Any and all help appreciated :D



Jul 20, 2009 at 3:51 PM
Edited Jul 21, 2009 at 1:38 AM

Ok I kind of got it working now. Heres the situation..

Firstly I can get a Neocontrol window to display! But!

I have a model on screen and animating by using your animated model tutorial code.

I have the drawstatistics added to the screen manager and the text saying "Press F12..." is showing.

I have a Neoforce Window displaying above all of these with full functionality.


But now the animated model is drawing above the draw statistics layer, but showing and hiding still works ok, its just behind the animated model. Here's where it gets strange..when the draw statistic text "Press F12..." fades out, the model goes with it and now when I hide/show the statistics the model hides and shows with it? All the while the Neoforce controls are still functioning. If i dont add the statistics to the screen the model disappears almost instantly.


Any ideas?



Jul 21, 2009 at 1:52 AM

Hi. Internally, xen tracks pretty much every graphics device state it interacts with. So things like render state are internally tracked.
What this means is if you enabled blending, but blending is already enabled, then the XNA state change will never be made. State changes, even when they don't matter, have a big overhead - which is why it's done like this.

The downside, as you are finding out, is if some other code interacts with the graphics device as well. Suddenly the internal tracking data could be wrong, and things become out of sync and you get graphics bugs.
There are two ways to get around this, the first is to tell xen you have been messing with the graphics device directly. If you had been calling GetGraphicsDevice, this is required (you have to specific what you intend to do). However here, Neoforce is using the GraphicsDeviceManager.
So, after neoforce completes it's drawing, you can call:


This will mark all internal tracking state as 'dirty', or unknown.

The second option, is to use an XNA StateBlock. This is a wrapper on a Direct3D object which stores the *entire* application render state, then allows you to reset it. It's probably slower, but would guarantee nothing is going to go out of sync.


The reason GameTime is nowhere to be found in xen, is that early on (back in XNA GS 2.0) GameTime had an internal constructor. And as I do some complex stuff with timesets (to avoid jitter) I couldn't use the one XNA provides.

Jul 23, 2009 at 6:13 PM


Thanks for the reply, Ive got it working now :D All seems ok.

Any ideas why all the models are upside down?