[abandoned] access VBOs created in a different function

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

[abandoned] access VBOs created in a different function

Post by Cube_ »

EDIT: Anything below this is utterly irrelevant as I decided to abandon this idea and instead went with the route of refactoring my codebase to eliminate this issue altogether (at the cost of a higher runtime memory footprint, now I need to figure out somewhere else to shave off memory).

In other words, if a mod or admin stumbles upon this please do close or delete this as it's no longer relevant.

Okay, so I have a dynamic mesh generating class in a separate file (as it, and the classes it depend on are pretty damn large) and due to working with very large vertex counts I'd like to use VBOs to speed things up.
However I am not quite sure how I would do this.

Code: Select all

    scene::SMesh *mesh = new scene::SMesh();
    for (u32 i=0; i<6; ++i)
    {
        scene::IMeshBuffer *buf = new scene::SMeshBuffer();
        buf->append(vertices + 4 * i, 4, indices, 6);
 
        buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
        buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
        buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
 
        mesh->addMeshBuffer(buf);
        buf->drop();
    }
 
    scene::SAnimatedMesh *aMesh = new scene::SAnimatedMesh(mesh);
    mesh->drop();
    scaleMesh(aMesh, scale); 
    aMesh->getMeshBuffer(0)->setHardwareMappingHint(scene::EHM_DYNAMIC);
    aMesh->setDirty();
That's how I actually work with the mesh, turning it into an object of type SAnimatedMesh, however I'm getting the feeling that creating the VBOs from a separate file is the wrong way to do things as I cannot figure out how to access it from the main thread (the function is of type void, memory is extremely important for my application as I deal with enormous datasets).

Perhaps a better solution is to make the function of type SAnimatedMesh and then return aMesh, then clearing it and then allocating the VBOs in the main thread?
I'm not sure if that'd be bad practice, in fact that sounds just as bad to me.
Last edited by Cube_ on Tue Mar 03, 2015 2:37 pm, edited 1 time in total.
"this is not the bottleneck you are looking for"
Post Reply