 |
 |
writing OpenGL program on Mac?(sorry maybe worng place to post)
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Aug 2004
Status:
Offline
|
|
could i writing OpenGL program on Mac? which application should i use?
thx guys
|
|
There were once four people named Everybody, Somebody, Nobody and Anybody. Somebody had to do a job, but Nobody wanted to do it. Nobody could see that Anybody could do it, and Somebody got angry about that because it was Everybody's job. Nobody ended up doing it, and it so happened that Everybody blamed Somebody when Nobody did what Anybody could have done.
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2001
Location: Seattle, WA
Status:
Offline
|
|
start with the developer forum.
Start with installing the developer tools that came with your Mac (or download from connect.apple.com )
The documentation you will need will both be installed and is online at apples site.
|
|
The spirit of resistance to government is so valuable on certain occasions, that I wish it always to be kept alive.
- Thomas Jefferson, 1787
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2001
Location: Sitting in front of computer
Status:
Offline
|
|
yep its definately possible, as i had to write a couple a year or two ago. Ask in the developer forum. Also, search the web for tutorials. You will just need to use XCode that comes with OS X's dev tools.

|
|
I free'd my mind... now it won't come back.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jul 2003
Location: Bless you
Status:
Offline
|
|
|
|
|
A Jew with a view.
|
| |
|
|
|
 |
|
 |
|
Registered User
Join Date: Oct 2003
Status:
Offline
|
|
Install SDL by going to libsdl.org and downloading the SDL source.
Unpack it, ./configure, make, sudo make install.
Everything lands in /usr/local.
The #includes in your source file should look like,
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
Use "int main(int argc, char **argv) {...}" like usual with SDL_init(), SDL_SetVideoMode(), SDL_Quit(), etc.
Build with:
g++ main.cpp -I/usr/local/include -framework OpenGL -lSDL -lSDLmain -framework Foundation -framework Cocoa
(Note, libSDLmain is a statically linked lib.)
Enjoy. :)
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: May 2002
Location: Brooklyn, NY
Status:
Offline
|
|
There's also a SDL framework. It makes compiling and linking much less complicated inside of XCode. Also, you can use GLUT or Cocoa for windowing under os x. Personally I'm allergic to SDL
You also might want to check out G3D. http://g3d-cpp.sf.net . I'm working on their mac port. There will be frameworks for it soon, but for now it works fine as a static library.
gabe
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Aug 2004
Status:
Offline
|
|
i just wondering what is the difference between WINDOWS version of openGL, and MAC version of openGL? My school told us we are going to use windows version,therefore, it that mean i can not use mac to develop ?
i am new to openGL, thx in advance 
|
|
There were once four people named Everybody, Somebody, Nobody and Anybody. Somebody had to do a job, but Nobody wanted to do it. Nobody could see that Anybody could do it, and Somebody got angry about that because it was Everybody's job. Nobody ended up doing it, and it so happened that Everybody blamed Somebody when Nobody did what Anybody could have done.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Dec 1999
Location: Plainview, NY
Status:
Offline
|
|
Originally posted by maCCer:
i just wondering what is the difference between WINDOWS version of openGL, and MAC version of openGL? My school told us we are going to use windows version,therefore, it that mean i can not use mac to develop ?
i am new to openGL, thx in advance
opengl is cross platform. the only things that should be different are how you include the appropriate files, and the above poster took care of that already.
i developed in opengl for my graphics class, with the ultimate target being the school's unix boxes, and had no problem using Project Builder for that (XCode's predecessor)
|
|
|
| |
|
|
|
 |
|
 |
|
Registered User
Join Date: Oct 2003
Status:
Offline
|
|
maCCer, OpenGL is just a specification (i.e. what the API looks like, and what gets drawn when you call certain functions). You may have various implementations of that spec -- even more than one on one given platform. MS has their sort of hackneyed implementation for Windows, Apple has theirs. There's another open and cross-platform one called Mesa. nVidia has their own that they include as part of their video card drivers for GNU/Linux.
Of course you can use your Mac to develop your apps for school -- as long as they don't do something ridiculous like require you to use Windows-specific extensions or Win32 for the framework of your app.
Even if they *do* require you to use Win32, you might be able to get away with grabbing some boilerplate Win32 code and just stuff your code into it before turning it in.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Aug 2004
Status:
Offline
|
|
that is really helpful, thanks guys!
|
|
There were once four people named Everybody, Somebody, Nobody and Anybody. Somebody had to do a job, but Nobody wanted to do it. Nobody could see that Anybody could do it, and Somebody got angry about that because it was Everybody's job. Nobody ended up doing it, and it so happened that Everybody blamed Somebody when Nobody did what Anybody could have done.
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Aug 2004
Status:
Offline
|
|
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
const int windowWidth=300; const int windowHeight=400;
// define vertices and edges of the house
const int numVertices=6; const int numEdges=6;
const float vertices[numVertices][2] = {{0.0, 0.0},{100.0, 0.0},{0.0, 100.0},{100.0, 100.0},{50.0,
150.0}};
const int edges[numEdges][2] = {{0, 1},{1, 3},{3, 2},{2, 0},{2, 4},{3, 4}};
void display(void){
glClear(GL_COLOR_BUFFER_BIT); // clear all pixels in frame buffer
glColor3f (1.0, 0.0, 0.0); // draw edges in red [given as RGB (red,green,blue) value]
glBegin(GL_LINES);
for(int i=0;i<numEdges;i++){
glVertex2fv(vertices[edges[i][0]]);
glVertex2fv(vertices[edges[i][1]]); }
glEnd();
glFlush (); // start processing buffered OpenGL routines
}
void init(void) {
// select clearing color (for glClear)
glClearColor (1.0, 1.0, 1.0, 0.0); // RGB-value for white
// initialize view (simple orthographic projection)
GLdouble halfWidth=(GLdouble) windowWidth/2.0;
GLdouble halfHeight=(GLdouble) windowHeight/2.0;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-halfWidth, halfWidth, -halfHeight, halfHeight);
}
// create a single buffered colour window
int main(int argc, char** argv){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(windowWidth, windowHeight);
glutInitWindowPosition(100, 100);
glutCreateWindow("My first OpenGL program");
init (); // initialise view
glutDisplayFunc(display); // draw scene
glutMainLoop();
return 0;
}
|
|
There were once four people named Everybody, Somebody, Nobody and Anybody. Somebody had to do a job, but Nobody wanted to do it. Nobody could see that Anybody could do it, and Somebody got angry about that because it was Everybody's job. Nobody ended up doing it, and it so happened that Everybody blamed Somebody when Nobody did what Anybody could have done.
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Aug 2004
Status:
Offline
|
|
i am very new to openGL, according to the code i post above, does it related to some WINDOWS only features of openGL, which can not be implement on mac?
|
|
There were once four people named Everybody, Somebody, Nobody and Anybody. Somebody had to do a job, but Nobody wanted to do it. Nobody could see that Anybody could do it, and Somebody got angry about that because it was Everybody's job. Nobody ended up doing it, and it so happened that Everybody blamed Somebody when Nobody did what Anybody could have done.
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Apr 2001
Location: Bethesda, MD
Status:
Offline
|
|
You should be able to just change the includes at the top and it should work. Delete the include <windows.h> and change the next three to:
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Aug 2004
Status:
Offline
|
|
|
|
|
There were once four people named Everybody, Somebody, Nobody and Anybody. Somebody had to do a job, but Nobody wanted to do it. Nobody could see that Anybody could do it, and Somebody got angry about that because it was Everybody's job. Nobody ended up doing it, and it so happened that Everybody blamed Somebody when Nobody did what Anybody could have done.
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Apr 2001
Status:
Offline
|
|
You should be able to just change the includes at the top and it should work. Delete the include <windows.h> and change the next three to:
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
A better idea is to use conditional compliation to that the code will run on either the Mac or Windows. If your instructor has to go changing your programs to make them run on his system, you're going to fail the class.
So, do this instead:
#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#else
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#endif
(Obviously you need to be sure that __APPLE__ is defined on your Mac. It is by default when using gcc/XCode. If you were using CodeWarrior, you'd want to use one of their predefined macros)
The most obvious differences in OpenGL between platforms is the routines used to create an OpenGL context, a window and attach the context to the window. On Windows you use the WGL routines to create and attach the context. On the Mac, you use the AGL routines. On Linux or other X11-based systems you use the GLX routines. All the functionality is nearly identical - you just use those platform-specific routines to get OpenGL going - once it's up and going, GL is pretty much GL, regardless of platform.
Depending on the complexity of your course, you may never touch that stuff. You may use GLUT throughout to manage the contexts and windows, since it allows you to do it in platform-neutral way with just a few calls.
Wade
(Last edited by wadesworld; Jan 22, 2005 at 08:16 PM.
)
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Aug 2004
Status:
Offline
|
|
thx wade  )
that is really good  ))
|
|
There were once four people named Everybody, Somebody, Nobody and Anybody. Somebody had to do a job, but Nobody wanted to do it. Nobody could see that Anybody could do it, and Somebody got angry about that because it was Everybody's job. Nobody ended up doing it, and it so happened that Everybody blamed Somebody when Nobody did what Anybody could have done.
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Location: London
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Aug 2004
Status:
Offline
|
|
|
|
|
There were once four people named Everybody, Somebody, Nobody and Anybody. Somebody had to do a job, but Nobody wanted to do it. Nobody could see that Anybody could do it, and Somebody got angry about that because it was Everybody's job. Nobody ended up doing it, and it so happened that Everybody blamed Somebody when Nobody did what Anybody could have done.
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Aug 2004
Status:
Offline
|
|
Originally posted by wadesworld:
A better idea is to use conditional compliation to that the code will run on either the Mac or Windows. If your instructor has to go changing your programs to make them run on his system, you're going to fail the class.
So, do this instead:
#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#else
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#endif
(Obviously you need to be sure that __APPLE__ is defined on your Mac. It is by default when using gcc/XCode. If you were using CodeWarrior, you'd want to use one of their predefined macros)
The most obvious differences in OpenGL between platforms is the routines used to create an OpenGL context, a window and attach the context to the window. On Windows you use the WGL routines to create and attach the context. On the Mac, you use the AGL routines. On Linux or other X11-based systems you use the GLX routines. All the functionality is nearly identical - you just use those platform-specific routines to get OpenGL going - once it's up and going, GL is pretty much GL, regardless of platform.
Depending on the complexity of your course, you may never touch that stuff. You may use GLUT throughout to manage the contexts and windows, since it allows you to do it in platform-neutral way with just a few calls.
Wade
Are there any RULE of convert include statement of mac to windows,or reverse ,thx
|
|
There were once four people named Everybody, Somebody, Nobody and Anybody. Somebody had to do a job, but Nobody wanted to do it. Nobody could see that Anybody could do it, and Somebody got angry about that because it was Everybody's job. Nobody ended up doing it, and it so happened that Everybody blamed Somebody when Nobody did what Anybody could have done.
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Apr 2001
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Admin Emeritus 
Join Date: Oct 2000
Location: Boston, MA
Status:
Offline
|
|
By far, the best tutorials out there that I've read have been at:
http://nehe.gamedev.net
These are easy to follow, include Mac OS X/Cocoa sources, and are fairly comprehensive. :-)
|
|
"Against stupidity, the gods themselves contend in vain" (Schiller)
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Aug 2004
Status:
Offline
|
|
Originally posted by parallax:
By far, the best tutorials out there that I've read have been at:
http://nehe.gamedev.net
These are easy to follow, include Mac OS X/Cocoa sources, and are fairly comprehensive. :-)
thank you,parallax, i am checking that website, sounds cool to me
|
|
There were once four people named Everybody, Somebody, Nobody and Anybody. Somebody had to do a job, but Nobody wanted to do it. Nobody could see that Anybody could do it, and Somebody got angry about that because it was Everybody's job. Nobody ended up doing it, and it so happened that Everybody blamed Somebody when Nobody did what Anybody could have done.
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|