gpt4 book ai didi

opengl - fatal error gl.h 包含在 glew.h 之前

转载 作者:行者123 更新时间:2023-12-02 04:38:27 28 4
gpt4 key购买 nike

#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();
}

当我在 Microsoft Visual Studio 中构建源代码时出现错误"e:\vs2012\vc\include\gl\glew.h(84): fatal error C1189: #error : gl.h included before glew.h"。我还在 gl.h 之前包含了 glew.h可能是什么问题?

最佳答案

freeglut.h 将包含 gl.h。您必须在 freeglut.h 之前包含 glew.h。 glew 是一个非常好的和流行的库,但是这个 gl.h 包含在 glew.h 之前 是一个主要的限制!

关于opengl - fatal error gl.h 包含在 glew.h 之前,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21415319/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com