Template class compile error

I have a template class called

ElementContainer
1
2
3
4
5
6
7
8
9
10
11
12
template <typename T>
class ElementContainer {
private:
    std::vector<T> m_elements;
public:
    
    //...

    std::vector<T>& get(){
        return m_elements;
    }
};


VBO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
template <typename T>
class VBO {
private:
    bool m_vboExists = false;
    unsigned int m_vbo = 0;
public:


    void upload(std::vector<T>& data, int storagePattern = GL_STATIC_DRAW){
        if(m_vboExists){
            deleteVBO();
        }
        m_vboExists = true;
        glGenBuffers(1, &m_vbo);
        glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
        glBufferData(GL_ARRAY_BUFFER, data.size() * sizeof(T), data.at(0), storagePattern);
    }

    //...
};


and Mesh
1
2
3
4
5
6
7
8
9
10
11
12
13
template <typename T>
class Mesh {
private:
    ElementContainer<T> m_vertices;

public:

    //...

    ElementContainer<T>& get(){
        return m_vertices;
    }
};


Now when I actually use them, I get compile errors all over the place!

1
2
3
4
5
6
7
//Definition
Mesh<Voxel> mesh;
VBO<Voxel> vbo;

//Call
std::vector<Voxel>& test = mesh.get().get();
vbo.upload(test); //<< There occures the error. If I comment out that line, it vanishes 


That is the link to the actual compiler message (Cut out):
https://hastebin.com/hokagacuti.tex

I tried different template arguments, with no result.

What am I missing?

Thanks in advance!


glBufferData(GL_ARRAY_BUFFER, data.size() * sizeof(T), data.data(), storagePattern);
The third argument is a void*, not a Voxel.
Last edited on
glBufferData(GL_ARRAY_BUFFER, data.size() * sizeof(T), data.data(), storagePattern);
The third argument is a void*, not a Voxel.


Well, yea, that did it. Thanks!
Topic archived. No new replies allowed.