mardi 5 juillet 2016

"Incomplete Type Is Not Allowed" Error

"sizeof(points)" is the part that is throwing the error (Marked below). I don't know what is going on / what is wrong. I am new to OpenGL and I am experimenting with what I have learned to make it possible to have multiple triangles drawn hence the class. I have also placed the code in a pastebin here

VertexObject.h

#pragma once

#include <stdio.h>
#include <stdlib.h>

#include <GL\glew.h>
#include <GLFW\glfw3.h>

class VertexObject
{

public:
    VertexObject ( );

    void SetArray ( GLfloat Points [] );

    void SetBuffer ( GLuint* VBO );

    GLfloat Points [ ] = {
         1.0f , 0.0f , 1.0f,
         0.0f , 1.0f , 1.0f,
        -1.0f , 0.0f , 1.0f
    };

private:



};

VertexObject.cpp

#include "VertexObject.h"

#include <stdio.h>
#include <stdlib.h>

#include <GL\glew.h>
#include <GLFW\glfw3.h>

void VertexObject::SetArray ( GLfloat Points [ ] )
{

    //Generate Vertex Array Object
    GLuint vaoID1;
    //Generates an array for the VAO
    glGenVertexArrays ( 1 , &vaoID1 );
    //Assigns the array to the Vertex Array Object
    glBindVertexArray ( vaoID1 );

    //Fills in the array

    for ( int i = 0; i < sizeof ( Points ); i++ ) //Error occurs here
    {

        this->Points [ i ] = Points [ i ];

    }

}

void VertexObject::SetBuffer ( GLuint* VBO )
{

    //Generate Vertex Buffer Object
    glGenBuffers ( 1 , VBO );
    glBindBuffer ( GL_ARRAY_BUFFER , *VBO );
    glBufferData ( GL_ARRAY_BUFFER ,sizeof(Points) , Points , GL_STATIC_DRAW );

}

Aucun commentaire:

Enregistrer un commentaire