所以我认为这是我的代码中有错误的部分。我想在尝试添加顶点向量时,我没有正确地发送我的数组或其不同的东西。
void tetrahedron(GLfloat vertice[6][3])
{
glTranslatef(0.3f, 0.0f, 0.0f);
glRotatef(45.0f, 0.0, 1.0, 0.0);
glRotatef(45.0f, 0.0, 0.0, 1.0);
//Cara1
glBegin(GL_QUADS);
glColor3f(0.1, 0.0, 0.9);
GLfloat temp[3];
temp = vertice[2] + vertice[5] + vertice[0];
glVertex3fv(temp);
glVertex3fv(temp);
glVertex3fv(temp);
glEnd();
}
错误是C2110:'+':无法添加两个指针
in:temp = vertex [2] + vertex [5] + vertex [0];
void octahedron(GLfloat vertice[6][3])
{
glTranslatef(0.0f, 0.0f, -5.0f);
glRotatef(45.0f, 0.0, 1.0, 0.0);
glRotatef(45.0f, 0.0, 0.0, 1.0);
}
没什么特别的
在下一个函数是我创建我的数组,我试图发送到八面体和四面体:
void display(void) // Creamos la funcion donde se dibuja
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Limiamos pantalla y Depth Buffer
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); // Reinicializamos la actual matriz Modelview
GLfloat vertice[6][3] = {
{0.0, 0.5, 0.0}, //arriba
{ 0.0,-0.5,0.0 }, //abajo
{ 0.5,0.0,0.0 }, //izq
{ -0.5,0.0,0.0 }, //der
{ 0.0,0.0,0.5 }, //frontal
{ 0.0,0.0,-0.5 }, //trasero
};
octahedron(vertice);
tetrahedron(vertice);
glFlush();
}
发现我的问题,就是我忘了如何添加数组。解决了for和stuff:
GLfloat temp[3];
int i;
//cara 1
for ( i = 0; i < 3; i++); {
temp[i]= (vertice[2][i]) + (vertice[5][i]) + (vertice[0][i]);
}