johnMG
2003.10.21, 11:50 AM
This is my first post here, and I'm also just getting started with OSX and Obj-C. :)
I made a small glut example program by:
-- using PB to create a Cocoa app,
-- added the GLUT and OpenGL frameworks to the project,
-- renamed main.m to main.c, wiped out what was in there:
#import <Cocoa/Cocoa.h>
int main(int argc, const char *argv[])
{
return NSApplicationMain(argc, argv);
}
and put in this:
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
void initGL();
void drawGLScene();
void resizeGLScene( int width, int height );
int main(int argc, char *argv[])
{
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
glutInitWindowSize( 400, 600 );
glutInitWindowPosition( 100, 200 );
glutCreateWindow( argv[0] );
initGL();
glutDisplayFunc( drawGLScene );
glutReshapeFunc( resizeGLScene );
glutMainLoop();
return 0;
}
void initGL()
{
glShadeModel( GL_SMOOTH );
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_EQUAL );
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
}
void drawGLScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
}
void resizeGLScene( int width, int height )
{
if ( height == 0 ) height = 1;
if ( width == 0 ) width = 1;
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective(
45.0,
(float)width / (float)height,
1.0,
10.0 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
}
and after a 'clean', it built and ran fine.
(Hmm.. Is that the correct way to set up a program using glut?)
My question is, exactly which library am I linking to?
Looking in /System/Library/Frameworks/OpenGL.framework, there's a Mach-O dylib named OpenGL, but also in a Libraries subdirectory, there's libGL.dylib and libGLU.dylib.
How can I tell which library (libGL.dylib or OpenGL) I'm linking to? (No ldd command here. :) )
Why is the file OpenGL named without the .dylib extension?
I made a small glut example program by:
-- using PB to create a Cocoa app,
-- added the GLUT and OpenGL frameworks to the project,
-- renamed main.m to main.c, wiped out what was in there:
#import <Cocoa/Cocoa.h>
int main(int argc, const char *argv[])
{
return NSApplicationMain(argc, argv);
}
and put in this:
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
void initGL();
void drawGLScene();
void resizeGLScene( int width, int height );
int main(int argc, char *argv[])
{
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
glutInitWindowSize( 400, 600 );
glutInitWindowPosition( 100, 200 );
glutCreateWindow( argv[0] );
initGL();
glutDisplayFunc( drawGLScene );
glutReshapeFunc( resizeGLScene );
glutMainLoop();
return 0;
}
void initGL()
{
glShadeModel( GL_SMOOTH );
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_EQUAL );
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
}
void drawGLScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
}
void resizeGLScene( int width, int height )
{
if ( height == 0 ) height = 1;
if ( width == 0 ) width = 1;
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective(
45.0,
(float)width / (float)height,
1.0,
10.0 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
}
and after a 'clean', it built and ran fine.
(Hmm.. Is that the correct way to set up a program using glut?)
My question is, exactly which library am I linking to?
Looking in /System/Library/Frameworks/OpenGL.framework, there's a Mach-O dylib named OpenGL, but also in a Libraries subdirectory, there's libGL.dylib and libGLU.dylib.
How can I tell which library (libGL.dylib or OpenGL) I'm linking to? (No ldd command here. :) )
Why is the file OpenGL named without the .dylib extension?