
#include <GLUT/glut.h>
#include <OpenGL/gl.h>
//#include <stdlib.h>
#include <stdio.h>
//#include <string.h>

GLboolean doMulti = GL_TRUE;

static void init(void)
{
	glCullFace (GL_BACK);
	glEnable (GL_CULL_FACE);
//	glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);
	glClearColor (0.0, 0.0, 0.0, 0.0);
}

void display(void)
{
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glEnable (GL_DEPTH_TEST);

   if (doMulti)
   {
		glEnable(GL_MULTISAMPLE_ARB);
   }
   else
   {
		glDisable(GL_MULTISAMPLE_ARB);
   }

   glPushMatrix ();
      glTranslatef (0.0, -0.5, -6.0);    
      glRotatef (30.0, 1.0, 0.0, 0.0);
      glRotatef (60.0, 0.0, 1.0, 0.0); 
      glutWireSphere(0.5, 16, 16); // drawCube(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5);
      
      glTranslatef(0, 1, 0);
      glutWireTeapot(0.5);
   glPopMatrix ();

   glFlush ();
}

void reshape(int w, int h)
{
   glViewport(0, 0, (GLsizei) w, (GLsizei) h);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   gluPerspective(30.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
}

/* ARGSUSED1 */
void keyboard(unsigned char key, int x, int y)
{
   switch (key)
   {
      case 't':
      case 'T':
      case 'a':
      case 'A':
      case ' ':
         doMulti = !doMulti;
         glutPostRedisplay();
         break;
      case 27:
         exit(0);  /*  Escape key  */
         break;
      default:
         break;
   }
}

/*  Main Loop
 */
int main(int argc, char** argv)
{
   glutInit(&argc, argv);
   glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB 
                      | GLUT_ALPHA | GLUT_DEPTH | GLUT_MULTISAMPLE);
   glutInitWindowSize(800, 600);
   glutCreateWindow(argv[0]);
   init ();
   
   printf(glGetString(GL_EXTENSIONS));
   
   glutReshapeFunc (reshape);
   glutKeyboardFunc (keyboard);
   glutDisplayFunc (display);
   glutMainLoop();
   return 0;
}


