title: How to proper position skybox camera using openGL
body: <p>I created a skybox for my project and it looks the way I wanted it to; however, there are a few issues I cannot figure out how to fix and I have read some tutorials on this subject, but I was not able to find something that would help me.
  The first problem is that I don't know how to get the box to always move with my camera. In the image below you can see that I am able to zoom out and see the whole box, instead of only zooming in/out of the solar system and always having the stars on the background.</p>
  
  <p><img src="https://i.stack.imgur.com/AFoEy.jpg" alt="enter image description here"></p>
  
  <p>The other issue I have is that when I zoom in too close my background disappears.The picture below illustrates what I mean
  <img src="https://i.stack.imgur.com/ZE0Ml.jpg" alt="enter image description here"></p>
  
  <p>I know if I can get the camera working properly I can get this fixed, but it goes back to my first problem. I don't know how to access the camera info.</p>
  
  <p>I believe I would have to modify <code>glTranslatef()</code> and <code>glScalef()</code> in my code from a fixed number to a number that changes with the camera position. 
  Here is my code:</p>
  
  <pre><code>void Skybox::displaySkybox() 
  {
  
  Images::RGBImage test[6]; //6 pictures for 6 sides
  test[0]=Images::readImageFile(fileName); //Top
  //test[1]=Images::readImageFile(fileName);//Back
  //test[2]=Images::readImageFile(fileName);//Bottom
  //test[3]=Images::readImageFile(fileName);//Right
  //test[4]=Images::readImageFile(fileName); //Left
  //test[5]=Images::readImageFile(fileName);  //Front
  
  glEnable(GL_TEXTURE_2D);    
  
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
  test[0].glTexImage2D(GL_TEXTURE_2D,0,GL_RGB);
  
  // Save Current Matrix
  glPushMatrix();
  
  // Second Move the render space to the correct position (Translate)
  glTranslatef(0,0,0);
  
  // First apply scale matrix
  glScalef(10000,10000,10000);
  
   static const GLint faces[6][4] =
                  {
                  {5, 1, 2, 6}, // back
                  {5, 4, 0, 1}, // bottom
                  {0, 4, 7, 3}, // front
                  {4, 5, 6, 7}, // right ( 'left' in crinity's labeling )
                  {1, 0, 3, 2}, // left  ( 'right' in crinity's labeling )
                  {2, 3, 7, 6}  // top*/
                  };
  GLfloat v[8][3];
  GLint i;
  
  v[0][0] = v[1][0] = v[2][0] = v[3][0] = -1;  // min x
  v[4][0] = v[5][0] = v[6][0] = v[7][0] =  1;  // max x
  v[0][1] = v[1][1] = v[4][1] = v[5][1] = -1;  // min y
  v[2][1] = v[3][1] = v[6][1] = v[7][1] =  1;  // max y
  v[0][2] = v[3][2] = v[4][2] = v[7][2] = -1;  // min z
  v[1][2] = v[2][2] = v[5][2] = v[6][2] =  1;  // max z
  
  for (i = 0; i &lt; 7; i++) 
  {
      //
      glBegin(GL_QUADS);
  
      glTexCoord2f(0,1);  glVertex3fv(&amp;v[faces[i][0]][0]);
  glTexCoord2f(1,1);  glVertex3fv(&amp;v[faces[i][1]][0]);
  glTexCoord2f(1,0);  glVertex3fv(&amp;v[faces[i][2]][0]);
  glTexCoord2f(0,0);  glVertex3fv(&amp;v[faces[i][3]][0]);
  
      glEnd();
  }
  // Load Saved Matrix
  glPopMatrix();
  
  }
  </code></pre>
  
  <p>How can I get access to these variables? Does openGL alreay have a function that takes care of that? </p>