Original Post
Hey! Currently I'm using my own wrapper for the DX9 VertexDeclaration, so that I'm not tied to the DX9 device. So my RenderDevice has a function: SetVertexDeclaration(IVertexDeclaration decl); It works ok, but the thing is that the code looks so ugly when interpreting my own implementation of a VertexDeclaration to the DirectX version: for eg. The VertexDeclaration has a list of IVertexElement elements. Each of them having a DeclarationType, DeclarationMethod, DeclarationUsage. And interpreting this to the DirectX VertexElement is a plain ugly switch: D3D.VertexElement = DX9Types.Translate(vertexDeclaration.Elements); D3D.VertexElement DX9Types.Translate(IVertexElement element) { switch(element.DeclarationType) { .... } switch(element.DeclarationMethod) { .... } return new D3D.VertexElement(...); } I guess that this will be kinda hard to maintain, so I would really appreciate any thoughts on how to design a better system, mainly how to get ridd of the ugly switches. Thx!