nyymanni / msdfgl Goto Github PK
View Code? Open in Web Editor NEWOpenGL implementation of the MSDF algorithm
License: MIT License
OpenGL implementation of the MSDF algorithm
License: MIT License
Meson is more simple, flexible, and human readable build system. Any plan on moving to Meson?
I was unable to compile until I manually removed spurious "\n" sequences in the generated _msdfgl_shaders.h
Looks like C lines are being treated like shader lines.
Are they? They don't appear to be.
This is great work. Congratulations!
For cubic-to-quadratic conversion I suggest you lift the cu2qu algorithm. I have described it here:
Cheers
Hello. I am interested in using MSDFs on platforms / APIs such as Metal and WebGL that do not support geometry shaders. Would you be able to offer some guidance on how one might transition to just a vertex and fragment shader? It seems that a lot would need to change, though. Alternatively, would you consider exploring how to make a variant of this library for other APIs?
Thank you for your time.
This general code seems to be ok:
// ....
// general GLFW, window and GLAD initialization
// ....
glfwGetFramebufferSize(window, &fb_width, &fb_height);
glViewport(0, 0, fb_width, fb_height);
// ....
msdfgl_context_t ctx = msdfgl_create_context("330 core");
msdfgl_atlas_t atlas = msdfgl_create_atlas(ctx, 1024, 2);
msdfgl_font_t font = msdfgl_load_font(ctx, "Arial.ttf", 4, 2, atlas);
msdfgl_generate_ascii(font);
// glfwGetFramebufferSize(window, &fb_width, &fb_height);
// glViewport(0, 0, fb_width, fb_height);
msdfgl_set_missing_glyph_callback(ctx, msdfgl_generate_glyph, NULL);
_msdfgl_ortho(0.0, fb_width, fb_height, 0.0, -1.0, 1.0, proj);
while (!glfwWindowShouldClose(window)) {
processInput();
glClearColor(0.05f, 0.05f, 0.05f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
msdfgl_printf(0, 64, font, 64, 0xffffffff, (GLfloat *)proj,
static_cast<msdfgl_printf_flags>(MSDFGL_UTF8 | MSDFGL_KERNING), "Hello world!");
glfwSwapBuffers(window);
glfwPollEvents();
}
But I encounter in one very annoying thing here. Any time when msdfgl library is generating glyphs (via _msdfgl_generate_glyphs_internal
which is called either by msdfgl_generate_ascii
or through callback) I SHOULD restore glViewport (commented lines right after msdfgl_generate_ascii(font);
. This is becouse _msdfgl_generate_glyphs_internal
sets the Viewport inside theirs own framebuffer but doesn't restore it when done.
so if I have glViewport(0, 0, fw_width, fb_height)
before any glyps generation and then I am trying to print any text I see the mess I attached. But of course I have this nice callback that fixes everything, but only after resizing:
inline void Engine::onFramebufferResize(GLFWwindow *window, int width, int height) {
auto &e = Engine::Instance();
glfwGetFramebufferSize(window, &e.fb_width, &e.fb_height);
glViewport(0, 0, e.fb_width, e.fb_height);
_msdfgl_ortho(0.0, e.fb_width, e.fb_height, 0.0, -1.0, 1.0, proj);
}
I see this behaviour in demo file too. I running it on Debian 10.
Maybe there could be another one callback that will be called after glyphs generation and restore the viewport? Or I totally wrong somewhere and just should use it in some another way?
Things go harder if I don't want to pregenerate any glyps at all (just like in demo file) and print every time a new text with new symbols. Any time right after msdfgl_printf
my Viewport will be broken! it is totally not expected behaviour!
Hi, @nyyManni ,
nice job with the library.
I was wondering if this library supports multi-line text rendering using the line height of the font?
Thanks.
msdfgl_map_get
uses bsearch
which is a POSIX function and results in a link error on MSVC
msdfgl.lib(msdfgl_map.obj) : error LNK2019: unresolved external symbol __imp_bsearch referenced in function msdfgl_map_get
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.