2017-01-30 10 views
0

です。Intro:リリースモードではコードは機能しません。デバッグで動作します。ブレークポイントは現在ヒットしません。 debbugerのターゲットコードタイプの実行可能コードは

これは私のブレークポイントの1に示します。

The breakpoint will not currently be hit. No executable code of the debbuger's target code type is

コードスポットがある:

void Font::operator<<(std::string s) 
{ 
    this->printf(s); // this line 
} 

このメソッドは、このように呼ばれている:

float oneframe; 
oneframe = (double)elapsed/ 1000000.0; 

float ffps =1./oneframe; 
int fps = ffps; 
char txt[200]; 
sprintf(txt, "%d FPS", fps); 
font << txt; // displays text 

のprintfは以下のとおりです。

void Font::printf(std::string s) 
{ 
    UINT lines = 0; 
    std::vector<float> offsetX; 
    float offsetY=0; 
    UINT length = s.size(); 
    XMMATRIX M = XMMatrixScaling(m_scaling.x, m_scaling.y, m_scaling.z)* 
     XMMatrixTranslation(m_translation.x, m_translation.y, m_translation.z); 
    float fontLength=0; 
    float fontHeight = 60.0f/windowHeight; 
    float fontWidth = 60.0f/windowWidth * 0.6f; 

    m_deviceContext->VSSetShader(m_vertexShader, 0, 0); 
    m_deviceContext->IASetInputLayout(m_inputLayout); 
    m_deviceContext->PSSetShader(m_pixelShader, 0, 0); 
    m_deviceContext->PSSetShaderResources(0, 1, &m_texture); 
    m_deviceContext->PSSetSamplers(0, 1, &m_sampler); 
    m_deviceContext->OMSetDepthStencilState(m_dsOff, 1); 

    if (m_anchor != TOP_LEFT) 
    { 
     float offset = 0; 
     for (int i = 0; i < length; i++) 
     { 
      offset += m_kerning*widthMap[s[i]]; 
      if (s[i] == '\n' || s[i] == '\r' || i == length - 1) 
      { 
       offsetX.push_back(offset); 
       offset = 0; 
      } 
     } 
    } 
    for (int i = 0; i < length; i++) 
    { 
     XMFLOAT3 TL(-1, 1, 0), BR(1, -1, 0); 
     XMVECTOR vTL, vBR; 
     if (s[i] == '\n' || s[i] == '\r') 
     { 
      fontLength = 0; 
      lines++; 
      continue; 
     } 
     switch (m_anchor) 
     { 
     default: 
     case TOP_LEFT: 
      vTL = XMVector3TransformCoord(XMLoadFloat3(&XMFLOAT3(fontLength, -m_leading*lines, 0)), M); 
      vBR = XMVector3TransformCoord(XMLoadFloat3(&XMFLOAT3(fontWidth + fontLength, -m_leading*lines - fontHeight, 0)), M); 
      break; 
     case TOP_RIGHT: 
      vTL = XMVector3TransformCoord(XMLoadFloat3(&XMFLOAT3(fontLength - offsetX[lines], -m_leading*lines, 0)), M); 
      vBR = XMVector3TransformCoord(XMLoadFloat3(&XMFLOAT3(fontWidth + fontLength - offsetX[lines], -m_leading*lines - fontHeight, 0)), M); 
      break; 
     case BOTTOM_LEFT: 
      offsetY = m_leading*offsetX.size(); 
      vTL = XMVector3TransformCoord(XMLoadFloat3(&XMFLOAT3(fontLength, -m_leading*lines+ offsetY, 0)), M); 
      vBR = XMVector3TransformCoord(XMLoadFloat3(&XMFLOAT3(fontWidth + fontLength, -m_leading*lines - fontHeight+ offsetY, 0)), M); 
      break; 
     case BOTTOM_RIGHT: 
      offsetY = m_leading*offsetX.size(); 
      vTL = XMVector3TransformCoord(XMLoadFloat3(&XMFLOAT3(fontLength - offsetX[lines], -m_leading*lines + offsetY, 0)), M); 
      vBR = XMVector3TransformCoord(XMLoadFloat3(&XMFLOAT3(fontWidth + fontLength - offsetX[lines], -m_leading*lines - fontHeight + offsetY, 0)), M); 
      break; 
     case CENTER: 
      { 
       offsetY = m_leading*offsetX.size()/2; 
       float halfOffsetx = offsetX[lines]/2; 
       vTL = XMVector3TransformCoord(XMLoadFloat3(&XMFLOAT3(fontLength - halfOffsetx, -m_leading*lines + offsetY, 0)), M); 
       vBR = XMVector3TransformCoord(XMLoadFloat3(&XMFLOAT3(fontWidth + fontLength - halfOffsetx, -m_leading*lines - fontHeight + offsetY, 0)), M); 
       break; 
      } 
     } 
     XMStoreFloat3(&TL, vTL); 
     XMStoreFloat3(&BR, vBR); 
     assert(updateBuffer(TL, BR, fontMap[s[i]])); 
     UINT stride, offset; 
     stride = sizeof(SimpleVertex); 
     offset = 0; 
     m_deviceContext->IASetVertexBuffers(0, 1, &m_vertexBuffer, &stride, &offset); 
     m_deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); 
     m_deviceContext->Draw(6, 0); 
     fontLength += m_kerning*widthMap[s[i]]; 
    } 
    m_deviceContext->OMSetDepthStencilState(m_dsOn, 1); 
} 

ここで奇妙なところがあります。リリースモードでこの通知を受け取ります。上のコードはDebugで完全に動作します。何らかの理由で、リリースに切り替えると機能しません。私は関数に送信されているtxt変数をチェックしました。それにはテキストがあります。私にとっては、コードが何らかの形で最適化されているかのようです。

また、DebugフォルダとReleaseフォルダのすべてを削除して、新しいビルドを実行しました。何もない。 VSから実行せずに実行可能ファイルをテストしましたが、同じ結果です。リリースでのデバッグは、txtにテキストがあることを示していますが、デバッガがfont << txtのすぐ上に浮かんでいるように見える場合はどうなるのか判断できません。

+1

おそらく、リリースビルドで 'Font :: operator <<'がインラインになっているので、その上にブレークポイントを設定できません。おそらく 'Font :: printf'の最初の行にブレークポイントを設定することができます。 –

+1

脇に: '' std :: string''や '' std :: wstring''を一時的に渡すべきではありません。代わりに '' const std :: string&s''を使用してください。 –

+0

@IgorTandetnikはい、私はprintfを見ることができます。 – Robokitty

答えて

0

私は答えを見つけました。最後にprintfにはassertが使用されています。アサーションはリリースでは実行されません。デバッグ時のみ。