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"

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"

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

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

EDIT:

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).

 

[答案]

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.

If you have something like:

#include
<something_that_includes_gl.h>

#include
"Game.h"

It will effectively include gl.h before GLEW.

 

我的情况是在andriod ndk项目中遇到的这个错误,把

#include
<GL/glew.h>

这句话放在pch.h的最前面,错误就没有了。

gl.h included before glew.h的更多相关文章

  1. C++中#include包含头文件带 .h 和不带 .h 的区别

    C++中#include包含头文件带 .h 和不带 .h 的区别? 如 #include <iostream> 和 #include <iostream.h> 包含的东西有哪些 ...

  2. sed命令查找<media/msm_cam_sensor.h>替换为"len_msm_cam_sensor.h"

    sed -i 's:<media/msm_cam_sensor.h>:"len_msm_cam_sensor.h":g' $(find . -name "*. ...

  3. H.264 RTPpayload 格式------ H.264 视频 RTP 负载格式

    H.264 RTPpayload 格式------ H.264 视频 RTP 负载格式 1. 网络抽象层单元类型 (NALU) NALU 头由一个字节组成, 它的语法如下: +------------ ...

  4. H.264 SVC 与H.264 AVC

    分级视频编码技术实现一次性编码产生具有不同帧率.分辨率的视频压缩码流,然后根据不同网络带宽.不同的显示屏幕和终端解码能力选择需要传输的视频信息量,以此实现视频质量的自适应调整 AVC 实际上是 H.2 ...

  5. mysql -h localhost和mysql -h 127.0.0.1的区别

    今天早上同事说MySQL root账号登录不上了.我试了一下 #mysql -u root -p 提示”Access denied for user ‘root’@’localhost’ (using ...

  6. H.264 RTPpayload 格式------ H.264 视频 RTP 负载格式(包含AAC部分解析)

    H.264 RTPpayload 格式------ H.264 视频 RTP 负载格式 1. 网络抽象层单元类型 (NALU) NALU 头由一个字节组成, 它的语法如下: +------------ ...

  7. 简单地迁移你的android jni代码逻辑到iOS - 编写iOS下jni.h的替代 - ocni.h

    1. jni的代码逻辑中与上层平台语言交互了. 2. 使用非Xcode的ide开发工具,希望使用纯净的c/c++代码,不掺杂其它平台相关的语言语法. 3. 只想简单地替换jni代码对上层平台语言的功能 ...

  8. H.265 HD 和H.265 4K Video Encoder IP Core

    H.265 HD 和H.265 4K Video Encoder IP Core H.265 HD Video Encoder IP Core(H.265 HD Video/Audio Encoder ...

  9. sed初理多行合并+sed之G、H、g、h使用+sed n/N使用说明

    转载:[shell]sed处理多行合并 - seyjs - 博客园 (cnblogs.com) 文件格式 table=t1 name owner address table=t2 id text co ...

随机推荐

  1. [原创]互联网公司App测试流程

    [原创]互联网公司App测试流程 一款App的发布上线,离不开充分的测试工作,App测试与pc软件测试二者大体流程相同,但也有所区别,其中由于App测试有其固有的特性,所以在测试时流程会有不同,具体我 ...

  2. HDU 3472 HS BDC (混合图的欧拉路径判断)

    HS BDC Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Subm ...

  3. STM32F4, USB HS with ULPI and Suspend/Wakeup

    Hi guys,I am in need of your help, unfortunately STs documentation is lacking some information here. ...

  4. IAR EWARM __iar_program_start, __iar_data_init3, __iar_copy_init3, __iar_zero_init3

    #include <stdint.h> // The type of a pointer into the init table. typedef void const * table_p ...

  5. kettle的基本介绍

    Kettle 主要内容: 一.ETL介绍 二.Kettle介绍 三.Java调用Kettle API 一.ETL介绍 1. ETL是什么? 1).ETL分别是“Extract”.“ Transform ...

  6. [C# 基础知识系列]专题八: 深入理解泛型(二)

    引言: 本专题主要是承接上一个专题要继续介绍泛型的其他内容,这里就不多说了,就直接进入本专题的内容的. 一.类型推断 在我们写泛型代码的时候经常有大量的"<"和"& ...

  7. WebLogic使用总结(四)——WebLogic部署Web应用

    一.打包Web应用 首先将要部署到WebLogic的Web应用打包成war包,具体操作步骤如下图所示: 选中要打包的[oams]项目→[Export...]

  8. CE找基址

  9. 在CentOS4上安装JMagick

    用Java做网站经常要处理用户上传的图片,例如生成缩略图等等.虽然Java可以使用Java2D进行一些图片操作,但是功能和效率实在太差了. 目前比较好的是用JMagick来进行图像处理,不过JMagi ...

  10. git服务器的建立——Git折腾小记

    转自:http://blog.csdn.net/xsl1990/article/details/25486211 如果你能看到一些sshd相关的进程信息,则说明你已经有这个服务了,否则(或者你想更新的 ...