diff src/solar-system.cpp @ 4:7ae4ee5c27f8

Corrected orientation and orbital speed of Moon
author Eris Caffee <discordia@eldalin.com>
date Sun, 28 Apr 2013 18:36:00 -0500
parents c24af3462002
children
line diff
     1.1 --- a/src/solar-system.cpp	Sat Apr 27 13:22:17 2013 -0500
     1.2 +++ b/src/solar-system.cpp	Sun Apr 28 18:36:00 2013 -0500
     1.3 @@ -14,9 +14,13 @@
     1.4  
     1.5  #include <dirent.h>
     1.6  
     1.7 +#include <string>
     1.8 +
     1.9  #include <GL/glut.h>
    1.10  #include <GL/glx.h>
    1.11  
    1.12 +////////////////////////////////////////////////////////////////////////////////
    1.13 +
    1.14  GLShaderManager		shaderManager;
    1.15  GLMatrixStack		modelViewMatrix;
    1.16  GLMatrixStack		projectionMatrix;
    1.17 @@ -29,17 +33,16 @@
    1.18  
    1.19  int			width = 800;
    1.20  int			height = 600;
    1.21 -int			fullscreen = 0;
    1.22 +int			fullscreen = 1;
    1.23  
    1.24 -#define NUM_SPHERES 50
    1.25 -GLFrame spheres[NUM_SPHERES];
    1.26 +////////////////////////////////////////////////////////////////////////////////
    1.27  
    1.28  GLTriangleBatch jupiterBatch;
    1.29 -GLTriangleBatch sphereBatch;
    1.30  GLTriangleBatch earthBatch;
    1.31  GLTriangleBatch moonBatch;
    1.32  GLTriangleBatch sunBatch;
    1.33 -GLBatch floorBatch;
    1.34 +
    1.35 +////////////////////////////////////////////////////////////////////////////////
    1.36  
    1.37  #define TEX_EARTH 1
    1.38  #define TEX_MOON 2
    1.39 @@ -49,6 +52,11 @@
    1.40  GLuint uiTextures[NUM_TEXTURES];
    1.41  
    1.42  ////////////////////////////////////////////////////////////////////////////////
    1.43 +
    1.44 +const std::string Data_Dir("../textures/");
    1.45 +
    1.46 +////////////////////////////////////////////////////////////////////////////////
    1.47 +
    1.48  #define SCREENSHOT_FILENAME_BASE "screenshot-"
    1.49  #define SCREENSHOT_FILENAME_BASELEN 11
    1.50  #define SCREENSHOT_FILENAME_EXT ".tga"
    1.51 @@ -148,7 +156,7 @@
    1.52  
    1.53     float MoonRotSpeed = 1.0/29.5 * RotScale;
    1.54     float MoonAxialTilt = 6.7;
    1.55 -   float MoonOrbitSpeed = 1.0/29.5 * RotScale;
    1.56 +   float MoonOrbitSpeed = 1.0/(24*29.5) * RotScale;
    1.57     float MoonOrbitTilt = 5.145;
    1.58  
    1.59     static CStopWatch rotTimer;
    1.60 @@ -271,13 +279,15 @@
    1.61  
    1.62     // orbit the Earth
    1.63     modelViewMatrix.Rotate(MoonOrbitTilt, 0.0f, 0.0f, 1.0f);
    1.64 +
    1.65     // NOrth is up!
    1.66 -   modelViewMatrix.Rotate(-90.0f - MoonAxialTilt, 0.0f, 1.0f, 0.0f);
    1.67 +    modelViewMatrix.Rotate(90.0f - MoonAxialTilt, -1.0f, 0.0f, 0.0f);
    1.68 +    modelViewMatrix.Rotate(90.0f, 0.0f, 0.0f, 1.0f);
    1.69  
    1.70     float MoonRot = rotTimer.GetElapsedSeconds() * MoonOrbitSpeed * 10;
    1.71 -   modelViewMatrix.Rotate(MoonRot, 0.0f, 1.0f, 0.0f);
    1.72 +   modelViewMatrix.Rotate(MoonRot, 0.0f, 0.0f, 1.0f);
    1.73  
    1.74 -   modelViewMatrix.Translate(0.5f, 0.0f, 0.0f);
    1.75 +   modelViewMatrix.Translate(0.0f, 0.5f, 0.0f);
    1.76  
    1.77  
    1.78     glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_MOON]);
    1.79 @@ -347,17 +357,23 @@
    1.80  
    1.81     glGenTextures(NUM_TEXTURES, uiTextures);
    1.82  
    1.83 +   std::string f;
    1.84 +
    1.85 +   f.assign(Data_Dir).append("earth.tga");
    1.86     glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_EARTH]);
    1.87 -   LoadTGATexture("../textures/earth.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE);
    1.88 +   LoadTGATexture(f.c_str(), GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE);
    1.89  
    1.90 +   f.assign(Data_Dir).append("moon.tga");
    1.91     glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_MOON]);
    1.92 -   LoadTGATexture("../textures/moon.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE);
    1.93 +   LoadTGATexture(f.c_str(), GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE);
    1.94  
    1.95 +   f.assign(Data_Dir).append("jupiter.tga");
    1.96     glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_JUPITER]);
    1.97 -   LoadTGATexture("../textures/jupiter.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE);
    1.98 +   LoadTGATexture(f.c_str(), GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE);
    1.99  
   1.100 +   f.assign(Data_Dir).append("sun.tga");
   1.101     glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_SUN]);
   1.102 -   LoadTGATexture("../textures/sun.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE);
   1.103 +   LoadTGATexture(f.c_str(), GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE);
   1.104  
   1.105     static M3DMatrix44f mCamera;
   1.106     cameraFrame.GetCameraMatrix(mCamera);
   1.107 @@ -522,7 +538,7 @@
   1.108     glutInit(&argc, argv);
   1.109     glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);
   1.110     glutInitWindowSize(800, 600);
   1.111 -   glutCreateWindow("OpenGL SphereWorld");
   1.112 +   glutCreateWindow("OpenGL Solar System");
   1.113  
   1.114     glutReshapeFunc(ChangeSize);
   1.115     glutDisplayFunc(RenderScene);
   1.116 @@ -552,6 +568,10 @@
   1.117        SwapInterval(1);
   1.118  
   1.119     SetupRC();
   1.120 +
   1.121 +   glutFullScreen();
   1.122 +   fullscreen = 1;
   1.123 +
   1.124     glutMainLoop();
   1.125     ShutDownRC();
   1.126