Home How to pass a templated vector to a C++ function?
Reply: 0

How to pass a templated vector to a C++ function?

user637
1#
user637 Published in May 25, 2018, 8:56 am

I am writting a function that needs to handle any type of vector passed into it, regardless of the inner type of the vector.

The function takes in the vector, finds the size of the elements and then passes the data to the GPU.

It would look something like:

void Object_3D::set_instance_data(Renderer* handler, vector<T> data)
{
    glBindVertexArray(VAO);

    glBindBuffer(GL_SHADER_STORAGE_BUFFER, (VBOs[3]));
    glBufferData(GL_SHADER_STORAGE_BUFFER, data.size()*sizeof(T), 
        data.data(), GL_DYNAMIC_COPY);

}

However I cannot get this code to compile.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.334781 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO