title: glaux substitute in mac
body: <p>I'm getting started with OpenGL. I need to do a project using glaux.h. My problem is that I'm running Mac OS X Lion, so I cannot use glaux. </p>
  
  <p>I was searching on the web and I found some codes that try to replace glaux. Codes were fine, but they use Windows Api variables. So obviously I can't use them. Here is the code that I need to read using glaux: </p>
  
  <pre><code>#include &lt;stdio.h&gt;          // Header File For Standard Input/Output
  #include &lt;stdlib.h&gt;
  #include &lt;GLUT/glut.h&gt;
  #include &lt;OpenGL/gl.h&gt;
  #include &lt;OpenGL/glu.h&gt;
  #include "bmp.h"
  #include &lt;string.h&gt;
  
  const int W_WIDTH = 500;    // PreselecciÛn del ancho de la ventana
  const int W_HEIGHT = 500;   // PreselecciÛn del alto de la ventana
  bool    keys[256];          // Array Used For The Keyboard Routine
  bool    active=1;       // Window Active Flag Set To TRUE By Default
  bool    fullscreen=TRUE;    // Fullscreen Flag Set To Fullscreen Mode By Default
  bool    fullscreen=0;   // Fullscreen Flag Set To Fullscreen Mode By Default
  GLuint  texture[1];         // Storage For 1 Texture
  GLuint  box;                // Storage For The Box Display List
  GLuint  top;                // Storage For The Top Display List
  GLuint  xloop;              // Loop For X Axis
  GLuint  yloop;              // Loop For Y Axis
  
  GLfloat xrot;               // Rotates Cube On The X Axis
  GLfloat yrot;               // Rotates Cube On The Y Axis
  
  static GLfloat boxcol[5][3]=
  {
  {1.0f,0.0f,0.0f},{1.0f,0.5f,0.0f},{1.0f,1.0f,0.0f},{0.0f,1.0f,0.0f},{0.0f,1.0f,1.0f}
  };
  
  static GLfloat topcol[5][3]=
  {
  {.5f,0.0f,0.0f},{0.5f,0.25f,0.0f},{0.5f,0.5f,0.0f},{0.0f,0.5f,0.0f},{0.0f,0.5f,0.5f}
  };
  
  LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);   // Declaration For WndProc
  
  // Build Cube Display Lists
  GLvoid BuildLists()
  {
  box=glGenLists(2);                                                    // Generate 2 Different Lists
  glNewList(box,GL_COMPILE);          // Start With The Box List
  glBegin(GL_QUADS);
  // Bottom Face
  glNormal3f( 0.0f,-1.0f, 0.0f);
  glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
  glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
  glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);
  glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);
  // Front Face
  glNormal3f( 0.0f, 0.0f, 1.0f);
  glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);
  glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);
  glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);
  glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);
  // Back Face
  glNormal3f( 0.0f, 0.0f,-1.0f);
  glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
  glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);
  glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);
  glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
  // Right face
  glNormal3f( 1.0f, 0.0f, 0.0f);
  glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
  glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);
  glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);
  glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);
  // Left Face
  glNormal3f(-1.0f, 0.0f, 0.0f);
  glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
  glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);
  glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);
  glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);
  glEnd();
  glEndList();
  top=box+1;                                          // Storage For "Top" Is "Box" Plus One
  glNewList(top,GL_COMPILE);                          // Now The "Top" Display List
  glBegin(GL_QUADS);
  // Top Face
  glNormal3f( 0.0f, 1.0f, 0.0f);
  glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);
  glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,  1.0f,  1.0f);
  glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,  1.0f,  1.0f);
  glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);
  glEnd();
  glEndList();
  }
  
  AUX_RGBImageRec *LoadBMP(char *Filename)    // Loads A Bitmap Image
  {
  FILE *File=NULL;                                            // File Handle
  
  if (!Filename)                                      // Make Sure A Filename Was Given
  {
      return NULL;                                    // If Not Return NULL
  }
  
  File=fopen(Filename,"r");                           // Check To See If The File Exists
  
  if (File)                                           // Does The File Exist?
  {
      fclose(File);                                   // Close The Handle
      return new AUX_RGBImageRec(Filename);               // Load The Bitmap And Return A Pointer
  }
  
  return NULL;                                        // If Load Failed Return NULL
  }
  
  int LoadGLTextures()        // Load Bitmaps And Convert To Textures
  {
  int Status=0;      // Status Indicator
  
  char ruta[100]="Data/Cube.bmp";
  
  AUX_RGBImageRec *TextureImage[1];   // Create Storage Space For The Texture
  
  memset(TextureImage,0,sizeof(void *)*1);            // Set The Pointer To NULL
  
  // Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
  if (TextureImage[0]==LoadBMP(ruta))
  {
      Status=1;                                   // Set The Status To TRUE
  
      glGenTextures(1, &amp;texture[0]);  // Create The Texture
  
      // Typical Texture Generation Using Data From The Bitmap
      glBindTexture(GL_TEXTURE_2D, texture[0]);
      glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]-&gt;sizeX, TextureImage[0]-&gt;sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]-&gt;data);
      glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
      glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
      }
  
  if (TextureImage[0])                                    // If Texture Exists
  {
      if (TextureImage[0]-&gt;data)                          // If Texture Image Exists
      {
          free(TextureImage[0]-&gt;data);                    // Free The Texture Image Memory
      }
  
      free(TextureImage[0]);                              // Free The Image Structure
  }
  
  return Status;                                      // Return The Status
  }
  
  GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
  {
  if (height==0)                                      // Prevent A Divide By Zero By
  {
      height=1;                                       // Making Height Equal One
  }
  
  glViewport(0,0,width,height);                       // Reset The Current Viewport
  
  glMatrixMode(GL_PROJECTION);                        // Select The Projection Matrix
  glLoadIdentity();               // Reset The Projection Matrix
  
  // Calculate The Aspect Ratio Of The Window
  gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
  
  glMatrixMode(GL_MODELVIEW);                         // Select The Modelview Matrix
  glLoadIdentity();               // Reset The Modelview Matrix
  }
  
  int InitGL()                // All Setup For OpenGL Goes Here
  {
  if (!LoadGLTextures())          // Jump To Texture Loading Routine
  {
      return 0;           // If Texture Didn't Load Return FALSE
  }
  BuildLists();           // Jump To The Code That Creates Our Display Lists
  
  glEnable(GL_TEXTURE_2D);            // Enable Texture Mapping
  glClearColor(0.0f, 0.0f, 0.0f, 0.5f);               // Black Background
  glClearDepth(1.0f);                 // Depth Buffer Setup
  glEnable(GL_DEPTH_TEST);            // Enables Depth Testing
  glEnable(GL_COLOR_MATERIAL);            // Enable Material Coloring
  return 1;                   // Initialization Went OK
  }
  
  void DrawGLScene()                  // Here's Where We Do All The Drawing
  {
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Clear The Screen And The DepthB 
  
  glBindTexture(GL_TEXTURE_2D, texture[0]);
  for (yloop=1;yloop&lt;6;yloop++)
  {
      for (xloop=0;xloop&lt;yloop;xloop++)
      {
          //Poner vuestro codigo no hace falta que se ve axactamente igual
      }
  }
  // Vacia los buffers de dibujo
  glutSwapBuffers();
  glFlush();
  
  }
  
  
  int main(int argc, char **argv) {
  
  glutInit(&amp;argc, argv);
  glutInitWindowPosition(100,100);
  glutInitWindowSize (W_WIDTH, W_HEIGHT);
  glutInitDisplayMode (GLUT_RGBA | GLUT_DOUBLE);
  glutCreateWindow("Ventana con el Visual C++ y glut");
  
  glutDisplayFunc(DrawGLScene);
  glutReshapeFunc(ReSizeGLScene);
  
  // Funciones de inicializacion
  InitGL();
  
  glutMainLoop();
  return 0;
  }
  </code></pre>