在OS X Mavericks上安装FreeGLUT。

时间:2022-09-19 00:29:21

Now that OS X can use OpenGL 4+ I would like to begin learning more modern OpenGL. The tutorial I am following uses FreeGLUT as the windowing framework. While OS X has Apple's own adaption of GLUT, it is greatly outdated and doesn't work with modern OpenGL. To install FreeGLUT, I first installed X11 2.7.4 (to get GL/glx.h). Then I downloaded the tar ball of FreeGLUT from the FreeGLUT website... version 2.8.1. I then did the following in terminal:

现在OS X可以使用OpenGL 4+我想开始学习更现代的OpenGL。我使用的教程使用FreeGLUT作为窗口框架。虽然OS X有苹果自己的供过于求,但它已经过时了,而且与现代OpenGL不兼容。为了安装FreeGLUT,我首先安装了x12.7.4(得到GL/glx.h)。然后我从FreeGLUT网站下载了FreeGLUT的焦油球…2.8.1发布版本。然后我在终端做了以下工作:

./configure  CFLAGS="-I/usr/X11/include/X11/extensions -L/usr/X11/lib" LIBS="-lXrandr -lXxf86vm -lXi" --with-x --x-includes=/usr/X11/include

This worked as far as I know. I proceeded to do make all and was given many of these:

就我所知,这是可行的。我做了所有的事情,并得到了许多这样的东西:

clang: warning: argument unused during compilation: '-L/usr/X11/lib'
smooth_opengl3.c:131:1: error: unknown type name 'PFNGLGENBUFFERSPROC'
PFNGLGENBUFFERSPROC gl_GenBuffers;

I received countless of these errors; the names were all appended with PFNGL.

我收到了无数的错误;这些名字都附在PFNGL上。

I then was given a fatal error that stated too many errors were emitted and that the make would be stopped.

然后我得到了一个致命的错误,它指出了太多的错误被释放了,而make将被停止。

Any OS X or OpenGL users out there who know how to fix this?

任何OS X或OpenGL用户都知道如何解决这个问题?

4 个解决方案

#1


6  

Lazyfoo's guide to building FreeGLUT (2.8.0) on OSX worked for me, as well - with one modification: step #4 of their guide (which is for FreeGLUT 2.8.0) advises adding a macro guard to a section of code in a FreeGLUT source file. That source file in FreeGLUT 2.8.1, however, comes with three macro guards spread over the cited section of code. Instead of adding Lazyfoo's macro guard, I had to remove the 2nd and 3rd of the macro guards (that come with version 2.8.1) to get the code to compile. Hope this helps.

Lazyfoo在OSX上构建FreeGLUT(2.8.0)的指南也为我工作——有一个修改:他们指南的第4步(为FreeGLUT 2.8.0提供)建议在FreeGLUT源文件中添加一个宏保护到代码段。但是,在FreeGLUT 2.8.1中,该源文件附带了三个宏守卫,它们分布在被引用的代码段上。我没有添加Lazyfoo的宏保护,而是需要删除宏守卫的第2和3号(与2.8.1版本一起使用)来编译代码。希望这个有帮助。

#2


0  

Sorry for the late answer but if this still isn't working for you I recommend visiting lazyfoo.net and go to the OpenGL tutorials. The first one will walk you through how to install freeglut (though it might be an older version it worked for me on windows). It has a mac walkthrough as well I just can't tell you how good it is. Worth a try. Also if you are looking for tutorials I have gone through most of them and they are very good.

抱歉这么晚了,但如果这仍然没有效果,我建议你访问lazyfoo.net,然后去OpenGL教程。第一个将指导您如何安装freeglut(尽管它可能是在windows上为我工作的旧版本)。它有一个mac的演练,我只是不能告诉你它有多好。值得一试。另外,如果你正在寻找教程,我已经浏览了其中的大部分,而且它们非常好。

#3


0  

  1. #include
  2. # include
  3. #include
  4. # include
  5. #if defined(APPLE)
  6. #如果定义(苹果)
  7. #include
  8. # include
  9. #else
  10. 其他#
  11. #include
  12. # include
  13. #endif
  14. # endif

these are headers for b.c

这些是b.c的标题。

and this is make file cc b.c -o b -framework GLUT -framework opengl -Wno-deprecated

这是制作文件cc b。c -o b -框架过剩-框架opengl - wno弃用。

./b to view result in gult

。/b查看结果在gult。

#4


0  

Just a point of clarification, the included version of GLUT actually does support modern OpenGL. Create your context like this:

仅仅是澄清一点,包含的供过于求的版本确实支持现代OpenGL。创建这样的上下文:

glutInitDisplayMode(GLUT_3_2_CORE_PROFILE);

to get an OpenGL 4.1 context. I also sequence my includes like this:

获得OpenGL 4.1的上下文。我也将我的包括如下:

#include <OpenGL/gl3.h>
#define __gl_h_
#include <GLUT/glut.h>

to get access to the newer OpenGL functions and generate compiler errors when using the deprecated OpenGL functions.

要访问更新的OpenGL函数,并在使用弃用OpenGL函数时生成编译器错误。

To build on the command line just do:

在命令行上构建:

clang -framework OpenGL -framework GLUT

It works great and there is no need to install any additional libraries.

它运行良好,不需要安装任何额外的库。

#1


6  

Lazyfoo's guide to building FreeGLUT (2.8.0) on OSX worked for me, as well - with one modification: step #4 of their guide (which is for FreeGLUT 2.8.0) advises adding a macro guard to a section of code in a FreeGLUT source file. That source file in FreeGLUT 2.8.1, however, comes with three macro guards spread over the cited section of code. Instead of adding Lazyfoo's macro guard, I had to remove the 2nd and 3rd of the macro guards (that come with version 2.8.1) to get the code to compile. Hope this helps.

Lazyfoo在OSX上构建FreeGLUT(2.8.0)的指南也为我工作——有一个修改:他们指南的第4步(为FreeGLUT 2.8.0提供)建议在FreeGLUT源文件中添加一个宏保护到代码段。但是,在FreeGLUT 2.8.1中,该源文件附带了三个宏守卫,它们分布在被引用的代码段上。我没有添加Lazyfoo的宏保护,而是需要删除宏守卫的第2和3号(与2.8.1版本一起使用)来编译代码。希望这个有帮助。

#2


0  

Sorry for the late answer but if this still isn't working for you I recommend visiting lazyfoo.net and go to the OpenGL tutorials. The first one will walk you through how to install freeglut (though it might be an older version it worked for me on windows). It has a mac walkthrough as well I just can't tell you how good it is. Worth a try. Also if you are looking for tutorials I have gone through most of them and they are very good.

抱歉这么晚了,但如果这仍然没有效果,我建议你访问lazyfoo.net,然后去OpenGL教程。第一个将指导您如何安装freeglut(尽管它可能是在windows上为我工作的旧版本)。它有一个mac的演练,我只是不能告诉你它有多好。值得一试。另外,如果你正在寻找教程,我已经浏览了其中的大部分,而且它们非常好。

#3


0  

  1. #include
  2. # include
  3. #include
  4. # include
  5. #if defined(APPLE)
  6. #如果定义(苹果)
  7. #include
  8. # include
  9. #else
  10. 其他#
  11. #include
  12. # include
  13. #endif
  14. # endif

these are headers for b.c

这些是b.c的标题。

and this is make file cc b.c -o b -framework GLUT -framework opengl -Wno-deprecated

这是制作文件cc b。c -o b -框架过剩-框架opengl - wno弃用。

./b to view result in gult

。/b查看结果在gult。

#4


0  

Just a point of clarification, the included version of GLUT actually does support modern OpenGL. Create your context like this:

仅仅是澄清一点,包含的供过于求的版本确实支持现代OpenGL。创建这样的上下文:

glutInitDisplayMode(GLUT_3_2_CORE_PROFILE);

to get an OpenGL 4.1 context. I also sequence my includes like this:

获得OpenGL 4.1的上下文。我也将我的包括如下:

#include <OpenGL/gl3.h>
#define __gl_h_
#include <GLUT/glut.h>

to get access to the newer OpenGL functions and generate compiler errors when using the deprecated OpenGL functions.

要访问更新的OpenGL函数,并在使用弃用OpenGL函数时生成编译器错误。

To build on the command line just do:

在命令行上构建:

clang -framework OpenGL -framework GLUT

It works great and there is no need to install any additional libraries.

它运行良好,不需要安装任何额外的库。