写了一个入门的简单的OpenGL程序,也设置了库,system32文件夹下也有opengl32.dll,glu32.dll文件,编译报错如下,求解答:
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2144: syntax error : missing ';' before type 'void'
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : fatal error C1004: unexpected end of file found

解决方案 »

  1.   


    #include "stdafx.h"
    #include "windows.h"
    #include <math.h>#include <gl/gl.h>
    #include <gl/glu.h>
    #include <gl/glaux.h>void init();
    void CALLBACK reshape(GLsizei w,GLsizei h);
    void CALLBACK display();
    GLfloat s,h;void CALLBACK display()
    {
    glClearColor(1,1,1,1);
    glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity();
    gluLookAt(5,5,h,s,0,0,0,1,0); glColor3f(0,0,0); GLfloat RAD=3.1415926/180;
    GLfloat x,y,z,r;
    int i,j;
    for (i=0;i<180;i+=5)
    {
    glBegin(GL_LINE_LOOP);
    r=2*sin(i*RAD);
    z=2*cos(i*RAD);
    for (j=0;j<360;j+=10)
    {
    x=r*cos(j*RAD);
    y=r*sin(j*RAD);
    glVertex3f(x,y,z);
    }
    glEnd();
    }
    for (j=0;j<360;j+=10)
    {
    glBegin(GL_LINE_LOOP);
    for (i=0;i<=180;i+=10)
    {
    r=2*sin(i*RAD);
    z=2*cos(i*RAD);
    x=r*cos(j*RAD);
    y=r*sin(j*RAD);
    glVertex3f(x,y,z);
    }
    glEnd();
    } glFlush();
    }void init()
    {
    glShadeModel(GL_FLAT);
    s=0;
    h=5;
    }void CALLBACK reshape(GLsizei w,GLsizei h)
    {
    glMatrixMode(GL_PROJECTION); glLoadIdentity();
    gluPerspective(30,1,-3,3); glMatrixMode(GL_MODELVIEW); glViewport(0,0,2,h);
    }void CALLBACK Left()
    {
    s+=0.1;
    }void CALLBACK Right()
    {
    s-=0.1;
    }void CALLBACK Up()
    {
    h-=0.1;
    }void CALLBACK Down()
    {
    h+=0.1
    }int main(int argc, char* argv[])
    {
    auxInitDisplayMode(AUX_SINGLE|AUX_RGB); auxInitPosition(0,0,300,300);
    auxInitWindow("OpenGl Demo");
    init(); auxKeyFunc(AUX_LEFT,Left);
    auxKeyFunc(AUX_RIGHT,Right);
    auxKeyFunc(AUX_UP,Up);
    auxKeyFunc(AUX_DOWN,Down);
    auxReshapeFunc(reshape);
    auxMainLoop(display); return 0;
    }
      

  2.   

    void CALLBACK Down()
    {
        h+=0.1;
    }
      

  3.   

    估计vc 的集成环境没有设置好。。Project | Settings ->link