I am having an unusual problem with setting opengl and visual C++ 2010. I have download bothe gltools and freeglut 2.6 and I have added the header files to my project properties under the c++ -> general -> additional include libraries and library files under linker -> input -> additonal dependencies.
I’ve made the following calls to the headers in my cpp file as follows:
#include <stdio.h>
#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
(I am following an example in the book OPengl superbible 5th edition)
This is boderline frustrating at his point because the project will not build, refusing to identify some of the functions. I will paste the code below
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 the 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
”, glewGetErrorString(err));
return 1;
}
SetupRC();
glutMainLoop();
return 0;
}
Also here are the errors i am receiving
1>c:\users****\documents\visual studio 2010 riangle.cpp(53): error C2065: ‘“Triangle”’ : undeclared identifier
1>c:\users****\documents\visual studio 2010 riangle.cpp(58): error C2065: ‘“GLEW’ : undeclared identifier
1>c:\users****\documents\visual studio 2010 riangle.cpp(58): error C2146: syntax error : missing ‘)’ before identifier ‘Error’
1>c:\users****\documents\visual studio 2010 riangle.cpp(58): error C2017: illegal escape sequence
1>c:\users****\documents\visual studio 2010 riangle.cpp(58): error C2059: syntax error : ‘)’
Any help would be greatly appreciated. Thanks.