Domanda

#include<Windows.h>
#include <GL/freeglut.h>
#include <GL/glew.h>
#include<gl/GLU.h>
#include<gl/GL.h>
#include<iostream>
using namespace std;

const int width=1280;
const int height=960;
void OnInit();
void OnShutdown();
void OnResize();
void OnRender();

int main(int argc, char** argv) {
glutInit(&argc, argv);  
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE |
GLUT_RGBA);  
glutInitContextVersion (3,7     );
glutInitContextFlags (GLUT_CORE_PROFILE | GLUT_DEBUG);
glutInitContextProfile(GLUT_FORWARD_COMPATIBLE);
glutInitWindowSize(width, height);
glutCreateWindow("getting started with understanding");



glewExperimental = GL_TRUE;
GLenum err = glewInit();
if (GLEW_OK != err){
cerr<<"Error: "<<glewGetErrorString(err)<<endl;
} else {
if (GLEW_VERSION_3_3)
{
cout<<"Driver supports OpenGL 3.3\nDetails:"<<endl;
}   
}
cout<<"\tUsing glew "<<glewGetString(GLEW_VERSION)<<endl;
cout<<"\tVendor: "<<glGetString (GL_VENDOR)<<endl;
cout<<"\tRenderer: "<<glGetString (GL_RENDERER)<<endl;
cout<<"\tVersion: "<<glGetString (GL_VERSION)<<endl;
cout<<"\tGLSL:"<<glGetString(GL_SHADING_LANGUAGE_VERSION)<<endl;


OnInit();
glutCloseFunc(OnShutdown);
glutDisplayFunc(OnRender);
glutReshapeFunc(OnResize);
glutMainLoop();
return 0;

}

void OnInit() {
glClearColor(1,0,0,0);
cout<<"Initialization successfull"<<endl; 
}
void OnShutdown() {
cout<<"Shutdown successfull"<<endl;
}
void OnResize(int nw, int nh) {

}
void OnRender() {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}

When I build the source code in Microsoft Visual Studio giving the error "e:\vs2012\vc\include\gl\glew.h(84): fatal error C1189: #error : gl.h included before glew.h" . And I have also include glew.h before gl.h What can be the problem?

È stato utile?

Soluzione

freeglut.h will include gl.h. You have to include glew.h before freeglut.h. glew is a very good and popular library but this gl.h included before glew.h is a major constraint!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top