所以我认为这是我的代码中出现错误的部分。我认为在尝试添加顶点矢量时,我无法正确发送数组或其他内容。
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 =顶点[2] +顶点[5] +顶点[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();
}
答案 0 :(得分:0)
发现我的问题,那是我忘记了一般如何添加数组。解决了一个for和东西:
GLfloat temp[3];
int i;
//cara 1
for ( i = 0; i < 3; i++); {
temp[i]= (vertice[2][i]) + (vertice[5][i]) + (vertice[0][i]);
}