「sizeof(points)」是拋出錯誤的部分(標記如下)。我不知道發生了什麼事情。我是OpenGL的新手,我正在試驗我學到的東西,使得繪製多個三角形成爲可能。我也放在代碼在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);
}
這意味着你沒有在任何地方定義的點。 –
它在頭文件 –
中定義並且即使當我使用「this-> points」時,它仍然會拋出錯誤 –