Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/163.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在多个文件中使用Glew_C++_Opengl_Freeglut_Glew - Fatal编程技术网

C++ 在多个文件中使用Glew

C++ 在多个文件中使用Glew,c++,opengl,freeglut,glew,C++,Opengl,Freeglut,Glew,不知何故,我无法在多个头文件中获得Glew。它只是抱怨在GLEW之前已经定义了Gl 简而言之,我有以下文件结构: 程序.h 包括:、和SceneManager.h。 场景管理器 包括:GameObject.h GameObject.h 包括:。 我确实理解freeglut在glew前面,但我想以GL_BGR扩展为例 我如何在游戏对象中获得glew.h呢 肯定是glew.h里的一只虫子 我改用GLee,它没有这个问题。GLee的测试如下所示: #ifndef __glee_h_ #define _

不知何故,我无法在多个头文件中获得Glew。它只是抱怨在GLEW之前已经定义了Gl

简而言之,我有以下文件结构:

程序.h 包括:、和SceneManager.h。 场景管理器 包括:GameObject.h GameObject.h 包括:。 我确实理解freeglut在glew前面,但我想以GL_BGR扩展为例

我如何在游戏对象中获得glew.h呢

肯定是glew.h里的一只虫子

我改用GLee,它没有这个问题。GLee的测试如下所示:

#ifndef __glee_h_
#define __glee_h_

#ifdef __gl_h_
    #error gl.h included before glee.h
#endif

#ifdef __glext_h_
    #error glext.h included before glee.h
#endif

#ifdef __wglext_h_
    #error wglext.h included before glee.h
#endif

#ifdef __glxext_h_
    #error glxext.h included before glee.h
#endif

//...
#endif /* !defined(__glee_h_) */
#ifndef _STDAFX_H_
#define _STDAFX_H_

#include <GL/glew.h>
#include <GL/freeglut.h>

#endif
因此,测试只在第一次包含glee.h时进行

显然,glew在标头多重包含保护之外不正确地进行测试


第一次运行OpenGL跟踪glslDevil时,我从glew切换到了GLee,实际上,我看到glew在启动时调用了数百次glGetStringGL_扩展。

我现在自己做的有点不同:

我创建了一个包含glew和freeglut的预编译头。看起来是这样的:

#ifndef __glee_h_
#define __glee_h_

#ifdef __gl_h_
    #error gl.h included before glee.h
#endif

#ifdef __glext_h_
    #error glext.h included before glee.h
#endif

#ifdef __wglext_h_
    #error wglext.h included before glee.h
#endif

#ifdef __glxext_h_
    #error glxext.h included before glee.h
#endif

//...
#endif /* !defined(__glee_h_) */
#ifndef _STDAFX_H_
#define _STDAFX_H_

#include <GL/glew.h>
#include <GL/freeglut.h>

#endif
有人能确认这是否是一种可靠且众所周知的方法吗