CODECUBE VENTURES

XnaControl Source

Updated for V1

Download the XNA Control

  • Implements IServiceProvider and IGraphicsDeviceService.

  • UpdateMode property which lets you choose whether the control will render on paint, or in a render loop.

  • UpdateScene and RenderScene events.

  • The Control's BackColor property controls the scene's clear color.

  • PresentationParameter's properties are exposed as properties of the control so they are editable with Visual Studio's property grid. I probably need to expose a lot more, will probably do this on an as needed basis.

The source code provided in the download has a form with the XnaControl in a splitter. The form has the code from the How To: Use BasicEffect tutorial that comes with GSE. There is a button in the left split pane which switches the UpdateMode so you can see the manual vs loop modes.

Strangely enough, I'm actually pretty happy with the IServiceProvider implementation. I'm not too crazy about the way that the Game class implements it (specifically, the GameServiceContainer), so the XnaControl uses generics for a much nicer API:

xnaControl.AddService(physService);

IPhysicsService phys = xnaControl.GetService();

xnaControl.RemoveService();

I actually want to provide a binary only assembly at some point so you can download, reference, and drop the control without having to integrate the source code into your own project.

I hope others find this useful :-)

http://codecube.net/xna/CodeCube.Xna.zip

Update v0.2

  • New IScene interface. The XnaControl has a corresponding Scene property that lets you hook into the Update and Render methods without having to use the UpdateScene and RenderScene events. In the demo, the DemoForm implements the interface and simply sets "xnaControl1.Scene = this;"

  • The demo project now has an IDemo interface that you can use to create a new demo. The DemoForm has a combo that lists demos and you can switch between them. Simply add your demo to the demos list in the form's contstructor.

  • Fixed a bug in the XnaControlDesigner where the resource file wasn't being found and a design-time exception was being thrown.

Latest post: Digging Up the First Version of CodeCube

See more in the archives