Boost logo

Boost :

Subject: Re: [boost] boost::directx?
From: Christian Schladetsch (christian.schladetsch_at_[hidden])
Date: 2009-06-09 00:30:01

Some have asked what sort of thing would be in the proposed library.

I put together a quick demo of the sort of thing I would like to see in a
boost::directx library, and it's in the vault at

This would be quite obscure to those without DX experience, but I will
explain it in more detail to clarify my motives and goal. This is just a
single piece, but I'll go into some detail to demonstrate the sort of things
that I think would be helpful in boost::directx.

In DirectX (and any other low-level graphics system), there is a need to
reflect the vertex types. Typically, users will do something like this:

struct MyVertex
    float3 position;
    float2 texture[2];
    float3 normal;

VertexDescriptor MyVertexDesc[] =

The descriptor is required to inform the hardware about both the syntax and
the semantics of your vertex layout.

Clearly, the way this is currently done is error-prone. The vertex layout is
not type-related to the vertex description. This causes a lot of problems,
most obviously when they get out of sync, but even creating them at all is a
royal pain. And you need to do this sort of thing a lot these days in modern

The system in my proposal unites the two requirements:

    using namespace boost::directx;
    typedef make_vertex<vertex::Position<>, vertex::Normal<>,
vertex::Texture<2> > MyVertex;
    MyVertex vert;
    vert.position = float3(1,2,3);
    vert.texture[0] = float2(1,2);
    vert.texture[1] = float2(3,4);
    vert.normal = float3(4,5,6);
    vertex::declaration decl = MyVertex::make_decl();

This solves a real problem faced by DirectX developers every day. It uses
'advanced' techniques, and is a demonstration of how to use
boost::mpl::fold, and how type-traits are used to map C++ types to
enumerated values.

Is it domain-specific? Yes, it is specific to the area of "attempt at best
practises for creating vertex types for DirectX applications in C++".
Similarly, one assumes that boost.graph is specific to the area of "best
practises for creating and using graphs in C++".

I don't want to quabble over fine distinctions, but if a requirement is that
a library must be shown two work on two platforms, DirectX works on the
following platforms: Xbox360, Zune, and various Windows varieties (XP,
Vista, Windows 7). I am unsure of the status of DirectX under WINE. For what
it's worth, it is also supported on the Dreamcast which is not a MS
product. Of course, you also can't buy one these days but I digress.

There are many other areas in the day-to-day life of a DirectX C++ developer
that could be addressed with some "best-practise" attention. Inclusion of
those systems within boost would be beneficial to the DirectX and C++
communities that use it, and make boost more relevant to the requirements of
performance-oriented C++ developers.


Boost list run by bdawes at, gregod at, cpdaniel at, john at