[.net] Engine programming with Managed DirectX in C#.

Started by
6 comments, last by ViLiO 18 years, 2 months ago
I have been checking out managed directX for a while, using it to render bitmaps for my game since DirectDraw is deprecated, but now I finally moved on to 3d and i'm thinking about writing a small (very very very small) and simple (very very very simple, at least in the beginning) 3d-engine to fully understand all aspects of 3d-programming. I am not a newbie in the aspects of programming, but i'm a newbie to 3d-programming. I got many questions, so if any of you guys (or girls) could answer I would be truly greatful. Question 1: How should I design the design of the engine and what should I think about to make it extendable. Any thoughts, URL:s or examples are welcome. Question 2: When resetting devices, I've previously recreated resources manually, but is there a smart way to automate this with some kind of resource manager? I have a ton of other questions, but if I can get a discussion on these topics, that would probably get me a step closer to my goal. Best regards / Patrik Svensson, Sweden. [Edited by - guero on January 30, 2006 10:25:05 PM]
Advertisement
For the design the only advice I can offer is keep things modular and work in Systems of Systems.

I also use DirectX/C# but for my 2D game engine. I use a combination of a texture manager and automated drawing classes that require a reference to the Device to stay "alive".
Just put the game and engine in different namespaces, that's a start.
Make your own class, eg. Engine.DXDevice and pass the control in the constructor of the class, to separate the device from the form.
You will probably have some event handlers, like
                device = new Device(0, DeviceType.Hardware, control, flags, presentParams);                    device.DeviceLost  += new EventHandler(this.OnLostDevice);                device.DeviceReset += new EventHandler(this.OnResetDevice);                device.DeviceResizing += new CancelEventHandler(this.OnDeviceResizing);                OnResetDevice(device, null);

You can have those handlers raise your own event and have the game subscribe to this event. This way whenever the device is lost or the resources should be recreated the engine will call the method the game provided.
Krisc:

I have somehow the same idea. Can you explain your resource manager in a little bit more detail? Thanks :)

Fidelio66:

Thank you for your help, but I have no problem understanding how the Direct3D device work. My problem is the design of a stabile framework for my engine and what to implement. I also know where and when I should recreate or release resources, but what I'm looking for is a generic and automated way to do this; a resource manager.

Although, your help is appreciated. It's the thought that counts ;)

Best regards / Patrik Svensson
Well the texture manager is simple... basically a class can register a texture with the manager and it will hold a reference to the texture and re-create it when necessary or call an external method if the class that registered the texture set that up. It gives you the ability to check for duplicate textures, etc.

When writing an engine, events/delegates come into play everywhere. :P
Well, you might want to check out the source code to ShipHo, as well as the currently available articles on it. It's no definite guide to 3D engine programming in MDX, but it should give you plenty of ideas on how things could be done, including 'automatic' resource management and scene management.

Hope this helps :)
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
The guys at DigiPen are doing a webcast series on 3D game dev using C#. Check it out here

Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development

Quote:Original post by Machaira
The guys at DigiPen are doing a webcast series on 3D game dev using C#. Check it out here

Awesome! Thanks for that url [grin]
Richard 'ViLiO' Thomasv.net | Twitter | YouTube

This topic is closed to new replies.

Advertisement