glu.h问题!

Gri*_*fin -1 c++ opengl freeglut static-libraries visual-studio-2010

好吧我在Windows 7上设置Visual Studio C++ 10所以我可以从本书"OpenGL superbible 5th edition"中运行示例程序,但是我有一些主要问题,在获取GLTools和freeglut的时候:
这是我如何设置一切到目前为止.........................

我上网后跟着这些步骤:

首先你要下载过剩或freeglut,然后解压缩它.
- 我从http://www.starstonesoftware.com/OpenGL/上的zip文件中得到了这个

在freeglut文件夹中应该有一个名为VisualStudio2008的文件夹,请进入此目的.

应该有一个名为freeglut的VS项目文件,运行它并在转换窗口出现时单击"完成".然后编译它,如果它完成它说无法启动,这没关系.

现在在同一个文件夹中应该有一个名为Debug的新文件夹,因为你刚刚编译了freeglut :).

在里面你会发现freeglut.dll.这需要分别进入你的system32文件夹或SysWOW64.

除此之外还有一个名为freeglut的文件,其类型将是Object File Library.这需要进入Visual Studio中的lib文件夹.

现在回到主要的freeglut文件夹.应该有一个名为Include的文件夹.在这个名为GL的文件夹和两个文件中.这些需要复制到Visual Studio中的Include文件夹中.

lib和Include文件夹位于VC文件夹中,该文件夹位于Visual Studio文件夹中,对我来说是Microsoft Visual Studio 10.0.

有:) .`

然后我按照以下步骤设置GLTools和freeglut:

这需要计算机上的管理员权限.

一世.将所有freeglut头文件(以.h结尾)复制到该文件夹​​:C:\ Program Files\Microsoft Visual Studio 10.0\VC\include\GL \

II.将所有GLTools头文件(以.h结尾)复制到C:\ Program Files\Microsoft Visual Studio 10.0\VC\include \

III.将所有freeglut和GLTools库文件(以.lib结尾)文件复制到C:\ Program Files\Microsoft Visual Studio 10.0\VC\lib \

IV.即使您已将GLTools.lib复制到lib文件夹中,您仍可能需要告诉VS2010在编译项目时使用GLTools.lib文件.从菜单选项View→Property Manager打开Property Manager(您需要一个打开的项目来执行此操作).VS IDE的左侧窗格将更改为显示属性管理器.您可以调整此大小以使其更具可读性.如果未显示完整列表,请展开项目,然后双击其中一个Microsoft.Cpp.Win32.user链接以打开用户属性对话框.在Property Manager中,选择Linker→Input,然后单击Additional Dependencies(见下文).在弹出的对话框中添加"GLTools.lib",我还为此添加了feeglut_static.lib!

好吧,所以最后这里是我想要运行的代码:

#include <GLTools.h>            // OpenGL toolkit 
#include <GLShaderManager.h>    // Shader Manager Class 

#ifdef __APPLE__ 
#include <glut/glut.h>          // OS X version of GLUT 
#else 
#define FREEGLUT_STATIC 
#include <GL/glut.h>            // Windows FreeGlut equivalent 
#endif 


GLBatch triangleBatch;
GLShaderManager shaderManager;

///////////////////////////////////////////////////////////////////////////////
// Window has changed size, or has just been created. In either case, we need
// to use the window dimensions to set the viewport and the projection matrix.
void ChangeSize(int w, int h)
    {
    glViewport(0, 0, w, h);
    }


///////////////////////////////////////////////////////////////////////////////
// This function does any needed initialization on the rendering context.
// This is the first opportunity to do any OpenGL related tasks.
void SetupRC()
    {
    // Blue background
    glClearColor(0.0f, 0.0f, 1.0f, 1.0f );

    shaderManager.InitializeStockShaders();

    // Load up a triangle
    GLfloat vVerts[] = { -0.5f, 0.0f, 0.0f,
                          0.5f, 0.0f, 0.0f,
                          0.0f, 0.5f, 0.0f };

    triangleBatch.Begin(GL_TRIANGLES, 3);
    triangleBatch.CopyVertexData3f(vVerts);
    triangleBatch.End();
    }



///////////////////////////////////////////////////////////////////////////////
// Called to draw scene
void RenderScene(void)
    {
    // Clear the window with current clearing color
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    GLfloat vRed[] = { 1.0f, 0.0f, 0.0f, 1.0f };
    shaderManager.UseStockShader(GLT_SHADER_IDENTITY, vRed);
    triangleBatch.Draw();

    // Perform the buffer swap to display back buffer
    glutSwapBuffers();
    }


///////////////////////////////////////////////////////////////////////////////
// Main entry point for GLUT based programs
int main(int argc, char* argv[])
    {
    gltSetWorkingDirectory(argv[0]);

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);
    glutInitWindowSize(800, 600);
    glutCreateWindow("Triangle");
    glutReshapeFunc(ChangeSize);
    glutDisplayFunc(RenderScene);

    GLenum err = glewInit();
    if (GLEW_OK != err) {
        fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err));
        return 1;
        }

    SetupRC();

    glutMainLoop();
    return 0;
    }
Run Code Online (Sandbox Code Playgroud)

最后,这是我接受的错误:

1>------ Build started: Project: Triangle, Configuration: Debug Win32 ------
1>  Triangle.cpp
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\gl\glu.h(225): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\gl\glu.h(225): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\gl\glu.h(226): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\gl\glu.h(226): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\gl\glu.h(226): error C2086: 'int GLAPI' : redefinition
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\gl\glu.h(225) : see declaration of 'GLAPI'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\gl\glu.h(227): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\gl\glu.h(227): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\gl\glu.h(227): error C2086: 'int GLAPI' : redefinition
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\gl\glu.h(225) : see declaration of 'GLAPI'
Run Code Online (Sandbox Code Playgroud)

错误C1003:错误计数超过100; 停止编译

这是永远的,我不知道怎么会出现这样的问题,以及为什么它会在GLU.h中发生!我真的不确定什么是错的,我已经有一个星期的问题...请帮助=)

谢谢你,随时提出任何问题!

Ben*_*igt 6

不幸的是,你所遵循的所有指示都是糟糕的想法.将调试DLL复制到系统目录中 - 不好.将文件复制到Visual Studio包含目录 - 坏.

我没有使用GLUT,所以我没有一系列的工作步骤,但实际上你应该在你的项目中用include,lib和bin子目录创建一个子目录,并将所有内容安排在那里.虽然Visual C++ 2008具有计算机范围的目录设置,但Visual C++ 2010具有每项目目录配置.

至于修复你现在的错误,你需要从第225行向我们展示一块GL/glu.h.