views:

178

answers:

3

I'm currently in need of a purely managed code DirectX wrapper for .NET. While SlimDX is great, its use of unmanaged code makes it impossible to perform proper dead code analysis on, for the purpose of merging it into your assemblies. With a pure managed wrapper, I'd be able to include just the pieces I use in my assembly, allowing very, very small binaries (my goal is to be able to write 64k demos entirely using .NET).

Does such a thing exist, or am I going to be getting intimate with P/Invoke?

A: 

You will have to go with P/Invoke and will probably find it too slow (certain data structures P/Invoke very slowly).

Joshua
Yea, that's one of my concerns. I guess there is the option of emitting unmanaged wrappers at runtime.
Cody Brocious
There is. That's what mixed mode assemblies are for.
Joshua
Well no, the problem with mixed mode assemblies is that you can't strip away what you don't want -- that's why SlimDX is no good. I could of course do all of that by hand, but that's considerably more difficult. It's looking like just going OGL is going to save me a lot of time and space.
Cody Brocious
+1  A: 

No such thing, gotta roll your own. And you don't have to worry about the size of your assemblies when you use P/Invoke - if anything, they'll be a lot smaller than if you included their managed counterparts.

Depending on what you're doing (video? audio? 3D?), DirectShow.NET is a fun place to start with this sort of thing, given that it's incomplete and no longer supported.

MusiGenesis
I'm planning on writing full 64k demos (so audio and 3d in a single 64KB binary), but the concern with using something like SlimDX is that I can't strip away the parts I'm not using. However, the more I think through it, the more I wonder why I'm not just using OpenGL with some special hacks.
Cody Brocious
If you're this concerned with size, then P/Invoke is *the* way to go in general. Are you trying to make *everything* under 64K (including code and resources etc.)?
MusiGenesis
Yes, entirely within 64k. The problem with P/Invoke for DX is that the interfaces don't lend themselves well to being P/Invoked. In fact, I'm not certain you /can/ P/Invoke them without having some sort of unmanaged code to handle the VTables.
Cody Brocious
I guess my follow-up would be: why 64K? Even if your assembly is under 64K, it isn't *really* that small because it links to a boatload of .Net DLLs and whatnot.
MusiGenesis
In the demoscene, there are two (standard) classifications for intros: 4K and 64K
Cody Brocious
Surely they don't accept .Net demos? I thought with demos *absolutely everything* had to be under the minimum size. A .Net EXE is virtually a Visual Basic "application" (not that there's anything wrong with that).
MusiGenesis
Most do, yes. For the same reason that they accept demos that use the OpenGL ICD and the kernel.
Cody Brocious
I assume the demo scene is kind of like skateboarding, in the sense that there's no way in hell you could ever make a living doing it?
MusiGenesis
Directly? No, you can't really do so. However, the skills translate directly to things like game development, and many successful game companies have been started by demosceners (e.g. Remedy Entertainment, creators of Max Payne, Alan Wake, 3DMark, etc).
Cody Brocious
The demo scene is one of those things where if you don't get it, no-one can explain it to you. If you need to ask "why 64Kb", you definitely don't get it :)
FerretallicA
@FerretallicA: I "get" the demo scene - I've written a software synthesizer for smartphones, so I understand the challenge of getting a lot out of a little. I just think writing an app where the EXE happens to be under 64K but only runs at all because a multi-MB framework is already installed on the machine and does all the complicated work for you is a violation of the whole idea of demos.
MusiGenesis
A couple of months ago my co-worker showed me a game he'd written the night before using XAML. It had 3D tanks in a desert and you drove around and shot at stuff. The XAML for this was something like 120 lines. Does this count as a demo?
MusiGenesis
A: 

There is the managed directx wrapper (MDX) that microsoft shipped with the directx sdk for a while. It's now considered obsolete and not supported but that doesn't mean it doesn't work... To be honest I know little about it or if it will be suitable for your application but it might be worth a look.

John Burton