diff --git a/Editor/resources/Shaders/sdf_text.shader b/Editor/resources/Shaders/sdf_text.shader new file mode 100644 index 00000000..1e94e193 --- /dev/null +++ b/Editor/resources/Shaders/sdf_text.shader @@ -0,0 +1,52 @@ +#shader vertex +#version 460 core +layout(location = 0) in vec3 Position; +layout(location = 1) in vec2 UV; + +uniform mat4 model; +uniform mat4 projection; + +out vec2 a_UV; + +void main() +{ + a_UV = UV; + gl_Position = projection * model * vec4(Position, 1.0); +} + +#shader fragment +#version 460 core +out vec4 FragColor; + +in vec2 a_UV; + +uniform vec2 texPos; +uniform vec2 texScale; +uniform sampler2D msdf; +uniform vec4 bgColor; +uniform vec4 fgColor; + +uniform float pxRange; // set to distance field's pixel range + +float screenPxRange(vec2 coord) { + vec2 unitRange = vec2(pxRange) / vec2(textureSize(msdf, 0)); + vec2 screenTexSize = vec2(1.0) / fwidth(coord); + return max(0.5 * dot(unitRange, screenTexSize), 1.0); +} + +float median(float r, float g, float b) { + return max(min(r, g), min(max(r, g), b)); +} + +void main() { + vec2 textSize = textureSize(msdf, 0); + + vec2 uv = vec2(mix(texPos.x / textSize.x,texScale.x / textSize.x, a_UV.x), + mix(texScale.y / textSize.y, texPos.y / textSize.y, a_UV.y)); + + vec3 msd = texture(msdf, uv).rgb; + float sd = median(msd.r, msd.g, msd.b); + float screenPxDistance = screenPxRange(uv) * (sd - 0.5); + float alpha = smoothstep(0.5 - 1/16.0, 0.5 + 1 / 16.0, sd); + FragColor = mix(bgColor, fgColor, alpha); +} \ No newline at end of file diff --git a/Editor/src/EditorInterface.cpp b/Editor/src/EditorInterface.cpp index d9bb7aa6..49559889 100644 --- a/Editor/src/EditorInterface.cpp +++ b/Editor/src/EditorInterface.cpp @@ -19,7 +19,7 @@ #include "src/Resource/Project.h" #include #include - +Ref userInterface; ImFont* normalFont; ImFont* EditorInterface::bigIconFont; void EditorInterface::Init() @@ -56,6 +56,19 @@ void EditorInterface::DrawViewport() } } + + ImGui::End(); + if (ImGui::Begin("SDF FONT")) + { + ImVec2 regionAvail = ImGui::GetContentRegionAvail(); + if (userInterface) + { + auto id = userInterface->font->FontAtlas->GetID(); + ImGui::Image((void*)id, regionAvail, ImVec2(0, 1), ImVec2(1, 0)); + + } + + } ImGui::End(); if(ImGui::Begin("Viewport")) { @@ -222,7 +235,6 @@ void EditorInterface::DrawSceneTree() // Buttons to add and remove entity. ImGui::BeginChild("Buttons", ImVec2(300, 20), false); { - // Add entity. if (ImGui::Button("Add")) Engine::GetCurrentScene()->CreateEntity("Entity"); @@ -895,7 +907,7 @@ void OpenProject() Engine::LoadProject(project); // Create new interface named test. - Ref userInterface = UI::UserInterface::New("test"); + userInterface = UI::UserInterface::New("test"); // Set current interface running. diff --git a/Nuake/src/Rendering/Renderer2D.cpp b/Nuake/src/Rendering/Renderer2D.cpp index edc6419d..5bb1083a 100644 --- a/Nuake/src/Rendering/Renderer2D.cpp +++ b/Nuake/src/Rendering/Renderer2D.cpp @@ -2,6 +2,8 @@ #include "GL/glew.h" #include "../Core/Maths.h" Ref Renderer2D::UIShader; +Ref Renderer2D::TextShader; + unsigned int Renderer2D::VAO; unsigned int Renderer2D::VBO; @@ -10,7 +12,7 @@ Matrix4 Renderer2D::Projection; void Renderer2D::Init() { UIShader = CreateRef("resources/Shaders/ui.shader"); - Projection = glm::ortho(0.f, 1920.f, 1080.f, 0.f, -0.5f, 100.0f); + TextShader = CreateRef("resources/Shaders/sdf_text.shader"); float quad_Vertices[] = { // positions // texture Coords @@ -49,6 +51,74 @@ void Renderer2D::DrawRect() glDrawArrays(GL_TRIANGLES, 0, 6); } +Vector2 Renderer2D::CalculateStringSize(const std::string& str, Ref font, Vector2 position, float fontSize) +{ + float advance = 0.0f; + float Y = 0.0f; + for (char const& c : str) { + Char& letter = font->GetChar((int)c); + advance += letter.Advance * fontSize; + if(letter.PlaneBounds.top - letter.PlaneBounds.bottom > Y) + Y = letter.PlaneBounds.top - letter.PlaneBounds.bottom; + } + return Vector2(advance, Y); +} + +void Renderer2D::DrawString(const std::string& str, Ref font, Vector2 position, float fontSize) +{ + TextShader->Bind(); + TextShader->SetUniformMat4f("projection", Projection); + float advance = 0.0f; + font->FontAtlas->Bind(5); + TextShader->SetUniform1i("msdf", 5); + for (char const& c : str) { + Char& letter = font->GetChar((int)c); + + Matrix4 mat = Matrix4(1.0f); + mat = glm::translate(mat, Vector3(position.x + advance, position.y - (letter.PlaneBounds.top * fontSize), 0.f)); + float scaleX = letter.PlaneBounds.right - letter.PlaneBounds.left; + float scaleY = letter.PlaneBounds.top - letter.PlaneBounds.bottom; + mat = glm::scale(mat, Vector3(scaleX * fontSize, scaleY * fontSize, 0.f)); + + TextShader->SetUniform2f("texPos", letter.AtlasBounds.Pos.x, letter.AtlasBounds.Pos.y); + TextShader->SetUniform2f("texScale", letter.AtlasBounds.Size.x, letter.AtlasBounds.Size.y); + TextShader->SetUniformMat4f("model", mat); + //TextShader->SetUniform4f("bgColor", 0, 0, 1, 1); + TextShader->SetUniform4f("bgColor", 0.f, 0.f, 0.f, 0.f); + TextShader->SetUniform4f("fgColor", 1.f, 1.f, 1.f, 1.f); + //TextShader->SetUniform1f("pxRange", 32); + glBindVertexArray(VAO); + glDrawArrays(GL_TRIANGLES, 0, 6); + advance += letter.Advance * fontSize; + } +} + +void Renderer2D::DrawChar(Char& letter, Ref font, Vector2 position, Vector2 size) +{ + TextShader->Bind(); + TextShader->SetUniformMat4f("projection", Projection); + + Matrix4 mat = Matrix4(1.0f); + mat = glm::translate(mat, Vector3(position.x, position.y, 0.f)); + mat = glm::scale(mat, Vector3(letter.AtlasBounds.Size.x, letter.AtlasBounds.Size.y, 0.f)); + + //TextShader->SetUniform1f("u_border_radius", 8.1f); + //TextShader->SetUniform2f("u_size", 100.f, 100.f); + + font->FontAtlas->Bind(5); + // + TextShader->SetUniform1i("msdf", 5); + TextShader->SetUniform2f("texPos", letter.AtlasBounds.Pos.x, letter.AtlasBounds.Pos.y); + TextShader->SetUniform2f("texScale", letter.AtlasBounds.Size.x, letter.AtlasBounds.Size.y); + TextShader->SetUniformMat4f("model", mat); + //TextShader->SetUniform4f("bgColor", 0, 0, 1, 1); + TextShader->SetUniform4f("bgColor", 0.f, 0.f, 0.f, 0.f); + TextShader->SetUniform4f("fgColor", 1.f, 1.f, 1.f, 1.f); + //TextShader->SetUniform1f("pxRange", 32); + glBindVertexArray(VAO); + glDrawArrays(GL_TRIANGLES, 0, 6); +} + void Renderer2D::EndDraw() { diff --git a/Nuake/src/Rendering/Renderer2D.h b/Nuake/src/Rendering/Renderer2D.h index c5873bf5..a7bc46b2 100644 --- a/Nuake/src/Rendering/Renderer2D.h +++ b/Nuake/src/Rendering/Renderer2D.h @@ -2,6 +2,8 @@ #include #include #include +#include "src/UI/Font/Font.h" + class Renderer2D { private: @@ -9,10 +11,14 @@ private: static unsigned int VBO; public: static Ref UIShader; + static Ref TextShader; static Matrix4 Projection; static void Init(); static void BeginDraw(Vector2 size); static void DrawRect(); + static Vector2 CalculateStringSize(const std::string& str, Ref font, Vector2 position, float fontSize); + static void DrawString(const std::string& str, Ref font, Vector2 position, float fontSize); + static void DrawChar(Char& letter, Ref font, Vector2 position, Vector2 size); static void EndDraw(); }; \ No newline at end of file diff --git a/Nuake/src/Rendering/Textures/Texture.cpp b/Nuake/src/Rendering/Textures/Texture.cpp index f264e483..abf40efe 100644 --- a/Nuake/src/Rendering/Textures/Texture.cpp +++ b/Nuake/src/Rendering/Textures/Texture.cpp @@ -45,6 +45,24 @@ Texture::Texture(glm::vec2 size, GLenum format) glTexImage2D(GL_TEXTURE_2D, 0, format, size.x, size.y, 0, format, GL_UNSIGNED_BYTE, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + +} + + +Texture::Texture(glm::vec2 size, msdfgen::BitmapConstRef& bitmap, bool t) +{ + m_Width = size.x; + m_Height = size.y; + + glGenTextures(1, &m_RendererId); + glBindTexture(GL_TEXTURE_2D, m_RendererId); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + + auto pixel = bitmap(0, bitmap.height - 0 - 1); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)bitmap.pixels); } void Texture::Resize(glm::vec2 size) diff --git a/Nuake/src/Rendering/Textures/Texture.h b/Nuake/src/Rendering/Textures/Texture.h index 6101fbf7..679eda17 100644 --- a/Nuake/src/Rendering/Textures/Texture.h +++ b/Nuake/src/Rendering/Textures/Texture.h @@ -2,6 +2,8 @@ #include "stb_image/stb_image.h" #include #include "glm/vec2.hpp" +#include "msdfgen/core/BitmapRef.hpp" + typedef unsigned int GLenum; class Texture @@ -18,7 +20,9 @@ private: public: Texture(const std::string& path); + Texture(glm::vec2 size, msdfgen::BitmapConstRef& bitmap, bool t); Texture(glm::vec2 size, GLenum format); + ~Texture(); void Resize(glm::vec2 size); diff --git a/Nuake/src/Scene/Scene.h b/Nuake/src/Scene/Scene.h index 3f51cd01..83f0bb42 100644 --- a/Nuake/src/Scene/Scene.h +++ b/Nuake/src/Scene/Scene.h @@ -20,12 +20,13 @@ private: std::string Name; bool has_changed = true; - std::vector> m_Interfaces; + entt::registry m_Registry; Ref m_Environement; Ref m_EditorCamera; public: + std::vector> m_Interfaces; std::string Path = ""; static Ref New(); diff --git a/Nuake/src/UI/Font/AtlasGenerator.h b/Nuake/src/UI/Font/AtlasGenerator.h new file mode 100644 index 00000000..a2fa38f1 --- /dev/null +++ b/Nuake/src/UI/Font/AtlasGenerator.h @@ -0,0 +1,31 @@ +#pragma once +#include "msdf-atlas-gen/AtlasGenerator.h" +#include +#include + + + +class FontGenerator +{ + template GEN_FN> + static bool makeAtlas(const std::vector& glyphs, const std::vector& fonts, const msdf_atlas::GeneratorAttributes& attr) { + ImmediateAtlasGenerator > generator(config.width, config.height); + generator.setAttributes(attr); + generator.setThreadCount(1); + generator.generate(glyphs.data(), glyphs.size()); + msdfgen::BitmapConstRef bitmap = (msdfgen::BitmapConstRef) generator.atlasStorage(); + + bool success = true; + + //if (config.imageFilename) { + // if (saveImage(bitmap, config.imageFormat, config.imageFilename, config.yDirection)) + // puts("Atlas image file saved."); + // else { + // success = false; + // puts("Failed to save the atlas as an image file."); + // } + //} + + return success; + } +}; \ No newline at end of file diff --git a/Nuake/src/UI/Font/Font.h b/Nuake/src/UI/Font/Font.h new file mode 100644 index 00000000..fd5af8a0 --- /dev/null +++ b/Nuake/src/UI/Font/Font.h @@ -0,0 +1,103 @@ +#pragma once +#include +#include +#include +struct CharPos +{ + double left; + double right; + double top; + double bottom; +}; + +struct CharUV +{ + Vector2 Pos; + Vector2 Size; +}; + +class Char +{ +private: + unsigned int m_VBO; + unsigned int m_VAO; + +public: + unsigned int Unicode; + float Advance; + CharPos PlaneBounds; + CharUV AtlasBounds; + + Char() {}; + Char(const unsigned int unicode, float advance, CharPos plane, CharUV atlas) + { + Unicode = unicode; + Advance = advance; + PlaneBounds = plane; + AtlasBounds = atlas; + } + + CharUV GetAtlasUV(const Vector2& atlasSize) + { + return AtlasBounds; + } +}; + +class Font +{ +private: + msdfgen::FreetypeHandle* ft; + msdfgen::FontHandle* font; + const char* fontFilename; + + std::map Chars; + +public: + Ref FontAtlas; + + Font() : ft(msdfgen::initializeFreetype()), font(nullptr), fontFilename(nullptr) + { + this->Chars = std::map(); + } + + ~Font() { + if (ft) { + if (font) + msdfgen::destroyFont(font); + msdfgen::deinitializeFreetype(ft); + } + } + + bool load(const char* fontFilename) { + if (ft && fontFilename) { + if (this->fontFilename && !strcmp(this->fontFilename, fontFilename)) + return true; + if (font) + msdfgen::destroyFont(font); + if ((font = msdfgen::loadFont(ft, fontFilename))) { + this->fontFilename = fontFilename; + return true; + } + this->fontFilename = nullptr; + } + return false; + } + operator msdfgen::FontHandle* () const { + return font; + } + + msdfgen::FontHandle* GetFontHandle() { return font; } + msdfgen::FreetypeHandle* GetFreetypeHandle() { return ft; } + + void AddChar(const unsigned int unicode, float advance, CharPos plane, CharUV atlas) + { + this->Chars[unicode] = Char(unicode, advance, plane, atlas); + } + + Char GetChar(unsigned int unicode) + { + if (Chars.find(unicode) != Chars.end()) + return Chars[unicode]; + return Char(); + } +}; \ No newline at end of file diff --git a/Nuake/src/UI/Font/FontLoader.h b/Nuake/src/UI/Font/FontLoader.h new file mode 100644 index 00000000..ae751952 --- /dev/null +++ b/Nuake/src/UI/Font/FontLoader.h @@ -0,0 +1,174 @@ +#pragma once +#include +#include +#include "../Core/Core.h" +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "src/Vendors/msdf-atlas-gen/AtlasStorage.h" +#include "src/Vendors/msdf-atlas-gen/glyph-generators.h" +#include +#include + +#include "../Rendering/Textures/Texture.h" +#include "msdf-atlas-gen/json-export.h" +typedef unsigned char byte; +struct Config +{ + msdf_atlas::ImageType imageType; + msdf_atlas::ImageFormat imageFormat; + msdf_atlas::YDirection yDirection; + int width, height; + double emSize; + double pxRange; + double angleThreshold; + double miterLimit; + void (*edgeColoring)(msdfgen::Shape&, double, unsigned long long); + bool expensiveColoring; + unsigned long long coloringSeed; + msdf_atlas::GeneratorAttributes generatorAttributes; + bool preprocessGeometry; + bool kerning; + int threadCount = 1; +}; + +class FontLoader +{ +public: + + template GEN_FN> + static bool makeAtlas(const std::vector& glyphs, + const std::vector& fonts, + Config& config, Ref font) { + // Create generator + msdf_atlas::ImmediateAtlasGenerator > generator(config.width, config.height); + + // Setup generator settings + generator.setAttributes(config.generatorAttributes); + generator.setThreadCount(config.threadCount); + generator.generate(glyphs.data(), glyphs.size()); + + // Create bitmap + msdfgen::BitmapConstRef bitmap = (msdfgen::BitmapConstRef) generator.atlasStorage(); + + // Create Texture from bitmap + //msdf_atlas::exportJSON(fonts.data(), fonts.size(), config.emSize, config.pxRange, config.width, config.height, config.imageType, config.yDirection, "yayayayya.json", config.kerning); + font->FontAtlas = CreateRef(Vector2(config.width, config.height), bitmap, true); + + // Create Char structure + return true; + } + static Ref LoadFont(const std::string path) + { + // create font + Ref font = CreateRef(); + + // Create atlas settings + Config config{}; + config.pxRange = 2; + config.emSize = 0.0; + config.coloringSeed = 125155; + config.imageType = msdf_atlas::ImageType::MTSDF; + config.imageFormat = msdf_atlas::ImageFormat::UNSPECIFIED; + config.yDirection = msdf_atlas::YDirection::BOTTOM_UP; + config.edgeColoring = msdfgen::edgeColoringInkTrap; + config.kerning = true; + config.preprocessGeometry = false; + config.angleThreshold = 3.0; + config.miterLimit = 1.0; + config.generatorAttributes.scanlinePass = true; + config.generatorAttributes.config.overlapSupport = true; + + // Load file + if (!font->load(path.c_str())) + Logger::Log("Failed to laod font"); + + // Load charset ASCII + std::vector glyphs; + std::vector fonts; + msdf_atlas::FontGeometry fontGeometry(&glyphs); + msdf_atlas::Charset charset = msdf_atlas::Charset::ASCII; + + // Load Create charset + float fontScale = 32; + bool preprocess = false; + int loaded = fontGeometry.loadCharset(font->GetFontHandle(), fontScale, charset, config.preprocessGeometry, config.kerning); + + + fonts.push_back(fontGeometry); + + if (glyphs.empty()) + Logger::Log("No glyphs loaded."); + + // Create atlas params + msdf_atlas::TightAtlasPacker::DimensionsConstraint atlasSizeConstraint = msdf_atlas::TightAtlasPacker::DimensionsConstraint::MULTIPLE_OF_FOUR_SQUARE; + msdf_atlas::TightAtlasPacker atlasPacker; + atlasPacker.setDimensionsConstraint(atlasSizeConstraint); + msdf_atlas::ImageType imageType = msdf_atlas::ImageType::MTSDF; + atlasPacker.setPadding(imageType == msdf_atlas::ImageType::MSDF || imageType == msdf_atlas::ImageType::MTSDF ? 0 : -1); + atlasPacker.setPixelRange(config.pxRange); + atlasPacker.setUnitRange(config.emSize); + atlasPacker.setMiterLimit(config.miterLimit); + + // Pack atlas + if (int remaining = atlasPacker.pack(glyphs.data(), glyphs.size())) { + if (remaining < 0) { + Logger::Log("Failed to pack atlas."); + } + else { + printf("Error: Could not fit %d out of %d glyphs into the atlas.\n", remaining, (int)glyphs.size()); + + } + } + + // update atlast size + atlasPacker.getDimensions(config.width, config.height); + if (!(config.width > 0 && config.height > 0)) + printf("Unable to determine atlas size."); + + config.emSize = atlasPacker.getScale(); + config.pxRange = atlasPacker.getPixelRange(); + + // Color the glyph + //unsigned long long glyphSeed = config.coloringSeed; + //for (msdf_atlas::GlyphGeometry& glyph : glyphs) { + // glyphSeed *= 6364136223846793005ull; + // glyph.edgeColoring(config.edgeColoring, config.angleThreshold, glyphSeed); + //} + + msdf_atlas::Workload([&glyphs, &config](int i, int threadNo) -> bool { + unsigned long long glyphSeed = (6364136223846793005ull * (config.coloringSeed ^ i) + 1442695040888963407ull) * !!config.coloringSeed; + glyphs[i].edgeColoring(config.edgeColoring, config.angleThreshold, glyphSeed); + return true; + }, glyphs.size()).finish(config.threadCount); + + // Create bitmap and char structure + auto bitmap = makeAtlas(glyphs, fonts, config, font); + + for (auto& g : glyphs) + { + CharPos plane = {}; + g.getQuadPlaneBounds(plane.left, plane.bottom, plane.right, plane.top); + + CharUV box = {}; + + + double x2, y2, z2, w2; + g.getQuadAtlasBounds(x2, y2, z2, w2); + box.Pos.x = x2; + box.Pos.y = y2; + box.Size.x = z2; + box.Size.y = w2; + font->AddChar(g.getCodepoint(), g.getAdvance(), plane, box); + } + + return font; + } +}; \ No newline at end of file diff --git a/Nuake/src/UI/Node.h b/Nuake/src/UI/Node.h index 04de96db..32054f7d 100644 --- a/Nuake/src/UI/Node.h +++ b/Nuake/src/UI/Node.h @@ -354,8 +354,9 @@ public: YGNodeStyleSetPositionType(YogaNode, YGPositionTypeAbsolute); } - void Draw(float z, Vector2 offset) + void Draw(float z) { + Renderer2D::UIShader->Bind(); Color color = this->BackgroundColor; Renderer2D::UIShader->SetUniform4f("background_color", color.r / 255.f, @@ -401,6 +402,7 @@ public: Renderer2D::UIShader->SetUniformMat4f("model", transform); Renderer2D::UIShader->SetUniform1f("u_border_radius", 8.f); Renderer2D::UIShader->SetUniform2f("u_size", width, height); + Renderer2D::DrawRect(); } }; \ No newline at end of file diff --git a/Nuake/src/UI/Text.h b/Nuake/src/UI/Text.h new file mode 100644 index 00000000..6e432145 --- /dev/null +++ b/Nuake/src/UI/Text.h @@ -0,0 +1,17 @@ +#pragma once +#include "Node.h" + + +class Text : public Node +{ + + +public: + std::string content = "Hello World!"; + + + void Draw() + { + + } +}; \ No newline at end of file diff --git a/Nuake/src/UI/UserInterface.cpp b/Nuake/src/UI/UserInterface.cpp index f22fd72f..f6229755 100644 --- a/Nuake/src/UI/UserInterface.cpp +++ b/Nuake/src/UI/UserInterface.cpp @@ -4,12 +4,15 @@ #include "Stylesheet.h" #include "yoga/YGConfig.h" #include "InterfaceParser.h" +#include namespace UI { UserInterface::UserInterface(const std::string& name) { m_Name = name; + font = FontLoader::LoadFont("resources/Fonts/OpenSans-Regular.ttf"); + m_Stylesheet = StyleSheet::New("/Interface\\Testing.css"); Root = InterfaceParser::Parse("resources/Interface/Testing.interface"); @@ -99,28 +102,32 @@ namespace UI float leftOffset = YGNodeLayoutGetLeft(Root->YogaNode); float topOffset = YGNodeLayoutGetTop(Root->YogaNode); - - DrawRecursive(Root, 0, Vector2(leftOffset, topOffset)); + + + Vector2 charPos = Vector2(100.f, 100.f); + Char charr = font->GetChar(89); + + + + DrawRecursive(Root, 0); + + Renderer2D::DrawString("Hello SDF World!", font, charPos, 2.0f); + //Renderer2D::DrawChar(charr, font, charPos, size); } - void UserInterface::DrawRecursive(Ref node, float z, Vector2 offset) + void UserInterface::DrawRecursive(Ref node, float z) { if (!node) return; - node->Draw(z, offset); + node->Draw(z); if (node->Childrens.size() <= 0) return; - offset.x += YGNodeLayoutGetLeft(Root->YogaNode); - - if(!YGNodeLayoutGetHadOverflow(Root->YogaNode)) - offset.y += YGNodeLayoutGetTop(Root->YogaNode); - for (auto& c : node->Childrens) { - DrawRecursive(c, z + 1, offset); + DrawRecursive(c, z + 1); } } diff --git a/Nuake/src/UI/UserInterface.h b/Nuake/src/UI/UserInterface.h index c59a80bb..2af4de76 100644 --- a/Nuake/src/UI/UserInterface.h +++ b/Nuake/src/UI/UserInterface.h @@ -7,6 +7,7 @@ #include #include "../Core/Maths.h" #include "Stylesheet.h" +#include "Font/Font.h" namespace UI { class UserInterface @@ -19,6 +20,7 @@ namespace UI YGConfigRef yoga_config; YGNodeRef yoga_root; public: + Ref font; const int Width = 1920; const int Height = 1080; @@ -33,7 +35,7 @@ namespace UI void CreateYogaLayout(); void CreateYogaLayoutRecursive(Ref node, YGNodeRef yoga_node); void Draw(Vector2 size); - void DrawRecursive(Ref node, float z, Vector2 offset); + void DrawRecursive(Ref node, float z); void Update(Timestep ts); }; } \ No newline at end of file diff --git a/Nuake/src/Vendors/msdfgen/ext/import-svg.cpp b/Nuake/src/Vendors/msdfgen/ext/import-svg.cpp index 8d5a6c8a..49fd2020 100644 --- a/Nuake/src/Vendors/msdfgen/ext/import-svg.cpp +++ b/Nuake/src/Vendors/msdfgen/ext/import-svg.cpp @@ -6,7 +6,7 @@ #include #include "../core/arithmetics.hpp" -#include +#include #define ARC_SEGMENTS_PER_PI 2 #define ENDPOINT_SNAP_RANGE_PROPORTION (1/16384.) diff --git a/Nuake/src/Vendors/msdfgen/lib/lodepng.cpp b/Nuake/src/Vendors/msdfgen/lib/lodepng.cpp index eaeb8d38..399e1529 100644 --- a/Nuake/src/Vendors/msdfgen/lib/lodepng.cpp +++ b/Nuake/src/Vendors/msdfgen/lib/lodepng.cpp @@ -41,6 +41,7 @@ Rename this file to lodepng.cpp to use it for C++, or to lodepng.c to use it for const char* LODEPNG_VERSION_STRING = "20190210"; + /* This source file is built up in the following large parts. The code sections with the "LODEPNG_COMPILE_" #defines divide this up further in an intermixed way. @@ -59,6 +60,7 @@ define them in your own project's source files without needing to change lodepng source code. Don't forget to remove "static" if you copypaste them from here.*/ + #ifdef LODEPNG_COMPILE_ALLOCATORS static void* lodepng_malloc(size_t size) { #ifdef LODEPNG_MAX_ALLOC @@ -5929,6 +5931,7 @@ unsigned decode(std::vector& out, unsigned& w, unsigned& h, const #endif /* LODEPNG_COMPILE_DECODER */ #endif /* LODEPNG_COMPILE_DISK */ + #ifdef LODEPNG_COMPILE_ENCODER unsigned encode(std::vector& out, const unsigned char* in, unsigned w, unsigned h, LodePNGColorType colortype, unsigned bitdepth) { diff --git a/Nuake/src/Vendors/msdfgen/lib/tinyxml2.cpp b/Nuake/src/Vendors/msdfgen/lib/tinyxml2.cpp index 8b782832..ca974206 100644 --- a/Nuake/src/Vendors/msdfgen/lib/tinyxml2.cpp +++ b/Nuake/src/Vendors/msdfgen/lib/tinyxml2.cpp @@ -21,7 +21,7 @@ must not be misrepresented as being the original software. distribution. */ -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" #include // yes, this one new style header, is in the Android SDK. #if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) # include @@ -2030,7 +2030,7 @@ XMLDocument::~XMLDocument() } -void XMLDocument::MarkInUse(const XMLNode* node) +void XMLDocument::MarkInUse(XMLNode* node) { TIXMLASSERT(node); TIXMLASSERT(node->_parent == 0);