0

I noticed that my triangles aren't being rendered when I have my Vertices and Indices Array in another.cpp file, I assume I am passing in the arrays incorrectly, but am unable to find any solution to my problem.

Objects.h file

class Vertex
{
public:
    void GenVBO(unsigned int VBO)
    {
        glGenBuffers(1, &VBO);
        glBindVertexArray(VBO);
    }
    void GenVAO(unsigned int VAO, float Vertices[])
    {
        glGenVertexArrays(1, &VAO);
        glBindBuffer(GL_ARRAY_BUFFER, VAO);
        glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW);
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
        glEnableVertexAttribArray(0);
    }
    void GenEBO(unsigned int EBO,unsigned int Indices[])
    {
        glGenBuffers(1, &EBO);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Indices), Indices, GL_STATIC_DRAW);
    }
};

Objects.cpp file

unsigned int VBO;
unsigned int VAO;
unsigned int EBO;

float Vertices[] =
{
   0.3f,  0.3f, 0.0f,
   0.3f, -0.3f, 0.0f,
   -0.3f, -0.3f, 0.0f,
   -0.3f,  0.3f, 0.0f
};
unsigned int Indices[] =
{
    0, 1, 3,
    1, 2, 3
};


void InitDraw()
{
    Vertex theVertex;
    theVertex.GenVBO(VBO);
    theVertex.GenVAO(VAO,Vertices);
    theVertex.GenEBO(EBO,Indices);
}

When I include my Vertices array, and Indices Array in my .H file, the square is drawn.

0 Answers0