Scale a VBO with glMapBuffer glUnmapBuffer problem

hi guys,

i have made a VBO with that structure in c with that class :
//struct for the buffer of my VBO

typedef struct _buffer_object
{
l3d_glfloat location[3];
l3d_glfloat tex[2];
l3d_glfloat normal[3];
l3d_glfloat color[4];
GLubyte imaterial;
GLubyte padding[15]; //riempie la struttura di 64bit per incrementare le performance
}l3d_VBO_element,*pl3d_VBO_element;

class l3d_vertexbufferobject
{
private:

public:
    l3d_vertexbufferobject();

    l3d_uint _id;
    l3d_uint _idindex;
    l3d_uint _vbosize;
    l3d_uint _linesize;
    pl3d_VBO_element _buffer;
    l3d_uint  *_index;
    l3d_bufferobject * _elementvbo;
    l3d_bufferobject * _elementvert;
    l3d_bufferobject * _elementedge;
    l3d_bufferobject * _elementface;
    l3d_bufferobject * _elementquad;

    void clean();

};

}
where l3d_bufferobject manage a buffer object.

I make my VBO with that function:

l3d_vertexbufferobject *vbo=new l3d_vertexbufferobject;

vbo->_elementvbo=NULL;
vbo->_elementedge=NULL;
vbo->_elementface=NULL;
vbo->_elementquad=NULL;
vbo->_elementvert=NULL;


vbo->_elementvbo= new l3d_bufferobject;
vbo->_elementvbo->setlenght(sizeof(l3d_VBO_element));
vbo->_elementvbo->setsize(size);

vbo->_elementvert= new l3d_bufferobject;
vbo->_elementvert->setlenght(sizeof(l3d_uint));
vbo->_elementvert->setsize(size);


vbo->_vbosize=size;

if(size_index>0)
{
    vbo->_elementedge= new l3d_bufferobject;
    vbo->_elementedge->setlenght(sizeof(l3d_uint));
    vbo->_elementedge->setsize  (size_index  *  2);

}



if(size_index_face>0)
{
    vbo->_elementface=new l3d_bufferobject;
    vbo->_elementface->setlenght(sizeof(l3d_uint));
    vbo->_elementface->setsize (size_index_face  *  3);

}








pl3d_VBO_element first=(pl3d_VBO_element)vbo->_elementvbo->getbuffer();

l3d_uint * pvert=(l3d_uint *)vbo->_elementvert->getbuffer();

l3d_uint * pedge;
l3d_uint * pface;

if(vbo->_elementedge!=NULL)
    pedge=(l3d_uint *)vbo->_elementedge->getbuffer();

if(vbo->_elementface!=NULL)
    pface=(l3d_uint *)vbo->_elementface->getbuffer();

for(int ix=0; ix < size;ix++)
{
    pl3d_vertex_fast v=mesh->_vertex.find(ix);

    *pvert++=ix;

    first->location[0]=v->x;
    first->location[1]=v->y;
    first->location[2]=v->z;

    first->tex[0]=v->u;
    first->tex[1]=v->v;

    first->normal[0]=v->normals[0];
    first->normal[1]=v->normals[1];
    first->normal[2]=v->normals[2];

    first->color[0]=0.5F;
    first->color[1]=0.5F;
    first->color[2]=0.5F;
    first->color[3]=1.0F;

    first->imaterial=0;

    *first++;
}

for(int ix=0; ix < size_index;ix++)
{
    pl3d_line_struct  l=mesh->_edges.find(ix);

    *pedge++=l->v0;
    *pedge++=l->v1;
}
for(int ix=0; ix < size_index_face;ix++)
{
    pl3d_face3_struct f=mesh->_faces.find(ix);
    if(mesh->_display->invert)

    {

        *pface++=f->v0;
        *pface++=f->v1;
        *pface++=f->v2;

    }

    else
    {
        *pface++=f->v0;
        *pface++=f->v2;
        *pface++=f->v1;

    }




}

vbo->_elementvbo->create_sub(buffer_array,usage_static_draw);

vbo->_elementvert->create(buffer_element_array,usage_static_draw);

if(vbo->_elementedge!=NULL)
    vbo->_elementedge->create(buffer_element_array,usage_static_draw);

if(vbo->_elementface!=NULL)
    vbo->_elementface->create(buffer_element_array,usage_static_draw);

 mesh->_vbo=vbo;

where mesh rapresent my object.

and i want scale it with that function, but don’t go.

       void scale_vbo()
        {
            l3d_vertexbufferobject *vbo=_vbo;

            if(!vbo)
                return;

            pl3d_VBO_element vele=(pl3d_VBO_element)vbo->_elementvert->getbufferobject(access_write_only);


            pl3d_vertex_fast appv=_vertex.first();

            while(appv)
            {
                vele->location[0]*=_scale.x;
                vele->location[1]*=_scale.y;
                vele->location[2]*=_scale.z;

                *vele++;
                appv=appv->next;
            }
            vbo->_elementvert->unmapbuffer();


        }

is there anyone who can help me?

tnx :slight_smile:

You haven’t actually said what your problem is.

Something to do with glMapBuffer, but I do a search on the web page and you don’t even have a glMapBuffer call in the code you posted.

Speaking of which, if you’re going to post code, could you please, please, please use code tags - it makes things easier for anyone reading your post, which might make it more likely for you to get a helpful response. Maybe some people might want to help, but a code dump with not much more than “plz hlp thx” is off-putting, you know.