I have a vertex
struct that stores the location of a vertex in a 2d plane and can transform its position and also used to generate vertices to make a geometric shape. i need the parameter of one of the function calls to determine how many of this struct i will need i tried using an array but that didn't work since array's only accept const variables and i tried vectors but when i generate the buffers for the vertices i can't use a vector as "There is no conversion from vector to const void" here's the function.
void Sprite::init(Type mode, int verticesNum, float scale) {
//generate buffer if it hasn't been generated
if (_vboID == 0) {
glGenBuffers(1, &_vboID);
}
//make vector of structs using verticesNum as how many vertices are needed
std::vector<Vertex> vertexData(verticesNum);
if (mode == Type::CIRCLE) {
for (int i = verticesNum; i < verticesNum; i++) {
float angle = (M_PI / 180) * i;
vertexData[i].setPosition(cos(angle)*scale, sin(angle)*scale);
}
}
//Tell opengl to bind our vertex buffer object
glBindBuffer(GL_ARRAY_BUFFER, _vboID);
//Upload the data to the GPU
//this line is where i get the error as it can't use vertex data
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), /*right here*/vertexData/*to be more specific*/, GL_STATIC_DRAW);
//Unbind the buffer
glBindBuffer(GL_ARRAY_BUFFER, 0);
}