# HG changeset patch # User Eris Caffee # Date 1367192160 18000 # Node ID 7ae4ee5c27f898374c66ea0b96bb3326de5f5191 # Parent c24af3462002063d20b2b335fceba715b57c1727 Corrected orientation and orbital speed of Moon diff -r c24af3462002 -r 7ae4ee5c27f8 CMakeLists.txt --- a/CMakeLists.txt Sat Apr 27 13:22:17 2013 -0500 +++ b/CMakeLists.txt Sun Apr 28 18:36:00 2013 -0500 @@ -117,7 +117,7 @@ # C -std=gnu99 -std=c99 if (CMAKE_COMPILER_IS_GNUCXX) - add_definitions(-pedantic -Wall -std=c++0x) + add_definitions(-Wall -std=c++0x) endif () diff -r c24af3462002 -r 7ae4ee5c27f8 src/solar-system.cpp --- a/src/solar-system.cpp Sat Apr 27 13:22:17 2013 -0500 +++ b/src/solar-system.cpp Sun Apr 28 18:36:00 2013 -0500 @@ -14,9 +14,13 @@ #include +#include + #include #include +//////////////////////////////////////////////////////////////////////////////// + GLShaderManager shaderManager; GLMatrixStack modelViewMatrix; GLMatrixStack projectionMatrix; @@ -29,17 +33,16 @@ int width = 800; int height = 600; -int fullscreen = 0; +int fullscreen = 1; -#define NUM_SPHERES 50 -GLFrame spheres[NUM_SPHERES]; +//////////////////////////////////////////////////////////////////////////////// GLTriangleBatch jupiterBatch; -GLTriangleBatch sphereBatch; GLTriangleBatch earthBatch; GLTriangleBatch moonBatch; GLTriangleBatch sunBatch; -GLBatch floorBatch; + +//////////////////////////////////////////////////////////////////////////////// #define TEX_EARTH 1 #define TEX_MOON 2 @@ -49,6 +52,11 @@ GLuint uiTextures[NUM_TEXTURES]; //////////////////////////////////////////////////////////////////////////////// + +const std::string Data_Dir("../textures/"); + +//////////////////////////////////////////////////////////////////////////////// + #define SCREENSHOT_FILENAME_BASE "screenshot-" #define SCREENSHOT_FILENAME_BASELEN 11 #define SCREENSHOT_FILENAME_EXT ".tga" @@ -148,7 +156,7 @@ float MoonRotSpeed = 1.0/29.5 * RotScale; float MoonAxialTilt = 6.7; - float MoonOrbitSpeed = 1.0/29.5 * RotScale; + float MoonOrbitSpeed = 1.0/(24*29.5) * RotScale; float MoonOrbitTilt = 5.145; static CStopWatch rotTimer; @@ -271,13 +279,15 @@ // orbit the Earth modelViewMatrix.Rotate(MoonOrbitTilt, 0.0f, 0.0f, 1.0f); + // NOrth is up! - modelViewMatrix.Rotate(-90.0f - MoonAxialTilt, 0.0f, 1.0f, 0.0f); + modelViewMatrix.Rotate(90.0f - MoonAxialTilt, -1.0f, 0.0f, 0.0f); + modelViewMatrix.Rotate(90.0f, 0.0f, 0.0f, 1.0f); float MoonRot = rotTimer.GetElapsedSeconds() * MoonOrbitSpeed * 10; - modelViewMatrix.Rotate(MoonRot, 0.0f, 1.0f, 0.0f); + modelViewMatrix.Rotate(MoonRot, 0.0f, 0.0f, 1.0f); - modelViewMatrix.Translate(0.5f, 0.0f, 0.0f); + modelViewMatrix.Translate(0.0f, 0.5f, 0.0f); glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_MOON]); @@ -347,17 +357,23 @@ glGenTextures(NUM_TEXTURES, uiTextures); + std::string f; + + f.assign(Data_Dir).append("earth.tga"); glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_EARTH]); - LoadTGATexture("../textures/earth.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); + LoadTGATexture(f.c_str(), GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); + f.assign(Data_Dir).append("moon.tga"); glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_MOON]); - LoadTGATexture("../textures/moon.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); + LoadTGATexture(f.c_str(), GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); + f.assign(Data_Dir).append("jupiter.tga"); glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_JUPITER]); - LoadTGATexture("../textures/jupiter.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); + LoadTGATexture(f.c_str(), GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); + f.assign(Data_Dir).append("sun.tga"); glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_SUN]); - LoadTGATexture("../textures/sun.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); + LoadTGATexture(f.c_str(), GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); static M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); @@ -522,7 +538,7 @@ glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL); glutInitWindowSize(800, 600); - glutCreateWindow("OpenGL SphereWorld"); + glutCreateWindow("OpenGL Solar System"); glutReshapeFunc(ChangeSize); glutDisplayFunc(RenderScene); @@ -552,6 +568,10 @@ SwapInterval(1); SetupRC(); + + glutFullScreen(); + fullscreen = 1; + glutMainLoop(); ShutDownRC(); diff -r c24af3462002 -r 7ae4ee5c27f8 textures/Marble.tga Binary file textures/Marble.tga has changed diff -r c24af3462002 -r 7ae4ee5c27f8 textures/Marslike.tga Binary file textures/Marslike.tga has changed diff -r c24af3462002 -r 7ae4ee5c27f8 textures/MoonLike.tga Binary file textures/MoonLike.tga has changed diff -r c24af3462002 -r 7ae4ee5c27f8 textures/marble.tga Binary file textures/marble.tga has changed