I recently created a thread asking whether or not to use GLUT to create a model of the solar system
Anyway, I now have the calculations and output drawn for all the objects, only I have an issue. I originally created my project through using a portion of canned code for the viewing area and - despite looking up minor tutorials on cameras and viewports - i lack an understanding of it.
I am reading this OpenGL Camera Tutorial, and though I have tried code like:
glMatrixMode(GL_PROJECTION); // Set projection parameters.
glLoadIdentity();
gluLookAt(0, 0, 100, /* look from camera XYZ */
0, 0, 0, /* look at the origin */
0, 1, 0); /* positive Y up vector */
I am getting blackness as an output. I require the camera being far away, as the scale of the models are up to 109 (due to the sun being scaled by the radius of the earth), and of course the scaled distances between the planets.
My question is how do I set up a camera with a distance that would incorporate all the units of that distance, while still maintaining visibility?
I’d really appreciate either a detailed explanation (that helps a bit better than the tutorial), a better tutorial, or even ideally a few snippets of code I could work off of to figure out how to use cameras and views (Not that I mean I wish to cheat my understanding, but I work better with reading code snippets and deciphering what it means myself than reading tutorials most of the time).
EDIT:
I forgot to also ask; how could I make the view not stretch or compress the models when the window is reshaped?
I currently use this function:
void computeLocation()
{
double x = 2 * cos(user_theta); // my x-, y-, and z-coordinates
double y = 2 * sin(user_theta);
double z = user_height;
double d = sqrt(x * x + y * y + z * z); // distance to origin
glMatrixMode(GL_PROJECTION); // Set projection parameters.
glLoadIdentity();
glFrustum(-d * 0.5, d * 0.5, -d * 0.5, d * 0.5, d - 1.1, d + 1.1);
gluLookAt(x, y, z, 0, 0, 0, 0, 0, 1);
}
The user_theta is from canned code and calculates the position of the camera for a slight angular movement
I think my issue revolves around my lack of understanding of glFrostum; but even the tutorials of that only confuse me. I’m not looking for in depth work with it, just as simplified as possible to make a camera.
I apologize for my ignorance, but I am a bit rushed now and so I am looking for the simplest method available