VOXELFONT: option to mirror y axis
parent
49b620a2ad
commit
bc7cefea4e
|
@ -128,6 +128,7 @@ bool VoxelFont::renderGlyphs(const char* string) {
|
|||
int spaceWidth = 0;
|
||||
int chars = 0;
|
||||
const bool mergeQuads = _optionMask & MergeQuads;
|
||||
const bool originUpperLeft = _optionMask & OriginUpperLeft;
|
||||
for (int c = core::utf8::next(s); c != -1; c = core::utf8::next(s)) {
|
||||
int w;
|
||||
int h;
|
||||
|
@ -156,8 +157,14 @@ bool VoxelFont::renderGlyphs(const char* string) {
|
|||
for (int y = 0; y < h; ++y) {
|
||||
for (int x = 0; x < w; ++x) {
|
||||
if (bitmap[y * w + x] >= 25) {
|
||||
int finalY;
|
||||
if (originUpperLeft) {
|
||||
finalY = y;
|
||||
} else {
|
||||
finalY = regionH - y;
|
||||
}
|
||||
for (int i = 0; i < _thickness; ++i) {
|
||||
v.setVoxel(glm::ivec3(x + ix0, regionH - y, i), voxel);
|
||||
v.setVoxel(glm::ivec3(x + ix0, finalY, i), voxel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
~VoxelFont();
|
||||
|
||||
static const uint8_t MergeQuads = 1 << 0;
|
||||
static const uint8_t OriginUpperLeft = 1 << 1;
|
||||
|
||||
bool init(const char* font, int fontSize, int thickness, uint8_t optionMask, const char* glyphs);
|
||||
void shutdown();
|
||||
|
|
|
@ -41,7 +41,7 @@ private:
|
|||
const int _depth;
|
||||
const uint8_t _optionMask;
|
||||
public:
|
||||
VoxelFontRenderer(int fontSize, int depth = 4, uint8_t optionMask = voxel::VoxelFont::MergeQuads);
|
||||
VoxelFontRenderer(int fontSize, int depth = 4, uint8_t optionMask = voxel::VoxelFont::OriginUpperLeft | voxel::VoxelFont::MergeQuads);
|
||||
|
||||
bool init() override;
|
||||
void shutdown() override;
|
||||
|
|
|
@ -131,6 +131,9 @@ void TestVoxelFont::onRenderUI() {
|
|||
if (ImGui::Checkbox("Merge Quads", &_mergeQuads)) {
|
||||
changeFontSize(0);
|
||||
}
|
||||
if (ImGui::Checkbox("Upper left (origin)", &_upperLeft)) {
|
||||
changeFontSize(0);
|
||||
}
|
||||
ImGui::Text("Font vertices: %i, indices: %i", _vertices, _indices);
|
||||
ImGui::Text("Ctrl/+ Ctrl/-: Change font thickness");
|
||||
ImGui::Text("Space: Toggle merge quads");
|
||||
|
|
|
@ -20,6 +20,7 @@ private:
|
|||
int _fontSize = 20;
|
||||
int _thickness = 4;
|
||||
bool _mergeQuads = false;
|
||||
bool _upperLeft = false;
|
||||
|
||||
int _vertices = 0;
|
||||
int _indices = 0;
|
||||
|
|
Loading…
Reference in New Issue