This topic is now archived and is closed to further replies.

where is wrong with complier this program?

This topic is 5150 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

from a official document(with vc6.0 in winxp): #include <GL/gl.h> #include <GL/glu.h> #include <stdio.h> #include <math.h> #include <GL/glaux.h> #include <stdlib.h> #pragma comment(lib,"opengl32.lib") #pragma comment(lib,"glu32.lib") #pragma comment(lib,"glaux.lib") GLuint theTorus; //Draw a torus static void torus(int numc,int numt) { int i,j,k; double s,t,x,y,z,twopi; twopi = 2*(double)M_PI; for(i=0;i=0;k--) { s=(i+k)%numc + 0.5; t=j%numt; x=(1+0.1*cos(s*twopi/numc))*cos(t*twopi/numt); y=(1+0.1*cos(s*twopi/numc))*sin(t*twopi/numt); z=0.1*sin(s*twopi/numc); glVertex3f(x,y,z); } } glEnd(); } } //Create display list with Torus and initialize state static void init(void) { theTorus = glGenLists(1); glNewList(theTorus,GL_COMPILE); torus(8,25); glEndList(); glShadeModel(GL_FLAT); glClearColor(0.0,0.0,0.0,0.0); } void display(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0,1.0,1.0); glCallList(theTorus); glFlush(); } void reshape(int w,int h) { glViewport(0,0,(GLsizei)w,(GLsizei)h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(30,(GLfloat)w/(GLfloat)h,1.0,100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0,0,10,0,0,0,0,1,0); } void keyboard(unsigned char key,int x,int y) { switch(key) { case ''x'': case ''X'': glRotatef(30.0,0.0,1.0,0.0); glutPostRedisplay(); break; case ''y'': case ''Y'': glRotatef(30.0,0.0,1.0,0.0); glutPostRedisplay(); break; case ''i'': case ''I'': glLoadIdentity(); glutLookAt(0,0,10,0,0,0,0,1,0); glutPostRedisplay(); break; case 27: exit(0); break; } } int main(int argc,char **argv) { glutInitWindowSize(200,200); glutInit(&argc,argv); glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); glutCreateWindow(argv[0]); //init(); glutReshapeFunc(reshape); glutKeyBoardFunc(keyboard); glutDisplayFunc(display); return 0; }

Share this post

Link to post
Share on other sites