by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 17:00
    mosra synchronize #459
  • 17:00

    mosra on materialdata

    Trade: return Optional instead … Trade: check for custom Materia… sceneconverter: print material … and 12 more (compare)

  • 16:41
    Travis mosra/corrade@8d5aad8 (fuckoff-msvc) passed (1842)
  • 16:24
    mosra synchronize #459
  • 16:24

    mosra on materialdata

    UGH, but different (compare)

  • 16:09
    mosra synchronize #459
  • 16:09

    mosra on materialdata

    UGH (compare)

  • 16:08

    mosra on fuckoff-msvc

    UGH FFS MSVC (compare)

  • 15:40
    mosra synchronize #459
  • 15:40

    mosra on materialdata

    Math: remove pointless Emscript… Trade: remove deprecated mutabl… Trade: rename MaterialData::*Co… and 22 more (compare)

  • 15:32
    mosra edited #459
  • 15:30
    mosra edited #459
  • 15:30
    mosra edited #459
  • 09:23
    mosra edited #459
  • 08:49
    mosra edited #459
  • 08:46
    mosra edited #459
  • 08:46
    mosra edited #459
  • 02:33
    vegetablechickenluo starred mosra/magnum
  • 00:24
    Travis mosra/magnum-plugins (master) fixed (1351)
  • Aug 10 19:28
    mosra synchronize #459
mgood7123
@mgood7123

how would i go about internally caching my return values? such as

GLIS_FONT::ATLAS_TYPE *GLIS_FONT::get_atlas(const char *id) {
    auto o = find_font(id);
    if (o == nullptr) return nullptr;
    return o->resource.get<ATLAS_TYPE *>();
}

for example

    quad_cache = font.add_font("id", f);
    a12_cache = font.add_font_size("id", 12);
    // ... draw() {
    // initialize cache
    if (quad_cache == nullptr) quad_cache = font.get_atlas("id");
    if (fontInit_cache == nullptr) fontInit_cache = quad_cache->third.get<GLIS_FONT::font_init*>();
    if (fontData_cache == nullptr) fontData_cache = quad_cache->fourth.get<GLIS_FONT::font_data*>();
    if (a12_cache == nullptr) a12_cache = font.find_size("id", fontData_cache, 12);
    // cache initialized
    // ... }

so that, the cache's can be internal instead of external (user managed)

mgood7123
@mgood7123
https://github.com/mgood7123/GLIS/tree/master/examples/X11_font_2.cpp can even load multiple fonts at different sizes :)
image.png
@mosra do you think this could replace the current STB True-Type font engine? (or be provided as a plugin as an alternative to the STB True-Type font engine)
mgood7123
@mgood7123
(probably as a plugin since i think my API is very different than STBTryeType's API)
Vladimír Vondruš
@mosra
this is based on freetype, right?
i have plans to overhaul the whole Text library at some point (see mosra/magnum#143) .. well, probably throwing everything away and starting over will be easier :D
Guillaume Jacquemin
@williamjcm
Well, throwing everything away and starting over can be considered an overhaul.
That's what I'm doing with a project of mine. I had one Hell of a God object, but I'm now fixing that.
mgood7123
@mgood7123
yes this is based on FreeType
mgood7123
@mgood7123
@mosra
mgood7123
@mgood7123
hmmm im not sure how to implement shader coloring, as textures can have their own color, however magnum allows for shader coloring via
shader->setColor(color);
mgood7123
@mgood7123
for example, what would happen if you load a wooden box texture, and set the shader color? would the shader color override the wooden box texture's color? if so how would the color be reset as so the wooden box texture's color overrides the shader color
pezcode
@pezcode
usually the colors are multiplied
Vladimír Vondruš
@mosra
in all cases where there is both a texture and a color, those two get multiplied together
mgood7123
@mgood7123
hm ok
would the default values be, for example, 1.0f?
for example, if the shader's colors are white then the textures colors take priority, and if the texture's colors are white then the shaders colors take priority?
mgood7123
@mgood7123

i gtg bed, imma assume this to be the case

if the shader's colors are white then the textures colors take priority.
if the texture's colors are white then the shaders colors take priority

but ill check tomorrow :)

Guillaume Jacquemin
@williamjcm
If the colour in the shader is set to white, then nothing would happen, as fragment_colour * 1 equals fragment_colour.
(I'm not 100% awake, it seems. Good thing Gitter has an edit feature.)
mgood7123
@mgood7123
@williamjcm yea

for example

if shader is 0.75 red, and texture is 1.0 red, then the result would be 0.75 red (shader)

if texture is 0.75 red, and shader is 1.0 red, then the result would be 0.75 red (texture)

Guillaume Jacquemin
@williamjcm
For the red component, yes.
mgood7123
@mgood7123
and this applies to all components
so, by that, the shader and texture color components can be mixed, eg red and blue from texture, green from shader
Vladimír Vondruš
@mosra
that's precisely how it works, yep
and if you don't set the color, the default is 1 for all channels
mgood7123
@mgood7123
nice :)
magnum represents mesh coordinates in -1 to 1, right?
pezcode
@pezcode
you talking about the mesh primitives?
mgood7123
@mgood7123
yes
for example, Primitives::cubeSolid()
pezcode
@pezcode
yeah, most of them
2x2x2 cube, centered at origin.
mgood7123
@mgood7123
hm ok
Guillaume Jacquemin
@williamjcm
2x2x2 means it spans from -1 to 1 on all axes, yeah.
mgood7123
@mgood7123
ok
a transformation matrix would be needed to reposition the coordinates right?
for example, to shift the cube such that its top left corner is now at center (0.0f, 0.0f)
mgood7123
@mgood7123

also, can this be reduced to, for example, only specifying

x1, y1
x2, y2

?

    float vertices[] = {
            // positions           // colors                  // texture coords
             1.0f,  1.0f, 0.0f,    1.0f, 0.0f, 0.0f, 0.25f,   1.0f, 1.0f, // top right
             1.0f, -1.0f, 0.0f,    0.0f, 1.0f, 0.0f, 0.25f,   1.0f, 0.0f, // bottom right
            -1.0f, -1.0f, 0.0f,    0.0f, 0.0f, 1.0f, 0.25f,   0.0f, 0.0f, // bottom left
            -1.0f,  1.0f, 0.0f,    1.0f, 1.0f, 0.0f, 0.25f,   0.0f, 1.0f  // top left
    };
    unsigned int indices[] = {
            0, 1, 3, // first triangle
            1, 2, 3  // second triangle
    };
pezcode
@pezcode
what are x1 etc.?
mgood7123
@mgood7123
coordinates
pezcode
@pezcode
...
of what?
mgood7123
@mgood7123
floats
for example (these may be around the wrong way)
x1 =  1.0f, y1 =  1.0f // top left
x2 = -1.0f, y2 = -1.0f // bottom right
or rather, a rectangular shape drawn from x1, y1 to x2, y2
mgood7123
@mgood7123
like Trade::MeshData Magnum::Primitives::squareSolid(SquareFlags flags = {}) https://doc.magnum.graphics/magnum/namespaceMagnum_1_1Primitives.html#a13805b51e4c822e632722a3c7232317e
mgood7123
@mgood7123
void rectAlpha() {
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    // see Trade::MeshData Magnum::Primitives::squareSolid(SquareFlags flags = {})
    // https://doc.magnum.graphics/magnum/namespaceMagnum_1_1Primitives.html#a13805b51e4c822e632722a3c7232317e

    // set up vertex data (and buffer(s)) and configure vertex attributes
    // ------------------------------------------------------------------
    float vertices[] = {
            // positions           // colors                  // texture coords
             1.0f,  1.0f, 0.0f,    1.0f, 0.0f, 0.0f, 0.25f,   1.0f, 1.0f, // top right
             1.0f, -1.0f, 0.0f,    0.0f, 1.0f, 0.0f, 0.25f,   1.0f, 0.0f, // bottom right
            -1.0f, -1.0f, 0.0f,    0.0f, 0.0f, 1.0f, 0.25f,   0.0f, 0.0f, // bottom left
            -1.0f,  1.0f, 0.0f,    1.0f, 1.0f, 0.0f, 0.25f,   0.0f, 1.0f  // top left
    };
    unsigned int indices[] = {
            0, 1, 3, // first triangle
            1, 2, 3  // second triangle
    };
    unsigned int VBO, VAO, EBO;
    glGenVertexArrays(1, &VAO);
    glGenBuffers(1, &VBO);
    glGenBuffers(1, &EBO);

    glBindVertexArray(VAO);

    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);

    // position attribute
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 9 * sizeof(float), (void*)0);
    glEnableVertexAttribArray(0);
    // color attribute
    glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 9 * sizeof(float), (void*)(3 * sizeof(float)));
    glEnableVertexAttribArray(1);
    // texture coord attribute
    glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 9 * sizeof(float), (void*)(7 * sizeof(float)));
    glEnableVertexAttribArray(2);
    glBindVertexArray(VAO);
    glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
    glBindVertexArray(0);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
    glDeleteVertexArrays(1, &VAO);
    glDeleteBuffers(1, &VBO);
    glDeleteBuffers(1, &EBO);
    glDisable(GL_BLEND);
}
as i want to try to optimize how i draw my rectangle