DirectX :: SpriteFont / SpriteBatch verhindert, dass 3D-Szenen gezeichnet werden

Ich habe ein Problem mitDirectX::SpriteFont/DirectX::SpriteBatch (von DirectXTK; genau das gleiche Problem wie hier beschrieben:Probleme beim Zeichnen von Text mit der SpriteFont-Klasse).

void DrawScene(void)
{
    HRESULT hr;

    float bgColor_a[4] = { 0.0f, 0.4f, 0.8f, 0.0f };

    g_pDeviceContext->ClearRenderTargetView(g_pRenderTargetView, bgColor_a);
    g_pDeviceContext->ClearDepthStencilView(g_pDepthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);

    XMMATRIX cameraProj = XMLoadFloat4x4(&g_camera._cameraProjection);
    XMVECTOR pos = XMLoadFloat3(&g_camera._pos);
    XMVECTOR target = XMLoadFloat3(&g_camera._target);
    XMVECTOR up = XMLoadFloat3(&g_camera._up);
    XMMATRIX cameraView = XMMatrixLookAtLH(pos, target, up);
    XMMATRIX worldBox2 = XMMatrixIdentity() * (XMMatrixTranslation(2.0f, 0.0f, 0.0f) * XMMatrixRotationY(XMConvertToRadians(g_rotBox2)));
    XMMATRIX wvp = worldBox2 * cameraView * cameraProj;
    XMMATRIX transposeWvp = XMMatrixTranspose(wvp);
    XMStoreFloat4x4(&g_constantBufferPerObject._wvp, transposeWvp);
    g_pDeviceContext->UpdateSubresource(g_pConstantBufferPerObject, 0, NULL, &g_constantBufferPerObject, 0, 0);
    g_pDeviceContext->VSSetConstantBuffers(0, 1, &g_pConstantBufferPerObject);

    g_pDeviceContext->PSSetShaderResources(0, 1, &g_pCageTexture);
    g_pDeviceContext->PSSetSamplers(0, 1, &g_pCubeTextureSamplerState);

    // box
    g_pDeviceContext->DrawIndexed(36, 0, 0);

    wchar_t buffer[32];
    swprintf_s(buffer, 32, L"%.2f", g_fps._fps);

    //g_pSpriteBatch->Begin();
    //g_pSpriteFont->DrawString(g_pSpriteBatch, buffer, XMFLOAT2(30, 30));
    //g_pSpriteBatch->End();

    // Present the backbuffer to the screen
    hr = g_pSwapChain->Present(0, 0);
    if (FAILED(hr))
    {
        ErrorBoxW(L"Cannot present without error.");
    }
}

Ohne die Anrufe nachSpriteBatch::Begin(), SpriteFont::DrawString undSpriteBatch::End() sehen Sie einen strukturierten Würfel, der sich durch den Raum dreht (einen Käfig). Bei den Aufrufen der beschriebenen Funktionen sehen Sie nur die Bilder pro Sekunde in der oberen linken Ecke, aber keinen rotierenden Würfel.

Ich bin den Tutorials von @ gefolChuck Walbourn auf github DirectXTK und kombinierte die 2 Tutorials Draw String mitSpriteFont und Rendern eines primitiven 3D-Objekts (ein einfaches Dreieck). In diesem Beispiel wird die Testzeichenfolge über dem Dreieck gezeichnet. Aber ich verstehe nicht, warum der rotierende Würfel aus meinem Beispiel beim Zeichnen einer Zeichenfolge mit @ nicht sichtbar isSpriteFont Klasse von DirectXTK und ich kann nicht einmal die Ursache finden.

Pixel-Shader-Datei (PixelShader.hlsl):

struct VS_OUTPUT
{
    float4 Pos : SV_POSITION;
    float4 Color : COLOR;
    float2 TexCoord : TEXCOORD;
};

Texture2D ObjTexture;
SamplerState ObjSamplerState;

float4 PS( VS_OUTPUT input ) : SV_TARGET
{
    float4 diffuse = ObjTexture.Sample(ObjSamplerState, input.TexCoord);
    clip(diffuse.a - 0.25);
    return diffuse;
}

Vertex-Shader-Datei (VertexShader.hlsl):

cbuffer constantBufferPerObject
{
    float4x4 WVP;
    float ColorAdjust;
    int Mode;
    int Pad[2];
};

struct VS_OUTPUT
{
    float4 Pos : SV_POSITION;
    float4 Color : COLOR;
    float2 TexCoord : TEXCOORD;
};

VS_OUTPUT VS( float4 pos : POSITION, float4 color : COLOR_ZERO, float4 color2 : COLOR_ONE, float2 texCoord : TEXCOORD )
{
    VS_OUTPUT output;
    float4 temp;
    output.Pos = mul(pos, WVP);  
    temp = color;
    output.Color.r = temp.r * color2.r * (1.0f - ColorAdjust);
    output.Color.g = temp.g * color2.g * (1.0f - ColorAdjust);
    output.Color.b = temp.b * color2.b * (1.0f - ColorAdjust);
    output.Color.a = color.a * color2.a;
    output.TexCoord = texCoord;
    return output;
}

Um das Problem zu reproduzieren: Ich arbeite mit Visual Studio 2015 Community Edition. Ich habe DirectXTK (.lib) und DirectXTex WICTextureLoader .cpp / .h,DDSTextureLoader .cpp / .h, .lib) zu meinem Projekt. Bild für Würfel ist .png mit Alpha.

Hinwei: Ich habe dieses @ erstel dupliziert frage, an

vermeide ... um Hilfe bitten, Aufschluss geben oder auf andere Antworten antworten.

auf die andere Frage.

Antworten auf die Frage(4)

Ihre Antwort auf die Frage