Giter Club home page Giter Club logo

msdfgl's Introduction

Hello there

msdfgl's People

Contributors

hkva avatar mattparks avatar nyymanni avatar xornet-sl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

msdfgl's Issues

Meson build system

Meson is more simple, flexible, and human readable build system. Any plan on moving to Meson?

Bug in shader generator?

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.

Without point primitives or geometry shaders?

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.

resetting glViewport any time after glyph(s) generation

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?
Снимок экрана от 2020-04-05 03-35-32

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!

MSVC compatiblity?

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.