diff --git a/.clangd b/.clangd index 122ab09..32169b9 100644 --- a/.clangd +++ b/.clangd @@ -1,2 +1,3 @@ CompileFlags: - CompilationDatabase: bin \ No newline at end of file + CompilationDatabase: bin + Add: ["--target=x86_64-w64-mingw32"] \ No newline at end of file diff --git a/other/build.nr b/other/build.nr index b742f79..a4ea6e7 100644 --- a/other/build.nr +++ b/other/build.nr @@ -1 +1 @@ -2058 +2059 diff --git a/src/ogfx/render/FontGlyphAtlas.cpp b/src/ogfx/render/FontGlyphAtlas.cpp index f97c324..5c5f076 100644 --- a/src/ogfx/render/FontGlyphAtlas.cpp +++ b/src/ogfx/render/FontGlyphAtlas.cpp @@ -126,6 +126,7 @@ namespace ogfx int lockedPitch = 0; if (SDL_LockTexture(atlas, &dstRect, &lockedPixels, &lockedPitch)) { + SDL_LockSurface(surf); uint8_t* src = (uint8_t*)surf->pixels; uint8_t* dst = (uint8_t*)lockedPixels; for (int y = 0; y < gh; y++) @@ -134,6 +135,7 @@ namespace ogfx src += surf->pitch; dst += lockedPitch; } + SDL_UnlockSurface(surf); SDL_UnlockTexture(atlas); } diff --git a/src/test/GuiTest.cpp b/src/test/GuiTest.cpp index 38f940b..b736ea5 100644 --- a/src/test/GuiTest.cpp +++ b/src/test/GuiTest.cpp @@ -157,55 +157,61 @@ class Window : public ogfx::gui::Window setTheme(m_theme); - int32_t count = 0; - for (char c = 'A'; c <= 'Z'; c++) - { - for (int32_t i = 0; i < 200; i++) - { - count++; - uint32_t _fs = ostd::Random::getui32(8, 200); - m_gfx.setFontSize(_fs); - m_gfx.getFontGlyphAtlas().rasterize_glyph(ostd::String("").addChar(c), m_gfx.getSDLFont(), _fs); - } - } - for (char c = '0'; c <= '9'; c++) - { - for (int32_t i = 0; i < 200; i++) - { - count++; - uint32_t _fs = ostd::Random::getui32(8, 200); - m_gfx.setFontSize(_fs); - m_gfx.getFontGlyphAtlas().rasterize_glyph(ostd::String("").addChar(c), m_gfx.getSDLFont(), _fs); - } - } - for (char c = 'a'; c <= 'z'; c++) - { - count++; - for (int32_t i = 0; i < 200; i++) - { - uint32_t _fs = ostd::Random::getui32(8, 200); - m_gfx.setFontSize(_fs); - m_gfx.getFontGlyphAtlas().rasterize_glyph(ostd::String("").addChar(c), m_gfx.getSDLFont(), _fs); - } - } - for (char c = '0'; c <= '9'; c++) - { - for (int32_t i = 0; i < 200; i++) - { - count++; - uint32_t _fs = ostd::Random::getui32(8, 200); - m_gfx.setFontSize(_fs); - m_gfx.getFontGlyphAtlas().rasterize_glyph(ostd::String("").addChar(c), m_gfx.getSDLFont(), _fs); - } - } + m_gfx.setFontSize(fs); + m_gfx.getFontGlyphAtlas().rasterize_glyph(ostd::String("").addChar('H'), m_gfx.getSDLFont(), fs); + m_gfx.getFontGlyphAtlas().rasterize_glyph(ostd::String("").addChar('e'), m_gfx.getSDLFont(), fs); + m_gfx.getFontGlyphAtlas().rasterize_glyph(ostd::String("").addChar('l'), m_gfx.getSDLFont(), fs); + m_gfx.getFontGlyphAtlas().rasterize_glyph(ostd::String("").addChar('o'), m_gfx.getSDLFont(), fs); - for (int32_t i = 0; i < m_gfx.getFontGlyphAtlas().m_currentAtlasCount; i++) - { - ostd::String file("./atlas"); - file.add(i).add(".png"); - m_gfx.getFontGlyphAtlas().save_atlas_to_png(m_gfx.getSDLRenderer(), m_gfx.getFontGlyphAtlas().m_atlases[i], file); - } - std::cout << "Atlas cound: " << (int)count << "\n"; + // int32_t count = 0; + // for (char c = 'A'; c <= 'Z'; c++) + // { + // for (int32_t i = 0; i < 200; i++) + // { + // count++; + // uint32_t _fs = ostd::Random::getui32(8, 200); + // m_gfx.setFontSize(_fs); + // m_gfx.getFontGlyphAtlas().rasterize_glyph(ostd::String("").addChar(c), m_gfx.getSDLFont(), _fs); + // } + // } + // for (char c = '0'; c <= '9'; c++) + // { + // for (int32_t i = 0; i < 200; i++) + // { + // count++; + // uint32_t _fs = ostd::Random::getui32(8, 200); + // m_gfx.setFontSize(_fs); + // m_gfx.getFontGlyphAtlas().rasterize_glyph(ostd::String("").addChar(c), m_gfx.getSDLFont(), _fs); + // } + // } + // for (char c = 'a'; c <= 'z'; c++) + // { + // count++; + // for (int32_t i = 0; i < 200; i++) + // { + // uint32_t _fs = ostd::Random::getui32(8, 200); + // m_gfx.setFontSize(_fs); + // m_gfx.getFontGlyphAtlas().rasterize_glyph(ostd::String("").addChar(c), m_gfx.getSDLFont(), _fs); + // } + // } + // for (char c = '0'; c <= '9'; c++) + // { + // for (int32_t i = 0; i < 200; i++) + // { + // count++; + // uint32_t _fs = ostd::Random::getui32(8, 200); + // m_gfx.setFontSize(_fs); + // m_gfx.getFontGlyphAtlas().rasterize_glyph(ostd::String("").addChar(c), m_gfx.getSDLFont(), _fs); + // } + // } + + // for (int32_t i = 0; i < m_gfx.getFontGlyphAtlas().m_currentAtlasCount; i++) + // { + // ostd::String file("./atlas"); + // file.add(i).add(".png"); + // m_gfx.getFontGlyphAtlas().save_atlas_to_png(m_gfx.getSDLRenderer(), m_gfx.getFontGlyphAtlas().m_atlases[i], file); + // } + // std::cout << "Atlas cound: " << (int)count << "\n"; } inline void onSignal(ostd::Signal& signal) override @@ -251,7 +257,7 @@ class Window : public ogfx::gui::Window l_renderString("Hello", { 10, 140 }); - gfx.renderText("Hello", 10, 100, ostd::Colors::Crimson, 30); + gfx.renderText("Hello", 10, 100, ostd::Colors::Crimson, fs); }