Solar System OpenGL v1.0.0
|
Main entry point for the Solar System simulation application. More...
#include <iostream>
#include <cmath>
#include <GL/glut.h>
#include "stb_image.h"
#include "textures.h"
#include "planet_radii.h"
#include "orbit_radii.h"
#include "planet_speeds.h"
#include "texture_loader.cpp"
#include "mouse_handler.cpp"
#include "keyboard_handler.cpp"
Macros | |
#define | GL_SILENCE_DEPRECATION |
Functions | |
void | printCommandMenu () |
Prints the command menu for user instructions. | |
void | init () |
Initializes OpenGL settings and loads textures. | |
void | drawTexturedSphere (GLuint texture, float radius) |
Draws a textured sphere with the given texture and radius. | |
void | drawOrbit (float radius) |
Draws an orbit with the given radius. | |
void | drawSun (bool withLighting) |
Draws the sun with optional lighting. | |
void | drawSaturnRing (float innerRadius, float outerRadius) |
Draws Saturn's rings. | |
void | drawPlanet (GLuint texture, float orbitRadius, float orbitSpeed, float planetRadius, const char *name, bool hasRing=false, float innerRingRadius=0.0f, float outerRingRadius=0.0f) |
Draws a planet with the specified parameters. | |
void | display () |
Displays the current frame. | |
void | reshape (int w, int h) |
Handles window resizing events. | |
void | update (int value) |
Updates the simulation state. | |
int | main (int argc, char **argv) |
Main entry point for the application. | |
Variables | |
GLuint | sunTexture |
GLuint | mercuryTexture |
GLuint | venusTexture |
GLuint | earthTexture |
GLuint | marsTexture |
GLuint | jupiterTexture |
GLuint | saturnTexture |
GLuint | saturnRingTexture |
GLuint | uranusTexture |
GLuint | neptuneTexture |
float | rotationAngle = 0.0 |
Main entry point for the Solar System simulation application.
This file contains the main function and the core rendering logic for the Solar System simulation, including initialization, drawing, and updating the scene. It also handles user input via keyboard and mouse.
#define GL_SILENCE_DEPRECATION |
void display | ( | ) |
Displays the current frame.
This function clears the color and depth buffers, sets up the camera view, and draws all celestial bodies based on the current state. It also handles the selection of individual planets or the entire solar system.
void drawOrbit | ( | float | radius | ) |
Draws an orbit with the given radius.
radius | The radius of the orbit. |
This function draws a circular orbit using line loops, representing the path on which a planet revolves around a star.
void drawPlanet | ( | GLuint | texture, |
float | orbitRadius, | ||
float | orbitSpeed, | ||
float | planetRadius, | ||
const char * | name, | ||
bool | hasRing = false, | ||
float | innerRingRadius = 0.0f, | ||
float | outerRingRadius = 0.0f ) |
Draws a planet with the specified parameters.
texture | The texture to apply to the planet. |
orbitRadius | The radius of the planet's orbit around the sun. |
orbitSpeed | The speed of the planet's orbit. |
planetRadius | The radius of the planet. |
name | The name of the planet (for logging purposes). |
hasRing | If true, a ring is drawn around the planet (default is false). |
innerRingRadius | The inner radius of the ring (default is 0.0f). |
outerRingRadius | The outer radius of the ring (default is 0.0f). |
This function draws a planet with the specified texture and radius, and optionally draws a ring around the planet if specified.
void drawSaturnRing | ( | float | innerRadius, |
float | outerRadius ) |
Draws Saturn's rings.
innerRadius | The inner radius of the rings. |
outerRadius | The outer radius of the rings. |
This function draws Saturn's rings as a series of textured disks. The transparency and spacing of the disks create the appearance of rings.
void drawSun | ( | bool | withLighting | ) |
Draws the sun with optional lighting.
withLighting | If true, lighting effects are enabled; otherwise, they are disabled. |
This function draws the sun using the sun texture. It also applies a rotation based on the current rotation angle. Lighting effects are applied if specified.
void drawTexturedSphere | ( | GLuint | texture, |
float | radius ) |
Draws a textured sphere with the given texture and radius.
texture | The texture to apply to the sphere. |
radius | The radius of the sphere. |
This function draws a textured sphere using the specified texture and radius, representing a celestial body.
void init | ( | ) |
Initializes OpenGL settings and loads textures.
This function sets up OpenGL settings, such as enabling texture mapping and depth testing. It also loads textures for all celestial bodies and prints the command menu.
int main | ( | int | argc, |
char ** | argv ) |
Main entry point for the application.
argc | The number of command-line arguments. |
argv | The command-line arguments. |
This function initializes GLUT, sets up the window, and registers callback functions for display, reshape, keyboard, and mouse events. It then enters the GLUT main loop.
void printCommandMenu | ( | ) |
Prints the command menu for user instructions.
This function prints a menu of commands to the console, providing users with information on how to control the simulation using keyboard and mouse inputs.
void reshape | ( | int | w, |
int | h ) |
Handles window resizing events.
w | The new width of the window. |
h | The new height of the window. |
This function adjusts the viewport and projection matrix when the window is resized to ensure the correct aspect ratio and perspective.
void update | ( | int | value | ) |
Updates the simulation state.
value | Unused parameter for timer function. |
This function updates the rotation angle for animation and schedules the next update call. It also checks if the simulation is paused or running.
GLuint earthTexture |
GLuint jupiterTexture |
GLuint marsTexture |
GLuint mercuryTexture |
GLuint neptuneTexture |
float rotationAngle = 0.0 |
GLuint saturnRingTexture |
GLuint saturnTexture |
GLuint sunTexture |
GLuint uranusTexture |
GLuint venusTexture |