Text::Text(const std::string& name, const std::string& text, std::shared_ptr<Font> font, int font_size, const glm::vec4& color) : Node(name, Forward), mFont(font), mText(text), mFontSize(font_size), mColor(color) { setAlign(Center, Center); recreateBuffer(); }
void IndexBufferD3D11::setData(const void* data, uint32 size) { if (size == 0) { throw std::invalid_argument("Invalid size for index buffer: 0"); } if (size > mBufferDesc.ByteWidth) { mBufferDesc.ByteWidth = size; recreateBuffer(data); } else if (size < mBufferDesc.ByteWidth) { D3D11_BOX box; box.back = box.front = 0; box.bottom = 1; box.top = 0; box.left = 0; box.right = size; mDevice->getImmContext()->UpdateSubresource(mBuffer, 0, &box, data, size, 0); } else { mDevice->getImmContext()->UpdateSubresource(mBuffer, 0, nullptr, data, size, 0); } }
void Text::setAlign(Text::Align vertical, Align horizontal) { mVerticalAlign = vertical; mHorizontalAlign = horizontal; recreateBuffer(); }
void Text::setColor(const glm::vec4& color) { mColor = color; recreateBuffer(); }
void Text::setFontSize(int font_size) { mFontSize = font_size; recreateBuffer(); }
void Text::setText(const std::string& text) { mText = text; recreateBuffer(); }
void Text::setFont(std::shared_ptr<Font> font) { mFont = font; recreateBuffer(); }