I am working with OpenGL and I am trying to make a simple ground class that draws a rectangle.
I have a class called Vertex:
class Vertex
{
public:
Vertex(
glm::vec3 _position,
glm::vec3 _color = glm::vec3(0.0, 0.0, 0.0),
glm::vec3 _normal = glm::vec3(0.0, 1.0, 0.0),
glm::vec3 _texture = glm::vec3(0.0, 0.0, 0.0));
void setNormal(glm::vec3 _normal);
void setTexture(glm::vec3 _texture);
virtual ~Vertex();
protected:
private:
glm::vec3 position;
glm::vec3 color;
glm::vec3 normal;
glm::vec3 texture;
};
And this is my Ground class:
class Ground
{
private:
double widht;
double length;
double y;
int* indexes;
Vertex* vertices;
public:
Ground(double _width, double_length, double y);
}
And here is what I want to do in the Ground constructor:
this->indexes = {0, 3, 1, 1, 3, 2};
this->vertices = {
Vertex(glm::vec3(0 - width/2, y, 0-length/2)),
Vertex(glm::vec3(0 - width/2, y, 0+length/2)),
Vertex(glm::vec3(0 + width/2, y, 0+length/2)),
Vertex(glm::vec3(0 + width/2, y, 0-length/2))
}
I am getting this error when compiling:
error: cannot convert ‘<brace-enclosed initializer list>’ to ‘Vertex*’
Now I know I could hard-code initialize all of this, but I want a solution for a general ClassX* array header definition and constructor initialization.