public int createVAO()
    {
        int vao = glGenVertexArrays();
        glBindVertexArray(vao);

        int vbo = GLAllocation.generateBuffer();
        System.out.println(glGetError() == GL_NO_ERROR);

        vboSize = faces.size() * 3;

        FloatBuffer data = BufferUtils.createFloatBuffer(faces.size() * 3 * (3 + 4 + 2) );

        for (Model.Face face : faces)
        {
            for (int i = 0; i < 3; i++) //i < face.getVertexIndices().length
            {
                Vector3f v = vertices.get(face.getVertexIndices()[i] - 1);
                data.put(new float[]{v.x, v.y, v.z});

                if (hasNormals())
                {
                    Vector3f n = normals.get(face.getNormalIndices()[i] - 1);
                    data.put(new float[]{n.x, n.y, n.z, face.getMaterial()});
                }
                if (hasTextureCoordinates())
                {
                    Vector2f t = textureCoordinates.get(face.getTextureCoordinateIndices()[i] - 1);
                    data.put(new float[]{t.x, t.y});
                }
            }
        }

        data.flip();
        glBindBuffer(GL_ARRAY_BUFFER, vbo);
        glBufferData(GL_ARRAY_BUFFER, data, GL_STATIC_DRAW);

        System.out.println(glGetError() == GL_NO_ERROR);

        for (int i = 0; i < 4; i++) {
            glEnableVertexAttribArray(i);
        }

        int stride = hasNormals() ? (hasTextureCoordinates() ? 36 : 28) : 0; //36 = (numVertexComponents + numNormalComponents + numTextureComponents) * sizeOfBufferTypeInBytes = (3 + 4 + 2) * 4

        glVertexAttribPointer(0, 3, GL_FLOAT, false, stride, 0L);
        if (hasNormals()) {
            glVertexAttribPointer(1, 3, GL_FLOAT, false, stride, 12L);
            glVertexAttribPointer(2, 1, GL_FLOAT, false, stride, 24L);
        }
        if (hasTextureCoordinates()) {
            glVertexAttribPointer(3, 2, GL_FLOAT, false, stride, 28L);
        }

        glBindBuffer(GL_ARRAY_BUFFER, 0);
        glBindVertexArray(0);

        compiled = true;
        return vao;
    }