“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”时,它仍然会抛出错误 –