OK, I got it chopped down to just a simple sphere, and the forum seems to allow it. This code displays the sphere in Windows, but not in OS X. Any ideas as to what I am missing?
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
// Windows
#include <GL/glut.h>
// OS X
//#include <GLUT/glut.h>
//#include <OpenGL/gl.h>
using namespace std;
#define PI 3.14159 // sin cosine cosine sin 3.14159!
static GLfloat white[] = {1.0,1.0,1.0,1.0};
int win = 0;
static GLfloat lpos1[] = {0.0,10.0,10.0,1.0};
static GLdouble cpos[3];
static GLdouble lookpos[3];
static float alpha = 2 * PI;
static float beta = PI/25.0;
static float camera_distance = 15;
static int ww, hh;
void draw()
{
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glColor3f(1.0,0.0,0.0);
glutSolidSphere(1,50,50);
}
bool init()
{
glClearColor(0.2,0.2,0.2,0.0);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glDepthRange( 0.0, 1.0);
lookpos[0] = 0.0;
lookpos[1] = 2.0;
lookpos[2] = 0.0;
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
glEnable(GL_LIGHTING);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glEnable(GL_LIGHT1);
return true;
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
cpos[0] = camera_distance * cos(beta) * sin(alpha);
cpos[1] = camera_distance * sin(beta);
cpos[2] = camera_distance * cos(beta) * cos(alpha);
gluLookAt(cpos[0],cpos[1],cpos[2], lookpos[0],lookpos[1],lookpos[2], 0.0,1.0,0.0);
//Draw light sphere*****************
glLightfv(GL_LIGHT1,GL_POSITION,lpos1);
glLightfv(GL_LIGHT1,GL_DIFFUSE, white);
glLightfv(GL_LIGHT1,GL_SPECULAR, white);
glPushMatrix();
draw();
glPopMatrix();
glFlush();
glutSwapBuffers();
}
void resize(int w, int h)
{
ww = w;
hh = h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, w, h);
gluPerspective(45.0f, 1.0f * w / h, 1.0f, -100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void keyboard(unsigned char key, int x, int y)
{
switch(key)
{
case 27 :
exit(1);
break;
}
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowPosition(50, 50);
glutInitWindowSize(800, 600);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
win = glutCreateWindow("test");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutReshapeFunc(resize);
if (!init())
return 1;
glutMainLoop();
return 0;
}