简体   繁体   English

在 Mac OS X.framework 中包含 GLEW 的正确方法是什么?

[英]What is the correct way to include GLEW in a Mac OS X .framework?

Probably a very simple problem, but it's had me stumped.可能是一个非常简单的问题,但它让我难住了。

I've got an SDL/OpenGL/GLEW based static library that compiles (gcc/g++) and links fine on Windows. On OS X, the same codebase fails to compile claiming that it can't find the declaration of GL_NUM_EXTENSIONS and::glGetStringi() - which is since I've thrown GLEW in the mix (with only SDL and OpenGL, it builds fine on OS X too).我有一个基于 SDL/OpenGL/GLEW 的 static 库,它可以编译 (gcc/g++) 并在 Windows 上正常链接。在 OS X 上,相同的代码库无法编译,声称它找不到 GL_NUM_EXTENSIONS 和 :: 的声明glGetStringi() - 这是因为我已经将 GLEW 混入其中(只有 SDL 和 OpenGL,它在 OS X 上也能很好地构建)。

// globals.h
#include <glew.h>
#include <SDL/SDL.h>

// graphics.h
#include "globals.h"

bool HasGLExtension(const char* pName);

// graphics.cpp
#include <string>
#include "graphics.cpp"

bool HasGLExtension(const char* pName)
{
  GLint numExtensions;
  ::glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); // error
  for (int i = 0; i < numExtensions; ++i)
  {
    if (strcmp(pName, (char*)::glGetStringi(GL_EXTENSIONS, i)) == 0) // error
    {
      return true;
    }
  }
  return false;
}
  • the dependent libraries, built as frameworks, are situated at /Library/Frameworks.作为框架构建的依赖库位于 /Library/Frameworks。
  • the -DGLEW_STATIC -DSDL_NO_GLEXT compile flags are used (as needed on Windows - the problem persists even if I remove them).使用了 -DGLEW_STATIC -DSDL_NO_GLEXT 编译标志(根据 Windows 的需要 - 即使我删除它们,问题仍然存在)。
  • even auto-completion confirms that the location of glew.h exists (then again, of course, that's not the error I'm getting -- it's the symbols).甚至自动完成确认 glew.h 的位置存在(然后,当然,这不是我得到的错误——它是符号)。
  • including SDL/SDL_opengl.h will just result in conflicting declarations.包括 SDL/SDL_opengl.h 只会导致声明冲突。
  • the problematic definitions are present in glew.h有问题的定义存在于 glew.h 中

What's the obvious that I'm missing?什么是我失踪的明显?

Don't do it.不要这样做。 For something that 1, is easy to set up and 2, works out of the box and 3, has little to no encumbrance in its licensing, use glLoadGen .对于 1,易于设置,2,开箱即用,3,在许可方面几乎没有障碍的东西,请使用glLoadGen

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM