gpt4 book ai didi

c++ - 在多个文件中使用 Glew

转载 作者:太空宇宙 更新时间:2023-11-04 14:24:26 28 4
gpt4 key购买 nike

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

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

  1. 程序.h
    包括:<GL/glew.h> , <GL/freeglut.h>"SceneManager.h" .
  2. 场景管理器.h
    包括:"GameObject.h"
  3. 游戏对象.h
    包括:<GL/glew.h> , <GL/freeglut.h> .

我知道 freeglut 在 glew 前面,但我想要 GL_BGR例如扩展。

How do I get the glew.h in the GameObject as well?

最佳答案

一定是 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_) */

所以测试只在第一次包含 glee.h 时进行。

显然 glew 不正确地在 header 多重包含保护之外进行了测试。

我第一次运行 OpenGL 跟踪(实际上是 glslDevil)时从 glew 切换到 GLee,并看到 glew 在启动时调用了数百次 glGetString(GL_EXTENSIONS)

关于c++ - 在多个文件中使用 Glew,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5224751/

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