# Vertexquads are not being drawn in 2D space

I started teaching myself DirectX a short time ago and have come across a problem which I can't figure out by myself unfortunately. I'm trying to build my own font system, so I can draw strings in 2D screenspace. Until now Until now I have managed to create a function to which I just have to pass the string and the screenspace-positions., and it generates all vertices for / sets up the buffers etc (quads that i draw a certain portion of the font texture on). When I draw these vertices in 3D space, everything looks like it works like it should be.

(Forgot to hide the cube) As soon as I try to switch to 2D, I just get a window filled with the blue backgroundcolor. To switch to 2D I do the following things:

graphics.context->ClearDepthStencilView(graphics.depthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);
context->OMSetDepthStencilState(depthDisabledStencilState, 1);

WVP = XMMatrixOrthographicLH((float)mWidth, (float)mHeight, 0.0f, 1.0f);
cbPerVert.WVP = XMMatrixTranspose(WVP);
cbPerVert.World = XMMatrixTranspose(World);

context->UpdateSubresource( cbPerVertexBuffer, 0, NULL, &cbPerVert, 0, 0 );
context->VSSetConstantBuffers( 0, 1, &cbPerVertexBuffer );


My Question is now what I am doing wrong here. If the vertices are being genrated and drawn correctly, afaik all I have to do is project them into screenspace and disable the depth buffer, which I did here.. BTW: I randomly tried drawing the cube with my 2D settings and it was properly drawn.. Help is much appreciated :)

• Your font vertices could be the problem probably, if your cube is drawn correctly. (rough guess: maybe your font vertices are on the XZ plane and your projection projects to the XY plane?) – János Turánszki Feb 12 '14 at 21:58
• Thanks for the comment. The font vertices are in the XY-Plane, and for getting the cube drawn correctly in 2D I set the z-componenents of all cube-vertices to 0. – user42149 Feb 12 '14 at 22:11
• I doubt anyone would get you anything but guesses with so little information, I suggest you debug your code yourself. (For example you could check your font vertices after the matrix multiplication, or check with a graphics debugger) – János Turánszki Feb 12 '14 at 22:41
• wild guess 2: Maybe you are culling the wrong side of your quads? – János Turánszki Feb 12 '14 at 22:48
• Thanks a whole lot! Today I learned what culling is thansk to you :D Looks like I filled the vertexbuffer in such a way that I was drawing backfaces. Fixed that. Thanks! – user42149 Feb 12 '14 at 23:18