PDA

View Full Version : How can I creat a polyhedron in OpenGL?



szwzju
12-20-2002, 04:46 AM
i tried to run the following lines copied from a course book in BCB6.0. i added them to the framework that NeHe provided. to be specific, i added them into the function int DrawGLScene(GLvoid) after the first two lines glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear screen and depth buffer
glLoadIdentity();
but i get the error notice as following:
[C++ Error] Lesson02.cpp(80): E2225 Too many initializers
[C++ Error] Lesson02.cpp(80): E2188 Expression syntax
[C++ Error] Lesson02.cpp(87): E2451 Undefined symbol 'tindices'
[C++ Error] Lesson02.cpp(87): E2290 Subscripting missing ]
[C++ Error] Lesson02.cpp(88): E2290 Subscripting missing ]
[C++ Error] Lesson02.cpp(89): E2290 Subscripting missing ]

can anyone help me with this, i'm new to both C++ and OpenGL, thank you!


int DrawGLScene(GLvoid) // Here's where we do all the drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear screen and depth buffer
glLoadIdentity(); // Reset the current modelview matrix

#define X.525731112119133606
#define Z.850650808352039932
int i;
static GLfloat vdata[12][3]={
{-X,0.0,Z},{X,0.0,Z},{-X,0.0,-Z},{X,0.0,-Z},
{0.0,Z,X},{0.0,Z,-X},{0.0,-Z,X},{0.0,-Z,-X},
{Z,X,0.0},{-Z,X,0.0},{Z,-X,0.0},{-Z,-X,0.0},
static GLint tindices[20][3]={
{0,4,1},{0,9,4},{9,5,4},{4,5,8},{4,8,1},
{8,10,1},{8,3,10},{5,3,8},{5,2,3},{2,7,3},
{7,10,3},{7,6,10},{7,11,6},{11,0,6},{0,1,6},
{6,1,20},{9,0,11},{9,11,2},{9,2,5},{7,2,11}};
for(i=0;i<20;i++){
glBegin (GL_TRIANGLES);
glVertex3fv(&vdata[tindices[i][0][0]);
glVertex3fv(&vdata[tindices[i][1][0]);
glVertex3fv(&vdata[tindices[i][2][0]);
glEnd();
}

return true; // Done drawing the quad
}

jebus
12-20-2002, 05:00 AM
at the end of your vdata[12][3] initializer, remove the final comma and replace it with };

jebus