“无法添加两个指针”错误C2110,使用GLfloat array.cannot

问题描述 投票:-1回答:1

所以我认为这是我的代码中有错误的部分。我想在尝试添加顶点向量时,我没有正确地发送我的数组或其不同的东西。

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();
}
pointers vertex
1个回答
0
投票

发现我的问题,就是我忘了如何添加数组。解决了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]);
}
© www.soinside.com 2019 - 2024. All rights reserved.