Can't use std::vector in place of std::array on QOpenGLBuffer::allocate

Viewed 79

I'm working with OpenGl with Qt and I'm allocating a buffer with std::array, I want to replace it with std::vector, it should work almost the same way, but it doesn't work at all, just black screen.

Vertex is just a class with six floats (x,y,z, r,g,b) and few methods

declaration of vertexes

//works
std::array<Vertex, 12> vertexes = {
    VERTEX_0, VERTEX_2, VERTEX_TOP,
    VERTEX_2, VERTEX_1, VERTEX_TOP,
    VERTEX_1, VERTEX_0, VERTEX_TOP,
    VERTEX_0, VERTEX_1, VERTEX_2,
};

//doesn't work
std::vector<Vertex> vertexes = {
    VERTEX_0, VERTEX_2, VERTEX_TOP,
    VERTEX_2, VERTEX_1, VERTEX_TOP,
    VERTEX_1, VERTEX_0, VERTEX_TOP,
    VERTEX_0, VERTEX_1, VERTEX_2,
};

buffer allocation

m_vertex.allocate(vertexes.data(), sizeof(Vertex) * vertexes.size());
0 Answers
Related