问题
Ok so im setting up Visual studios C++ 10 on Windows 7 so i can run the sample progams from this book "OpenGL superbible 5th edition" but i'm having some MAJOR ISSUES, in getting GLTools and freeglut to wok:
Here's how I set everything up so far.........................
fist followed these steps i got online:
first youl want to download glut or freeglut, then unzip it ofc.
- I got this from the zip file at http://www.starstonesoftware.com/OpenGL/
In the freeglut folder there should be a folder called VisualStudio2008, go into this.
There should be a VS project file called freeglut, run this and click finish if the conversion window comes up. Then Compile it, if when its done it says unable to start, this is ok.
Now in the same folder there should be a new folder called Debug, as you have just compiled freeglut to it :).
Inside you will find freeglut.dll. This needs to go into your system32 folder, or SysWOW64 respectivily.
Aswell as this there is a file called freeglut, its type will be Object File Library. This needs to go into your lib folder in Visual studio.
Now go back to the main freeglut folder. There should be a folder called Include. and inside this a folder called GL and two files. These need to be copied into the Include folder in Visual Studio.
The lib and Include folders are inside the VC folder which is in the main Visual Studio folder which for me is Microsoft Visual Studio 10.0 .
There :).`
Then i followed these steps to set up GLTools and freeglut:
this requires admin permission on the computer.
i. Copy all of the freeglut header files (ending in .h) to the folder: C:\Program Files\Microsoft Visual Studio 10.0\VC\include\GL\
ii. Copy all of the GLTools header files (ending in .h) to C:\Program Files\Microsoft Visual Studio 10.0\VC\include\
iii. Copy all of the freeglut and GLTools library files (ending in .lib) files to C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\
iv. Even though you have copied GLTools.lib into the lib folder, you may still need to tell VS2010 to use the GLTools.lib file when compiling your projects. Open the Property Manager (you'll need an open project to do this), from the menu option View → Property Manager. The left hand pane of the VS IDE will change to show the property manager. You can resize this to make it more readable. Expand the project if the full listing is not shown, then double click on one of the Microsoft.Cpp.Win32.user links to open the user properties dialog. In the Property Manager, select Linker → Input, then click on the Additional Dependencies (see below). In the dialog that pops up add “GLTools.lib”, I also added feeglut_static.lib to this!
Alright so finally here's the code i'm tying to run:
#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;
}
and FINALLY FINALLY, here's the errors im recieveing:
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'
error C1003: error count exceeds 100; stopping compilation
This goes on FOREVER and i don't know how there can be such a problem, and why it's happening in GLU.h! I'm reallly not sure whats wrong an i've had this problem for a week... PLEASE HELP =)
thank you, and feel free to ask any questions!
回答1:
Unfortunately all of the instructions you followed were bad ideas. Copying debug DLLs into the system directory -- bad. Copying files into the Visual Studio include directory -- bad.
I don't use GLUT so I don't have a sequence of working steps, but really you should have made a subdirectory in your project with include, lib, and bin subdirectories, and arranged everything inside there. While Visual C++ 2008 had machine-wide directory settings, Visual C++ 2010 has per-project directory configuration.
As far as fixing the error you have now, you need to show us a block of GL/glu.h starting at line 225.
来源:https://stackoverflow.com/questions/5629351/glu-h-problems