简体   繁体   中英

Installing FreeGLUT on OS X Mavericks

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:

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

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

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

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.

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

glutInitDisplayMode(GLUT_3_2_CORE_PROFILE);

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

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

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.

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.

#include <stdio.h>
#include <stdlib.h>

#if defined(__APPLE__)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

these are headers for bc

and this is make file cc bc -ob -framework GLUT -framework opengl -Wno-deprecated

./b to view result in gult

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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