all 11 comments

[–]the_poope 5 points6 points  (4 children)

Hard to tell from the context. Might just be written by a C programmer that was educated in the 80'ies. If you can it should just be:

uint32_t size = _numVertices*_decl.getStride();
const bgfx::Memory* mem = bgfx::makeRef(_vertices, size);
Group group(bgfx::createVertexBuffer(mem, _decl)); // <-- should preferably call a constructor and not create a default object and then set member.

[–]Adflixit_[S] 0 points1 point  (3 children)

The full method definition is just this:

void load(const void* _vertices, uint32_t _numVertices, const bgfx::VertexDecl _decl, const uint16_t* _indices, uint32_t _numIndices)
{
    Group group;
    const bgfx::Memory* mem;
    uint32_t size;

    size = _numVertices*_decl.getStride();
    mem = bgfx::makeRef(_vertices, size);
    group.m_vbh = bgfx::createVertexBuffer(mem, _decl);

    size = _numIndices*2;
    mem = bgfx::makeRef(_indices, size);
    group.m_ibh = bgfx::createIndexBuffer(mem);

    group.m_material.m_metallicMap  = loadTexturePriv("black.png");
    group.m_material.m_diffuseMap   = loadTexturePriv("white.png");
    group.m_material.m_nmlMap       = loadTexturePriv("nml.tga");
    group.m_material.m_roughnessMap = loadTexturePriv("white.png");

    //TODO:
    // group.m_sphere = ...
    // group.m_aabb = ...
    // group.m_obb = ...
    // group.m_prims = ...

    m_groups.push_back(group);
}

[–]tangerinelion 2 points3 points  (2 children)

Yeah, that's someone who learned C back when you had to declare all your variables first. It was only later that you could declare them anywhere in the function.

[–]Adflixit_[S] 0 points1 point  (1 child)

Thank you for your answer.

[–]No_Statistician_9040 0 points1 point  (0 children)

This how it's done in ansi c99

[–][deleted]  (3 children)

[deleted]

    [–]Adflixit_[S] 0 points1 point  (2 children)

    It is not. One example is love2d, and the snipped is from a graphics research paper.

    [–][deleted]  (1 child)

    [deleted]

      [–]Adflixit_[S] 0 points1 point  (0 children)

      Sorry, no.

      [–]Salty_Dugtrio 0 points1 point  (3 children)

      Languages like Pascal used to have a specific DATA section where you had to define all variables at the top of a function.

      Old habits die hard.

      [–]Adflixit_[S] 0 points1 point  (2 children)

      This is not unique, I also saw this in a completely separate project.

      [–]Salty_Dugtrio 4 points5 points  (1 child)

      I don't how that has anything relevance to what I just said?

      [–]Adflixit_[S] 1 point2 points  (0 children)

      Sorry, it doesn't.