#error gl.h包含在glew.h之前 [英] #error gl.h included before glew.h

查看:5033
本文介绍了#error gl.h包含在glew.h之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图将我的OpenGL代码从Main()移动到一个特定的类,只有在必要的时候才会处理3D图形。以前,我的main.cpp文件的顶部如下所示:

So I'm trying to move my OpenGL code from Main() into a specific class that will handle the 3D graphics only when necessary. Previously, the top of my main.cpp file looked like this:

#define GLEW_STATIC
#include <GL/glew.h>
#include <SFML/Graphics.hpp>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include "Game.h"

我试图做的是将所有OpenGL相关的代码移动到 Game 类的方法。所以我从上面删除了 #define GLEW_STATIC #include< GL / glew.h> 到Game.h,这样Game.h的顶部现在看起来像这样:

This worked well enough. What I tried to do was move all the OpenGL-relevant code into methods of the Game class. So I removed #define GLEW_STATIC and #include <GL/glew.h> from the above, and put them into Game.h, such that the top of Game.h now looks like this:

#define GLEW_STATIC
#include <GL/glew.h>
#include <SFML/Graphics.hpp>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include "Environment.h"

当我尝试编译时,错误, #error gl.h包含在glew.h 之前。

When I try to compile, I get the title error, #error gl.h included before glew.h.

为什么会发生这种情况,使用OpenGL代码(几乎)完全在特定类的函数内,而不会发生这种情况?

Why is this happening, and how can I use OpenGL code (almost) entirely inside the functions of a specific class without this happening?

编辑:

我也试过在main.cpp这个配置,以确保在GLEW之前没有包括SFML。

I have also tried this configuration in main.cpp, in an attempt to make sure that nothing includes SFML before GLEW.

#include <cstdlib>
#include <iostream>
#include <fstream>
#include "Game.h"
#include <SFML/Graphics.hpp>

不幸的是,这没有帮助(没有什么包括,我没有提到这里) 。

Unfortunately, that doesn't help (there's nothing else being included that I'm not mentioning here).

推荐答案

其他一些库包括gl.h.我的猜测是SFML。确保您在Game.h中首先包含GLEW,并检查您包含Game.h的位置,以确保您在Game.h之前不包含SFML或包含gl.h的其他内容。

Some other library is including gl.h. My guess would be SFML. Make sure you include GLEW first in Game.h and check the places where you include Game.h to make sure you're not including SFML or something else that includes gl.h before Game.h.

如果你有类似的东西:

#include <something_that_includes_gl.h>
#include "Game.h"

它将有效地包括GLEW之前的gl.h。

It will effectively include gl.h before GLEW.

这篇关于#error gl.h包含在glew.h之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆