当前不会命中断点。没有调试器目标代码类型的可执行代码
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);
}
这就是它变得奇怪的地方。我在发布模式下收到此通知。上面的代码在调试中完全有效。无论出于何种原因,当我切换到 Release 时它都不起作用。我检查了发送到函数的 txt
变量,它有文本。对我来说,似乎代码以某种方式被优化了。
我还删除了 Debug 和 Release 文件夹中的所有内容,并进行了全新的构建。没有什么。我已经从 VS 测试了没有 运行 的可执行文件,结果相同。 Release 中的调试显示 txt
中有文本,但我无法确定发生了什么,因为调试器似乎正好漂浮在 font << txt
.
上方
我确实找到了答案。在 printf 的末尾附近使用了一个 assert
。 Release 中没有断言 运行。仅在调试中。
简介:代码在发布模式下不起作用。在调试中工作。
这显示在我的断点之一上:
代码点是:
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);
}
这就是它变得奇怪的地方。我在发布模式下收到此通知。上面的代码在调试中完全有效。无论出于何种原因,当我切换到 Release 时它都不起作用。我检查了发送到函数的 txt
变量,它有文本。对我来说,似乎代码以某种方式被优化了。
我还删除了 Debug 和 Release 文件夹中的所有内容,并进行了全新的构建。没有什么。我已经从 VS 测试了没有 运行 的可执行文件,结果相同。 Release 中的调试显示 txt
中有文本,但我无法确定发生了什么,因为调试器似乎正好漂浮在 font << txt
.
我确实找到了答案。在 printf 的末尾附近使用了一个 assert
。 Release 中没有断言 运行。仅在调试中。