add 3D text render (WIP)

This commit is contained in:
MihailRis
2024-11-12 03:14:59 +03:00
parent c5ca9128e9
commit b3ab037115
9 changed files with 176 additions and 25 deletions
+16 -3
View File
@@ -3,10 +3,13 @@
#include <memory>
#include <string>
#include <vector>
#include <glm/glm.hpp>
#include "typedefs.hpp"
class Texture;
class Batch2D;
class Batch3D;
class Camera;
enum class FontStyle {
none,
@@ -30,18 +33,28 @@ public:
/// @param text selected text
/// @param length max substring length (default: no limit)
/// @return pixel width of the substring
int calcWidth(const std::wstring& text, size_t length=-1);
int calcWidth(const std::wstring& text, size_t length=-1) const;
/// @brief Calculate text width in pixels
/// @param text selected text
/// @param offset start of the substring
/// @param length max substring length
/// @return pixel width of the substring
int calcWidth(const std::wstring& text, size_t offset, size_t length);
int calcWidth(const std::wstring& text, size_t offset, size_t length) const;
/// @brief Check if character is visible (non-whitespace)
/// @param codepoint character unicode codepoint
bool isPrintableChar(uint codepoint) const;
void draw(Batch2D* batch, std::wstring_view text, int x, int y);
void draw(Batch2D& batch, std::wstring_view text, int x, int y, float scale=1) const;
void draw(
Batch3D& batch,
const Camera& camera,
std::wstring_view text,
const glm::vec3& pos,
float scale = 1
) const;
const Texture* getPage(int page) const;
};