OpenGL on Mac OS X
2012-06-06 10:13
501 查看
转载自:http://alumni.cs.ucsb.edu/~wombatty/tutorials/opengl_mac_osx.html
to/from OS X ]
Make sure you have XCode installed. If you don't (it doesn't come installed on new Apple machines), you'll need to dig around on your supplied OS X CDs/DVDs. Usually it is on disc 2 of the install set. Install the whole thing.
Fire up XCode and create a new project:
In the Assistant screen, scroll down to Command Line Utility and choose Standard Tool. Give it a name and a location. This will give you a barebones project without any of the Cocoa stuff included. You could, of course, use a more inclusive
project option, but I'm talking barebones here.
In the project window, Control+Click (or Right-click, if your mouse has more than one button...) and choose Add...:Existing Frameworks. You should get a file dialog that is already showing/System/Library. Just choose /System/LibraryFrameworks/OpenGL.framework,
for the base OpenGL framework and GLU, or /System/Library/Frameworks/GLUT.framework, if you want GLUT.
In your source files, be sure to include OpenGL/gl.h, OpenGL/glu.h, and/or GLUT/glut.h.
coming soon!
in the include path than Windows and Linux (and probably a bunch of other *n?x OSes). Here's the skinny:
The other headache(?) that you will come across if you are doing things on the command line is what switches to feed
available above, but what do you do if you want to move your app to Linux? Or, heaven forbid, Windows?
Well, for Linux, you will replace those short little
For Windows I have, admittedly, no idea.
OpenGL on Mac OS X
[ Using XCode | Using GNU tools | Portingto/from OS X ]
Using XCode
This will get you an XCode project with all of the necessary frameworks added to it.Make sure you have XCode installed. If you don't (it doesn't come installed on new Apple machines), you'll need to dig around on your supplied OS X CDs/DVDs. Usually it is on disc 2 of the install set. Install the whole thing.
Fire up XCode and create a new project:
File:New Project.
In the Assistant screen, scroll down to Command Line Utility and choose Standard Tool. Give it a name and a location. This will give you a barebones project without any of the Cocoa stuff included. You could, of course, use a more inclusive
project option, but I'm talking barebones here.
In the project window, Control+Click (or Right-click, if your mouse has more than one button...) and choose Add...:Existing Frameworks. You should get a file dialog that is already showing/System/Library. Just choose /System/LibraryFrameworks/OpenGL.framework,
for the base OpenGL framework and GLU, or /System/Library/Frameworks/GLUT.framework, if you want GLUT.
In your source files, be sure to include OpenGL/gl.h, OpenGL/glu.h, and/or GLUT/glut.h.
Using GNU tools
This will get you going on the command line. This ought to be easier if you plan on moving between operating systems.coming soon!
Porting to/from OS X
OpenGL == cross-platform, right? Almost. Porting an existing OpenGL application to or from OS X is largely a matter of headers (I think...). For some unknown reason, OS X puts the headers in a different locationin the include path than Windows and Linux (and probably a bunch of other *n?x OSes). Here's the skinny:
Header Description | Mac OS X | The Rest of the World |
---|---|---|
GL - OpenGL Base | #include <OpenGL/gl.h> | #include <GL/gl.h> |
GLU - OpenGL Utility | #include <OpenGL/glu.h> | #include <GL/glu.h> |
GLUT - OpenGL Utility Toolkit | #include <GLUT/glut.h> | #include <GL/glut.h> |
gcc. The proper Mac switches are
available above, but what do you do if you want to move your app to Linux? Or, heaven forbid, Windows?
Well, for Linux, you will replace those short little
-frameworkflags with something like the following (stolen, unceremoniously, from the CS280: Real-time Graphics class website at UCSB):
-lglut -lGLU -lGL -L/usr/X11R6/lib/ -lXmu -lXi -lXext -lX11 -lXt
For Windows I have, admittedly, no idea.
相关文章推荐
- OpenGL on Mac OS X
- OpenGL(R) Programming on Mac OS(R) X: Architecture, Performance, and Integration
- 【OpenGL Programming On macOS using glfw 】0: Build a Simple OpenGL Program
- Getting List of All Processes on Mac OS X
- using zsh on MAC OS X
- 在Mac OS X 用C++编写OpenGL程序
- 解决Virtual Box 安装Mac OS X当出现“hfs: summary table not allowed on FS with block size of 2048”问题
- 初探SQL Server 2017 on Docker@macOS
- RemoteBox : Screenshots Screenshots Various screenshots of RemoteBox under different operating systems including Linux, MacOS X, Solaris, NetBSD, FreeBSD and OpenBSD. Do you have a screenshot of RemoteBox running on a distro or operating system
- Installing Wine on Mac OS X
- Mysql On Mac OS: Remove & Install
- Create & delete user accounts from the command line on Mac OS X
- Fixing java.net Local host name unknown error on Mac OS X
- Cross compile webrtc for ios on mac os.
- Raspberry Pi: INSTALLING OPERATING SYSTEM IMAGES ON MAC OS
- Installing ADB on MAC OS X
- MAc Os X OPENGL 的初步探索
- subversion on Mac OS X step by step
- install mongodb on macos
- sed: 1: “…”: invalid command code on Mac OS