supercell-wx/scwx-qt/source/scwx/qt/gl/text_shader.hpp
2022-10-02 23:44:09 -05:00

57 lines
1.3 KiB
C++

#pragma once
#include <scwx/qt/gl/gl_context.hpp>
#include <scwx/qt/util/font.hpp>
#include <memory>
#include <boost/gil.hpp>
#include <glm/glm.hpp>
namespace scwx
{
namespace qt
{
namespace gl
{
enum class TextAlign
{
Left,
Center,
Right
};
class TextShaderImpl;
class TextShader
{
public:
explicit TextShader(std::shared_ptr<GlContext> context);
~TextShader();
TextShader(const TextShader&) = delete;
TextShader& operator=(const TextShader&) = delete;
TextShader(TextShader&&) noexcept;
TextShader& operator=(TextShader&&) noexcept;
bool Initialize();
void RenderText(const std::string& text,
float x,
float y,
float scale,
const glm::mat4& projection,
const boost::gil::rgba8_pixel_t& color,
std::shared_ptr<util::Font> font,
GLuint textureId,
TextAlign align = TextAlign::Left);
void SetProjection(const glm::mat4& projection);
private:
std::unique_ptr<TextShaderImpl> p;
};
} // namespace gl
} // namespace qt
} // namespace scwx