mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
add missing functionality to show an atlas face
This commit is contained in:
parent
d7a53cd25f
commit
565d0ca543
2 changed files with 36 additions and 0 deletions
|
@ -74,6 +74,9 @@ public:
|
|||
/// append a wide char unicode string to the buffer using current pen position and color
|
||||
void appendText(FontHandle _fontHandle, const wchar_t* _string);
|
||||
|
||||
/// append a whole face of the atlas cube, mostly used for debugging and visualizing atlas
|
||||
void appendAtlasFace(uint16_t _faceIndex);
|
||||
|
||||
/// Clear the text buffer and reset its state (pen/color)
|
||||
void clearTextBuffer();
|
||||
|
||||
|
@ -277,6 +280,29 @@ void TextBuffer::appendText(FontHandle _fontHandle, const wchar_t* _string)
|
|||
}
|
||||
}
|
||||
}
|
||||
void TextBuffer::appendAtlasFace(uint16_t _faceIndex)
|
||||
{
|
||||
float x0 = m_penX;
|
||||
float y0 = m_penY;
|
||||
float x1 = x0 + (float)m_fontManager->getAtlas()->getTextureSize();
|
||||
float y1 = y0 + (float)m_fontManager->getAtlas()->getTextureSize();
|
||||
|
||||
m_fontManager->getAtlas()->packFaceLayerUV(_faceIndex, (uint8_t*)m_vertexBuffer, sizeof(TextVertex) * m_vertexCount + offsetof(TextVertex, u), sizeof(TextVertex) );
|
||||
|
||||
setVertex(m_vertexCount + 0, x0, y0, m_backgroundColor);
|
||||
setVertex(m_vertexCount + 1, x0, y1, m_backgroundColor);
|
||||
setVertex(m_vertexCount + 2, x1, y1, m_backgroundColor);
|
||||
setVertex(m_vertexCount + 3, x1, y0, m_backgroundColor);
|
||||
|
||||
m_indexBuffer[m_indexCount + 0] = m_vertexCount + 0;
|
||||
m_indexBuffer[m_indexCount + 1] = m_vertexCount + 1;
|
||||
m_indexBuffer[m_indexCount + 2] = m_vertexCount + 2;
|
||||
m_indexBuffer[m_indexCount + 3] = m_vertexCount + 0;
|
||||
m_indexBuffer[m_indexCount + 4] = m_vertexCount + 2;
|
||||
m_indexBuffer[m_indexCount + 5] = m_vertexCount + 3;
|
||||
m_vertexCount += 4;
|
||||
m_indexCount += 6;
|
||||
}
|
||||
|
||||
void TextBuffer::clearTextBuffer()
|
||||
{
|
||||
|
@ -801,6 +827,13 @@ void TextBufferManager::appendText(TextBufferHandle _handle, FontHandle _fontHan
|
|||
bc.textBuffer->appendText(_fontHandle, _string);
|
||||
}
|
||||
|
||||
void TextBufferManager::appendAtlasFace(TextBufferHandle _handle, uint16_t _faceIndex)
|
||||
{
|
||||
BX_CHECK(bgfx::invalidHandle != _handle.idx, "Invalid handle used");
|
||||
BufferCache& bc = m_textBuffers[_handle.idx];
|
||||
bc.textBuffer->appendAtlasFace(_faceIndex);
|
||||
}
|
||||
|
||||
void TextBufferManager::clearTextBuffer(TextBufferHandle _handle)
|
||||
{
|
||||
BX_CHECK(bgfx::invalidHandle != _handle.idx, "Invalid handle used");
|
||||
|
|
|
@ -60,6 +60,9 @@ public:
|
|||
/// append a wide char unicode string to the buffer using current pen position and color
|
||||
void appendText(TextBufferHandle _handle, FontHandle _fontHandle, const wchar_t* _string);
|
||||
|
||||
/// append a whole face of the atlas cube, mostly used for debugging and visualizing atlas
|
||||
void appendAtlasFace(TextBufferHandle _handle, uint16_t _faceIndex);
|
||||
|
||||
/// Clear the text buffer and reset its state (pen/color)
|
||||
void clearTextBuffer(TextBufferHandle _handle);
|
||||
|
||||
|
|
Loading…
Reference in a new issue