Setting Up In XCode
- Create new Command Line Tool
GLUT
Link Frameworks:
- Click on your project name then click on Build Phases
- Click ‘Link Binary With Libraries’
- Click the + button
- Type OpenGL in the search box, Click OpenGL.framework, then click Add
- Click the + button again
- Type glut in the search box, Click GLUT.framework, then click Add
Remove Depreciation Warnings (GLUT OpenGL files have been depreciated)
- Click the Build Settings tab
- In the search bar on the top right of the tab, type deprecated
- Under Apple LLVM – Warnings – All Languages, look for “Deprecated Functions” setting
- Change the setting to “No”
Include libraries in your project
- select main.c
- add the following files:
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
Done!
GLFW
Downloading GLFW & GLEW
- download GLFW & GLEW
- unzip both
- create new project - your base OpenGL project
- put GLEW & GLFW inside new project folder
- create 'build' folder inside
glfw
folder - Open CMake. input GLFW location, and put output as
glfw/build
folder Open newly created GLFW project in
glfw/build
- change the scheme ALL_BUILD to "install"
- Click the Run button.
Open terminal, cd to GLEW folder, "
sudo make install
"- GLEW libraries are now in
glew/lib
, and GLEW include files are inglew/include
- GLEW libraries are now in
Open your base OpenGL project > Build Phases > Link Binary w\/ libraries:
- OpenGL.framework
- libGLEW. ------, in
/usr/local/lib
- libglfw. -------, in ... look for it...
Go to Build settings> search paths>
- HEADER search paths: \/usr\/local\/include
- LIBRARY Search paths: \/usr\/local\/lib
Still under Build settings, go to Linking> Other Linker Flags, add
-lGLEW
#include <GL\/glew.h>
- #include <GLFW\/glfw3.h>
Adding GLFW & GLEW To Your Project
- Create new project
- Copy and paste GLFW & GLEW folders from base project
Open your OpenGL project > Build Phases > Link Binary w\/ libraries:
- OpenGL.framework
- libGLEW. ------, in
/usr/local/lib
(the most recently created) - libglfw. --------, in
/usr/local/lib
(the most recently created)
Go to Build settings> search paths>
HEADER search paths: \/usr\/local\/include
LIBRARY Search paths: \/usr\/local\/lib
- still under Build settings, go to Linking> Other Linker Flags, add
-lGLEW
- #include <GL\/glew.h>
- #include <GLFW\/glfw3.h>