Mercurial > solar_system
changeset 3:4f8b47ac2715 md2-test
Aborted test of loading an MD2 model. The GLTools TriangleBatch class doesn't play nicely with MD2, as it erroneously marks vertices as duplicates of each other.
author | Eris Caffee <discordia@eldalin.com> |
---|---|
date | Sun, 28 Apr 2013 18:04:27 -0500 |
parents | c24af3462002 |
children | |
files | CMakeLists.txt src/solar-system.cpp textures/Marble.tga textures/Marslike.tga textures/MoonLike.tga textures/jupiter.md2 |
diffstat | 6 files changed, 482 insertions(+), 402 deletions(-) [+] |
line diff
1.1 --- a/CMakeLists.txt Sat Apr 27 13:22:17 2013 -0500 1.2 +++ b/CMakeLists.txt Sun Apr 28 18:04:27 2013 -0500 1.3 @@ -117,7 +117,7 @@ 1.4 # C -std=gnu99 -std=c99 1.5 1.6 if (CMAKE_COMPILER_IS_GNUCXX) 1.7 - add_definitions(-pedantic -Wall -std=c++0x) 1.8 + add_definitions( -Wall -std=c++0x) 1.9 endif () 1.10 1.11 1.12 @@ -135,11 +135,12 @@ 1.13 1.14 file (GLOB SRCS src/*.c src/*.cpp 1.15 /home/eris/gamedev/study/OpenGL_Superbible/work/Src/GLTools/src/* 1.16 + /home/eris/gamedev/projects/MD2/src/* 1.17 ) 1.18 file (GLOB HDRS include/*.h include/*.hpp 1.19 /home/eris/gamedev/study/OpenGL_Superbible/work/Src/GLTools/include/* 1.20 /home/eris/gamedev/study/OpenGL_Superbible/work/Src/GLTools/include/GL/* 1.21 - 1.22 + /home/eris/gamedev/projects/MD2/include/* 1.23 ) 1.24 1.25 # The directories that contain the libraries we will be linking against. 1.26 @@ -153,6 +154,7 @@ 1.27 ${CMAKE_SOURCE_DIR}/include 1.28 /home/eris/gamedev/study/OpenGL_Superbible/work/Src/GLTools/include/ 1.29 /home/eris/gamedev/study/OpenGL_Superbible/work/Src/GLTools/include/GL 1.30 + /home/eris/gamedev/projects/MD2/include 1.31 ) 1.32 1.33 # Define the executable program file we are creating. We must list all of
2.1 --- a/src/solar-system.cpp Sat Apr 27 13:22:17 2013 -0500 2.2 +++ b/src/solar-system.cpp Sun Apr 28 18:04:27 2013 -0500 2.3 @@ -14,9 +14,15 @@ 2.4 2.5 #include <dirent.h> 2.6 2.7 +#include <iostream> 2.8 + 2.9 #include <GL/glut.h> 2.10 #include <GL/glx.h> 2.11 2.12 +#include "MD2.h" 2.13 + 2.14 +//////////////////////////////////////////////////////////////////////////////// 2.15 + 2.16 GLShaderManager shaderManager; 2.17 GLMatrixStack modelViewMatrix; 2.18 GLMatrixStack projectionMatrix; 2.19 @@ -31,15 +37,14 @@ 2.20 int height = 600; 2.21 int fullscreen = 0; 2.22 2.23 -#define NUM_SPHERES 50 2.24 -GLFrame spheres[NUM_SPHERES]; 2.25 +//////////////////////////////////////////////////////////////////////////////// 2.26 2.27 GLTriangleBatch jupiterBatch; 2.28 -GLTriangleBatch sphereBatch; 2.29 GLTriangleBatch earthBatch; 2.30 GLTriangleBatch moonBatch; 2.31 GLTriangleBatch sunBatch; 2.32 -GLBatch floorBatch; 2.33 + 2.34 +//////////////////////////////////////////////////////////////////////////////// 2.35 2.36 #define TEX_EARTH 1 2.37 #define TEX_MOON 2 2.38 @@ -49,514 +54,587 @@ 2.39 GLuint uiTextures[NUM_TEXTURES]; 2.40 2.41 //////////////////////////////////////////////////////////////////////////////// 2.42 + 2.43 +const std::string Data_Dir("../textures/"); 2.44 + 2.45 +//////////////////////////////////////////////////////////////////////////////// 2.46 #define SCREENSHOT_FILENAME_BASE "screenshot-" 2.47 #define SCREENSHOT_FILENAME_BASELEN 11 2.48 #define SCREENSHOT_FILENAME_EXT ".tga" 2.49 #define SCREENSHOT_FILENAME_EXTLEN 4 2.50 2.51 int scandir_filter(const struct dirent * d) 2.52 - { 2.53 - if (memcmp(d->d_name, SCREENSHOT_FILENAME_BASE, 2.54 - SCREENSHOT_FILENAME_BASELEN) != 0) return 0; 2.55 - if (memcmp(d->d_name+SCREENSHOT_FILENAME_BASELEN+3, 2.56 - SCREENSHOT_FILENAME_EXT, SCREENSHOT_FILENAME_EXTLEN) != 0) 2.57 - return 0; 2.58 - if (isdigit(d->d_name[SCREENSHOT_FILENAME_BASELEN]) 2.59 - && isdigit(d->d_name[SCREENSHOT_FILENAME_BASELEN+1]) 2.60 - && isdigit(d->d_name[SCREENSHOT_FILENAME_BASELEN+2])) 2.61 - return 1; 2.62 - return 0; 2.63 - } 2.64 + { 2.65 + if (memcmp(d->d_name, SCREENSHOT_FILENAME_BASE, 2.66 + SCREENSHOT_FILENAME_BASELEN) != 0) return 0; 2.67 + if (memcmp(d->d_name+SCREENSHOT_FILENAME_BASELEN+3, 2.68 + SCREENSHOT_FILENAME_EXT, SCREENSHOT_FILENAME_EXTLEN) != 0) 2.69 + return 0; 2.70 + if (isdigit(d->d_name[SCREENSHOT_FILENAME_BASELEN]) 2.71 + && isdigit(d->d_name[SCREENSHOT_FILENAME_BASELEN+1]) 2.72 + && isdigit(d->d_name[SCREENSHOT_FILENAME_BASELEN+2])) 2.73 + return 1; 2.74 + return 0; 2.75 + } 2.76 2.77 2.78 int get_next_file_name(char * filename) 2.79 - { 2.80 - static int i = 0; 2.81 + { 2.82 + static int i = 0; 2.83 2.84 - if (i == 0) 2.85 - { 2.86 - char pattern[SCREENSHOT_FILENAME_BASELEN+3+SCREENSHOT_FILENAME_EXTLEN]; 2.87 - struct dirent ** file_list; 2.88 - int num_files = scandir(".", &file_list, scandir_filter, alphasort); 2.89 - if (num_files != 0) 2.90 - sprintf(pattern, "%s%%03d%s", SCREENSHOT_FILENAME_BASE, 2.91 - SCREENSHOT_FILENAME_EXT); 2.92 - sscanf(file_list[num_files-1]->d_name, pattern, &i); 2.93 - } 2.94 - i++; 2.95 + if (i == 0) 2.96 + { 2.97 + char pattern[SCREENSHOT_FILENAME_BASELEN+3+SCREENSHOT_FILENAME_EXTLEN]; 2.98 + struct dirent ** file_list; 2.99 + int num_files = scandir(".", &file_list, scandir_filter, alphasort); 2.100 + if (num_files != 0) 2.101 + sprintf(pattern, "%s%%03d%s", SCREENSHOT_FILENAME_BASE, 2.102 + SCREENSHOT_FILENAME_EXT); 2.103 + sscanf(file_list[num_files-1]->d_name, pattern, &i); 2.104 + } 2.105 + i++; 2.106 2.107 - sprintf(filename, "%s%03d%s", SCREENSHOT_FILENAME_BASE, i, 2.108 - SCREENSHOT_FILENAME_EXT); 2.109 - return i; 2.110 - } 2.111 + sprintf(filename, "%s%03d%s", SCREENSHOT_FILENAME_BASE, i, 2.112 + SCREENSHOT_FILENAME_EXT); 2.113 + return i; 2.114 + } 2.115 2.116 //////////////////////////////////////////////////////////////////////////////// 2.117 bool LoadTGATexture(const char * szFileName, GLenum minFilter, 2.118 - GLenum magFilter, GLenum wrapMode) 2.119 - { 2.120 - GLbyte * pBits; 2.121 - int nWidth, nHeight, nComponents; 2.122 - GLenum eFormat; 2.123 + GLenum magFilter, GLenum wrapMode) 2.124 + { 2.125 + GLbyte * pBits; 2.126 + int nWidth, nHeight, nComponents; 2.127 + GLenum eFormat; 2.128 2.129 - pBits = gltReadTGABits(szFileName, &nWidth, &nHeight, &nComponents, &eFormat); 2.130 - if (pBits == NULL) 2.131 - { 2.132 - fprintf(stderr, "Failed to load %s\n", szFileName); 2.133 - exit(EXIT_FAILURE); 2.134 - } 2.135 + pBits = gltReadTGABits(szFileName, &nWidth, &nHeight, &nComponents, &eFormat); 2.136 + if (pBits == NULL) 2.137 + { 2.138 + fprintf(stderr, "Failed to load %s\n", szFileName); 2.139 + exit(EXIT_FAILURE); 2.140 + } 2.141 2.142 - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapMode); 2.143 - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapMode); 2.144 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapMode); 2.145 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapMode); 2.146 2.147 - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter); 2.148 - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter); 2.149 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter); 2.150 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter); 2.151 2.152 - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 2.153 - glTexImage2D(GL_TEXTURE_2D, 0, nComponents, nWidth, nHeight, 0, 2.154 - eFormat, GL_UNSIGNED_BYTE, pBits); 2.155 + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 2.156 + glTexImage2D(GL_TEXTURE_2D, 0, nComponents, nWidth, nHeight, 0, 2.157 + eFormat, GL_UNSIGNED_BYTE, pBits); 2.158 2.159 - free(pBits); 2.160 + free(pBits); 2.161 2.162 - if (minFilter == GL_LINEAR_MIPMAP_LINEAR || 2.163 - minFilter == GL_LINEAR_MIPMAP_NEAREST || 2.164 - minFilter == GL_NEAREST_MIPMAP_LINEAR || 2.165 - minFilter == GL_NEAREST_MIPMAP_NEAREST) 2.166 - { 2.167 - glGenerateMipmap(GL_TEXTURE_2D); 2.168 - } 2.169 + if (minFilter == GL_LINEAR_MIPMAP_LINEAR || 2.170 + minFilter == GL_LINEAR_MIPMAP_NEAREST || 2.171 + minFilter == GL_NEAREST_MIPMAP_LINEAR || 2.172 + minFilter == GL_NEAREST_MIPMAP_NEAREST) 2.173 + { 2.174 + glGenerateMipmap(GL_TEXTURE_2D); 2.175 + } 2.176 2.177 - return true; 2.178 - } 2.179 + return true; 2.180 + } 2.181 2.182 //////////////////////////////////////////////////////////////////////////////// 2.183 void DrawSolarSystem(GLfloat yRot) 2.184 - { 2.185 - static GLfloat vWhite[] = { 1.0f, 1.0f, 1.0f, 1.0f }; 2.186 - static GLfloat vLightPos[] = { 0.0f, 0.0f, 0.0f, 1.0f }; 2.187 - static M3DVector3f vSunPos = { 0.0f, 0.0f, 0.0f }; 2.188 - static M3DVector3f vEarthPos = { 5.0f, 0.0f, 0.0f }; 2.189 - static M3DVector3f vJupiterPos = { 10.0f, 0.0f, 0.0f }; 2.190 + { 2.191 + static GLfloat vWhite[] = { 1.0f, 1.0f, 1.0f, 1.0f }; 2.192 + static GLfloat vLightPos[] = { 0.0f, 0.0f, 0.0f, 1.0f }; 2.193 + static M3DVector3f vSunPos = { 0.0f, 0.0f, 0.0f }; 2.194 + static M3DVector3f vEarthPos = { 5.0f, 0.0f, 0.0f }; 2.195 + static M3DVector3f vJupiterPos = { 10.0f, 0.0f, 0.0f }; 2.196 2.197 - float RotScale = 100.0; 2.198 - float SunRotSpeed = 1.0/(25*24) * RotScale; 2.199 + float RotScale = 100.0; 2.200 + float SunRotSpeed = 1.0/(25*24) * RotScale; 2.201 2.202 - float JupiterRotSpeed = 1.0/9 * RotScale; 2.203 - float JupiterAxialTilt = 3.13; 2.204 + float JupiterRotSpeed = 1.0/9 * RotScale; 2.205 + float JupiterAxialTilt = 3.13; 2.206 2.207 - float EarthRotSpeed = 1.0/24 * RotScale; 2.208 - float EarthAxialTilt = 23.5; 2.209 + float EarthRotSpeed = 1.0/24 * RotScale; 2.210 + float EarthAxialTilt = 23.5; 2.211 2.212 - float MoonRotSpeed = 1.0/29.5 * RotScale; 2.213 - float MoonAxialTilt = 6.7; 2.214 - float MoonOrbitSpeed = 1.0/29.5 * RotScale; 2.215 - float MoonOrbitTilt = 5.145; 2.216 + // float MoonRotSpeed = 1.0/29.5 * RotScale; 2.217 + float MoonAxialTilt = 6.7; 2.218 + float MoonOrbitSpeed = 1.0/(24*29.5) * RotScale; 2.219 + float MoonOrbitTilt = 5.145; 2.220 2.221 - static CStopWatch rotTimer; 2.222 + static CStopWatch rotTimer; 2.223 2.224 - // Get the light position in eye space 2.225 - M3DVector4f vLightTransformed; 2.226 - M3DMatrix44f mCamera; 2.227 - modelViewMatrix.GetMatrix(mCamera); 2.228 - m3dTransformVector4(vLightTransformed, vLightPos, mCamera); 2.229 + // Get the light position in eye space 2.230 + M3DVector4f vLightTransformed; 2.231 + M3DMatrix44f mCamera; 2.232 + modelViewMatrix.GetMatrix(mCamera); 2.233 + m3dTransformVector4(vLightTransformed, vLightPos, mCamera); 2.234 2.235 2.236 - //////////////////////////////// 2.237 - // Begin Sun 2.238 + //////////////////////////////// 2.239 + // Begin Sun 2.240 2.241 - float SunRot = rotTimer.GetElapsedSeconds() * SunRotSpeed; 2.242 + float SunRot = rotTimer.GetElapsedSeconds() * SunRotSpeed; 2.243 2.244 - modelViewMatrix.PushMatrix(); 2.245 + modelViewMatrix.PushMatrix(); 2.246 2.247 - modelViewMatrix.Translatev(vSunPos); 2.248 - // North is up! 2.249 - modelViewMatrix.Rotate(-90.0f, 1.0f, 0.0f, 0.0f); 2.250 - // Rotate on axis 2.251 - modelViewMatrix.Rotate(SunRot, 0.0f, 0.0f, 1.0f); 2.252 + modelViewMatrix.Translatev(vSunPos); 2.253 + // North is up! 2.254 + modelViewMatrix.Rotate(-90.0f, 1.0f, 0.0f, 0.0f); 2.255 + // Rotate on axis 2.256 + modelViewMatrix.Rotate(SunRot, 0.0f, 0.0f, 1.0f); 2.257 2.258 - glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_SUN]); 2.259 - if (polymode == GL_FILL) 2.260 - { 2.261 - shaderManager.UseStockShader(GLT_SHADER_TEXTURE_REPLACE, 2.262 - transformPipeline.GetModelViewProjectionMatrix(), 2.263 - 0); 2.264 - } 2.265 - else 2.266 - { 2.267 - shaderManager.UseStockShader(GLT_SHADER_FLAT, 2.268 - transformPipeline.GetModelViewProjectionMatrix(), 2.269 - vWhite); 2.270 - } 2.271 - sunBatch.Draw(); 2.272 - modelViewMatrix.PopMatrix(); 2.273 - // End Sun 2.274 - ///////////////////////////////// 2.275 + glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_SUN]); 2.276 + if (polymode == GL_FILL) 2.277 + { 2.278 + shaderManager.UseStockShader(GLT_SHADER_TEXTURE_REPLACE, 2.279 + transformPipeline.GetModelViewProjectionMatrix(), 2.280 + 0); 2.281 + } 2.282 + else 2.283 + { 2.284 + shaderManager.UseStockShader(GLT_SHADER_FLAT, 2.285 + transformPipeline.GetModelViewProjectionMatrix(), 2.286 + vWhite); 2.287 + } 2.288 + sunBatch.Draw(); 2.289 + modelViewMatrix.PopMatrix(); 2.290 + // End Sun 2.291 + ///////////////////////////////// 2.292 2.293 2.294 - //////////////////////////////// 2.295 - // Jupiter 2.296 - float JupiterRot = rotTimer.GetElapsedSeconds() * JupiterRotSpeed; 2.297 + //////////////////////////////// 2.298 + // Jupiter 2.299 + float JupiterRot = rotTimer.GetElapsedSeconds() * JupiterRotSpeed; 2.300 2.301 - modelViewMatrix.PushMatrix(); 2.302 - modelViewMatrix.Translatev(vJupiterPos); 2.303 - // North is up! 2.304 - modelViewMatrix.Rotate(-90.0f - JupiterAxialTilt, 1.0f, 0.0f, 0.0f); 2.305 - // Rotate on axis 2.306 - modelViewMatrix.Rotate(JupiterRot, 0.0f, 0.0f, 1.0f); 2.307 + modelViewMatrix.PushMatrix(); 2.308 + modelViewMatrix.Scale(1.0/1000, 1.0/1000, 1.0/1000); 2.309 + modelViewMatrix.Translatev(vJupiterPos); 2.310 + // North is up! 2.311 + modelViewMatrix.Rotate(-90.0f - JupiterAxialTilt, 1.0f, 0.0f, 0.0f); 2.312 + // Rotate on axis 2.313 + modelViewMatrix.Rotate(JupiterRot, 0.0f, 0.0f, 1.0f); 2.314 2.315 - glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_JUPITER]); 2.316 - if (polymode == GL_FILL) 2.317 - { 2.318 - // shaderManager.UseStockShader(GLT_SHADER_TEXTURE_REPLACE, 2.319 - // transformPipeline.GetModelViewProjectionMatrix(), 2.320 - // 0); 2.321 - shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, 2.322 - modelViewMatrix.GetMatrix(), 2.323 - transformPipeline.GetProjectionMatrix(), 2.324 - vLightTransformed, 2.325 - vWhite, 2.326 - 0); 2.327 - } 2.328 - else 2.329 - { 2.330 - shaderManager.UseStockShader(GLT_SHADER_FLAT, 2.331 - transformPipeline.GetModelViewProjectionMatrix(), 2.332 - vWhite); 2.333 + glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_JUPITER]); 2.334 + if (polymode == GL_FILL) 2.335 + { 2.336 + shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, 2.337 + modelViewMatrix.GetMatrix(), 2.338 + transformPipeline.GetProjectionMatrix(), 2.339 + vLightTransformed, 2.340 + vWhite, 2.341 + 0); 2.342 + } 2.343 + else 2.344 + { 2.345 + shaderManager.UseStockShader(GLT_SHADER_FLAT, 2.346 + transformPipeline.GetModelViewProjectionMatrix(), 2.347 + vWhite); 2.348 2.349 - } 2.350 - jupiterBatch.Draw(); 2.351 - modelViewMatrix.PopMatrix(); 2.352 - // End Jupiter 2.353 - //////////////////////////////// 2.354 + } 2.355 + jupiterBatch.Draw(); 2.356 + modelViewMatrix.PopMatrix(); 2.357 + // End Jupiter 2.358 + //////////////////////////////// 2.359 2.360 2.361 2.362 2.363 - ///////////////////////////////// 2.364 - // Begin Earth/Moon 2.365 + ///////////////////////////////// 2.366 + // Begin Earth/Moon 2.367 2.368 - // Begin Earth 2.369 - float EarthRot = rotTimer.GetElapsedSeconds() * EarthRotSpeed; 2.370 + // Begin Earth 2.371 + float EarthRot = rotTimer.GetElapsedSeconds() * EarthRotSpeed; 2.372 2.373 - modelViewMatrix.PushMatrix(); 2.374 - modelViewMatrix.Translatev(vEarthPos); 2.375 - modelViewMatrix.PushMatrix(); // Save unrotated matrix for when we do the Moon 2.376 + modelViewMatrix.PushMatrix(); 2.377 + modelViewMatrix.Translatev(vEarthPos); 2.378 + modelViewMatrix.PushMatrix(); // Save unrotated matrix for when we do the Moon 2.379 2.380 - // NOrth is up! 2.381 - modelViewMatrix.Rotate(-90.0f - EarthAxialTilt, 1.0f, 0.0f, 0.0f); 2.382 - // Rotate on the axis 2.383 - modelViewMatrix.Rotate(EarthRot, 0.0f, 0.0f, 1.0f); 2.384 + // NOrth is up! 2.385 + modelViewMatrix.Rotate(-90.0f - EarthAxialTilt, 1.0f, 0.0f, 0.0f); 2.386 + // Rotate on the axis 2.387 + modelViewMatrix.Rotate(EarthRot, 0.0f, 0.0f, 1.0f); 2.388 2.389 - if (polymode == GL_FILL) 2.390 - { 2.391 - glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_EARTH]); 2.392 - shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, 2.393 - modelViewMatrix.GetMatrix(), 2.394 - transformPipeline.GetProjectionMatrix(), 2.395 - vLightTransformed, 2.396 - vWhite, 2.397 - 0); 2.398 - } 2.399 - else 2.400 - { 2.401 - shaderManager.UseStockShader(GLT_SHADER_FLAT, 2.402 - transformPipeline.GetModelViewProjectionMatrix(), 2.403 - vWhite); 2.404 + if (polymode == GL_FILL) 2.405 + { 2.406 + glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_EARTH]); 2.407 + shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, 2.408 + modelViewMatrix.GetMatrix(), 2.409 + transformPipeline.GetProjectionMatrix(), 2.410 + vLightTransformed, 2.411 + vWhite, 2.412 + 0); 2.413 + } 2.414 + else 2.415 + { 2.416 + shaderManager.UseStockShader(GLT_SHADER_FLAT, 2.417 + transformPipeline.GetModelViewProjectionMatrix(), 2.418 + vWhite); 2.419 2.420 - } 2.421 - earthBatch.Draw(); 2.422 - modelViewMatrix.PopMatrix(); 2.423 + } 2.424 + earthBatch.Draw(); 2.425 + modelViewMatrix.PopMatrix(); 2.426 2.427 - // Begin Moon 2.428 + // Begin Moon 2.429 2.430 + 2.431 + // orbit the Earth 2.432 + modelViewMatrix.Rotate(MoonOrbitTilt, 0.0f, 0.0f, 1.0f); 2.433 2.434 - // orbit the Earth 2.435 - modelViewMatrix.Rotate(MoonOrbitTilt, 0.0f, 0.0f, 1.0f); 2.436 - // NOrth is up! 2.437 - modelViewMatrix.Rotate(-90.0f - MoonAxialTilt, 0.0f, 1.0f, 0.0f); 2.438 + // NOrth is up! 2.439 + modelViewMatrix.Rotate(90.0f - MoonAxialTilt, 1.0f, 0.0f, 0.0f); 2.440 + modelViewMatrix.Rotate(90.0f, 0.0f, 0.0f, 1.0f); 2.441 2.442 - float MoonRot = rotTimer.GetElapsedSeconds() * MoonOrbitSpeed * 10; 2.443 - modelViewMatrix.Rotate(MoonRot, 0.0f, 1.0f, 0.0f); 2.444 + float MoonRot = rotTimer.GetElapsedSeconds() * MoonOrbitSpeed ; 2.445 + modelViewMatrix.Rotate(MoonRot, 0.0f, 0.0f, -1.0f); 2.446 2.447 - modelViewMatrix.Translate(0.5f, 0.0f, 0.0f); 2.448 + modelViewMatrix.Translate(0.0f, 0.5f, 0.0f); 2.449 2.450 2.451 - glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_MOON]); 2.452 - if (polymode == GL_FILL) 2.453 - { 2.454 - shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, 2.455 - modelViewMatrix.GetMatrix(), 2.456 - transformPipeline.GetProjectionMatrix(), 2.457 - vLightTransformed, 2.458 - vWhite, 2.459 - 0); 2.460 - } 2.461 - else 2.462 - { 2.463 - shaderManager.UseStockShader(GLT_SHADER_FLAT, 2.464 - transformPipeline.GetModelViewProjectionMatrix(), 2.465 - vWhite); 2.466 - } 2.467 - moonBatch.Draw(); 2.468 - modelViewMatrix.PopMatrix(); 2.469 + glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_MOON]); 2.470 + if (polymode == GL_FILL) 2.471 + { 2.472 + shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, 2.473 + modelViewMatrix.GetMatrix(), 2.474 + transformPipeline.GetProjectionMatrix(), 2.475 + vLightTransformed, 2.476 + vWhite, 2.477 + 0); 2.478 + } 2.479 + else 2.480 + { 2.481 + shaderManager.UseStockShader(GLT_SHADER_FLAT, 2.482 + transformPipeline.GetModelViewProjectionMatrix(), 2.483 + vWhite); 2.484 + } 2.485 + moonBatch.Draw(); 2.486 + modelViewMatrix.PopMatrix(); 2.487 2.488 2.489 - modelViewMatrix.PopMatrix(); 2.490 - // End Earth/Moon 2.491 - //////////////////////////////// 2.492 + modelViewMatrix.PopMatrix(); 2.493 + // End Earth/Moon 2.494 + //////////////////////////////// 2.495 2.496 - } 2.497 + } 2.498 + 2.499 +//////////////////////////////////////////////////////////////////////////////// 2.500 +void load_md2(const std::string & file, GLTriangleBatch & batch) 2.501 + { 2.502 + std::string fpath(Data_Dir); 2.503 + fpath.append(file); 2.504 + 2.505 + MD2 model(fpath); 2.506 + if (! model.ok) 2.507 + { 2.508 + std::cerr << "Unable to load model " << fpath << std::endl; 2.509 + exit(EXIT_FAILURE); 2.510 + } 2.511 + 2.512 + batch.BeginMesh(model.header.num_verts); 2.513 + M3DVector3f verts[3]; 2.514 + M3DVector3f norms[3]; 2.515 + M3DVector2f tex_coords[3]; 2.516 + int vi = 0; 2.517 + for (std::vector<GL_Triangle>::iterator it = model.triangles.begin() ; it != model.triangles.end(); ++it) 2.518 + { 2.519 + 2.520 + for (int v=0; v<3; v++) 2.521 + for (int i=0; i<3; i++) 2.522 + verts[v][i] = model.frames[0].verts[ (*it).vert[v] ].coord[i]; 2.523 + 2.524 + for (int t=0; t<3; t++) 2.525 + for (int i=0; i<2; i++) 2.526 + tex_coords[t][i] = model.frames[0].verts[ (*it).tex[t] ].coord[i]; 2.527 + 2.528 + for (int v=0; v<3; v++) 2.529 + for (int i=0; i<3; i++) 2.530 + norms[v][i] = MD2::light_normals[ model.frames[0].verts[ (*it).vert[v] ].n ].coord[i]; 2.531 + 2.532 + // std::cout << "verts " ; 2.533 + // for (int v=0; v<3; v++) 2.534 + // { 2.535 + // for (int i=0; i<3; i++) 2.536 + // std::cout << verts[v][i] << " "; 2.537 + // std::cout << " "; 2.538 + // } 2.539 + // std::cout << std::endl; 2.540 + // std::cout << "norms " ; 2.541 + // for (int v=0; v<3; v++) 2.542 + // { 2.543 + // for (int i=0; i<3; i++) 2.544 + // std::cout << norms[v][i] << " "; 2.545 + // std::cout << " "; 2.546 + // } 2.547 + // std::cout << std::endl; 2.548 + 2.549 + batch.AddTriangle(verts, norms, tex_coords); 2.550 + } 2.551 + batch.End(); 2.552 + } 2.553 2.554 //////////////////////////////////////////////////////////////////////////////// 2.555 void RenderScene(void) 2.556 - { 2.557 - static CStopWatch rotTimer; 2.558 - float yRot = - rotTimer.GetElapsedSeconds() * 60.0f; 2.559 + { 2.560 + static CStopWatch rotTimer; 2.561 + float yRot = - rotTimer.GetElapsedSeconds() * 60.0f; 2.562 2.563 - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 2.564 + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 2.565 2.566 - // Begin Render 2.567 - modelViewMatrix.PushMatrix(); 2.568 + // Begin Render 2.569 + modelViewMatrix.PushMatrix(); 2.570 2.571 - // Begin Camera position 2.572 - static M3DMatrix44f mCamera; 2.573 - cameraFrame.GetCameraMatrix(mCamera); 2.574 - modelViewMatrix.MultMatrix(mCamera); 2.575 - // End Camera position 2.576 + // Begin Camera position 2.577 + static M3DMatrix44f mCamera; 2.578 + cameraFrame.GetCameraMatrix(mCamera); 2.579 + modelViewMatrix.MultMatrix(mCamera); 2.580 + // End Camera position 2.581 2.582 - DrawSolarSystem(yRot); 2.583 + DrawSolarSystem(yRot); 2.584 2.585 - // End Render 2.586 - modelViewMatrix.PopMatrix(); 2.587 + // End Render 2.588 + modelViewMatrix.PopMatrix(); 2.589 2.590 - glutSwapBuffers(); 2.591 - glutPostRedisplay(); 2.592 - } 2.593 + glutSwapBuffers(); 2.594 + glutPostRedisplay(); 2.595 + } 2.596 2.597 //////////////////////////////////////////////////////////////////////////////// 2.598 void SetupRC() 2.599 - { 2.600 - shaderManager.InitializeStockShaders(); 2.601 - glEnable(GL_DEPTH_TEST); 2.602 - glEnable(GL_CULL_FACE); 2.603 - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 2.604 + { 2.605 + shaderManager.InitializeStockShaders(); 2.606 + glEnable(GL_DEPTH_TEST); 2.607 + glEnable(GL_CULL_FACE); 2.608 + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 2.609 2.610 - gltMakeSphere(jupiterBatch, 0.5f, 128, 128 ); 2.611 - gltMakeSphere(earthBatch, 0.2f, 26, 26); 2.612 - gltMakeSphere(moonBatch, 0.1f, 26, 26); 2.613 - gltMakeSphere(sunBatch, 1.0f, 26, 26); 2.614 2.615 - glGenTextures(NUM_TEXTURES, uiTextures); 2.616 2.617 - glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_EARTH]); 2.618 - LoadTGATexture("../textures/earth.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); 2.619 + glGenTextures(NUM_TEXTURES, uiTextures); 2.620 2.621 - glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_MOON]); 2.622 - LoadTGATexture("../textures/moon.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); 2.623 + //////////////////////////////////////// 2.624 + // Earth 2.625 + gltMakeSphere(earthBatch, 0.2f, 26, 26); 2.626 + glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_EARTH]); 2.627 + LoadTGATexture("../textures/earth.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); 2.628 2.629 - glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_JUPITER]); 2.630 - LoadTGATexture("../textures/jupiter.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); 2.631 + //////////////////////////////////////// 2.632 + // Moon 2.633 + gltMakeSphere(moonBatch, 0.1f, 26, 26); 2.634 + glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_MOON]); 2.635 + LoadTGATexture("../textures/moon.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); 2.636 2.637 - glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_SUN]); 2.638 - LoadTGATexture("../textures/sun.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); 2.639 + //////////////////////////////////////// 2.640 + // Jupiter 2.641 + // gltMakeSphere(jupiterBatch, 0.5f, 128, 128 ); 2.642 + load_md2("jupiter.md2", jupiterBatch); 2.643 + glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_JUPITER]); 2.644 + std::string f(Data_Dir); 2.645 + f.append("jupiter.tga"); 2.646 + LoadTGATexture(f.c_str(), GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); 2.647 2.648 - static M3DMatrix44f mCamera; 2.649 - cameraFrame.GetCameraMatrix(mCamera); 2.650 - cameraFrame.MoveForward(-10.0); 2.651 -// cameraFrame.RotateWorld(15.0, 0.0f, 1.0f, 0.0f); 2.652 - } 2.653 + //////////////////////////////////////// 2.654 + // Sun 2.655 + gltMakeSphere(sunBatch, 1.0f, 26, 26); 2.656 + glBindTexture(GL_TEXTURE_2D, uiTextures[TEX_SUN]); 2.657 + LoadTGATexture("../textures/sun.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE); 2.658 + 2.659 + //////////////////////////////////////// 2.660 + // Camera 2.661 + static M3DMatrix44f mCamera; 2.662 + cameraFrame.GetCameraMatrix(mCamera); 2.663 + cameraFrame.MoveForward(-10.0); 2.664 + //cameraFrame.RotateWorld(15.0, 0.0f, 1.0f, 0.0f); 2.665 + } 2.666 2.667 //////////////////////////////////////////////////////////////////////////////// 2.668 void ShutDownRC(void) 2.669 - { 2.670 - glDeleteTextures(NUM_TEXTURES, uiTextures); 2.671 - } 2.672 + { 2.673 + glDeleteTextures(NUM_TEXTURES, uiTextures); 2.674 + } 2.675 2.676 //////////////////////////////////////////////////////////////////////////////// 2.677 void ChangeSize(int nWidth, int nHeight) 2.678 - { 2.679 - if (nHeight == 0) 2.680 - { 2.681 - nHeight = 1; 2.682 - } 2.683 - glViewport(0,0,nWidth, nHeight); 2.684 - viewFrustum.SetPerspective(35.0f, float(nWidth)/float(nHeight), 1.0f, 100.0f); 2.685 - projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix()); 2.686 - transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix); 2.687 - } 2.688 + { 2.689 + if (nHeight == 0) 2.690 + { 2.691 + nHeight = 1; 2.692 + } 2.693 + glViewport(0,0,nWidth, nHeight); 2.694 + viewFrustum.SetPerspective(35.0f, float(nWidth)/float(nHeight), 1.0f, 100.0f); 2.695 + projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix()); 2.696 + transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix); 2.697 + } 2.698 2.699 //////////////////////////////////////////////////////////////////////////////// 2.700 void SpecialKeys(int key, int x, int y) 2.701 - { 2.702 - } 2.703 + { 2.704 + } 2.705 2.706 //////////////////////////////////////////////////////////////////////////////// 2.707 void KeyboardFunc(unsigned char key, int x, int y) 2.708 - { 2.709 - static int changed; 2.710 - static float linear = 0.1f; 2.711 + { 2.712 + static int changed; 2.713 + static float linear = 0.1f; 2.714 2.715 - changed = 0; 2.716 + changed = 0; 2.717 2.718 - if ('w' == key) 2.719 - { 2.720 - cameraFrame.MoveForward(linear); 2.721 - changed = 1; 2.722 - } 2.723 - else if ('W' == key) 2.724 - { 2.725 - cameraFrame.MoveForward(10*linear); 2.726 - changed = 1; 2.727 - } 2.728 - else if ('s' == key) 2.729 - { 2.730 - cameraFrame.MoveForward(-linear); 2.731 - changed = 1; 2.732 - } 2.733 - else if ('S' == key) 2.734 - { 2.735 - cameraFrame.MoveForward(-10*linear); 2.736 - changed = 1; 2.737 - } 2.738 - else if ('a' == key) 2.739 - { 2.740 - cameraFrame.MoveRight(linear); 2.741 - changed = 1; 2.742 - } 2.743 - else if ('A' == key) 2.744 - { 2.745 - cameraFrame.MoveRight(10*linear); 2.746 - changed = 1; 2.747 - } 2.748 - else if ('d' == key) 2.749 - { 2.750 - cameraFrame.MoveRight(-linear); 2.751 - changed = 1; 2.752 - } 2.753 - else if ('D' == key) 2.754 - { 2.755 - cameraFrame.MoveRight(-10*linear); 2.756 - changed = 1; 2.757 - } 2.758 + if ('w' == key) 2.759 + { 2.760 + cameraFrame.MoveForward(linear); 2.761 + changed = 1; 2.762 + } 2.763 + else if ('W' == key) 2.764 + { 2.765 + cameraFrame.MoveForward(10*linear); 2.766 + changed = 1; 2.767 + } 2.768 + else if ('s' == key) 2.769 + { 2.770 + cameraFrame.MoveForward(-linear); 2.771 + changed = 1; 2.772 + } 2.773 + else if ('S' == key) 2.774 + { 2.775 + cameraFrame.MoveForward(-10*linear); 2.776 + changed = 1; 2.777 + } 2.778 + else if ('a' == key) 2.779 + { 2.780 + cameraFrame.MoveRight(linear); 2.781 + changed = 1; 2.782 + } 2.783 + else if ('A' == key) 2.784 + { 2.785 + cameraFrame.MoveRight(10*linear); 2.786 + changed = 1; 2.787 + } 2.788 + else if ('d' == key) 2.789 + { 2.790 + cameraFrame.MoveRight(-linear); 2.791 + changed = 1; 2.792 + } 2.793 + else if ('D' == key) 2.794 + { 2.795 + cameraFrame.MoveRight(-10*linear); 2.796 + changed = 1; 2.797 + } 2.798 2.799 - else if ('q' == key) 2.800 - { 2.801 - exit(0); 2.802 - } 2.803 - else if ('f' == key) 2.804 - { 2.805 - if (fullscreen) 2.806 - { 2.807 - glutReshapeWindow(width, height); 2.808 - fullscreen = 0; 2.809 - } 2.810 - else 2.811 - { 2.812 - width = glutGet(GLUT_WINDOW_WIDTH); 2.813 - height = glutGet(GLUT_WINDOW_HEIGHT); 2.814 - glutFullScreen(); 2.815 - fullscreen = 1; 2.816 - } 2.817 - } 2.818 - else if ('o' == key) 2.819 - { 2.820 - // 'o' for 'outline' - toggle wireframe rendering 2.821 - polymode = (polymode == GL_FILL) ? GL_LINE : GL_FILL; 2.822 - glPolygonMode(GL_FRONT_AND_BACK, polymode); 2.823 - } 2.824 - else if ('p' == key) 2.825 - { 2.826 - // 'p' for 'print screen' - save a screenshot 2.827 - char filename[20]; 2.828 - get_next_file_name(filename); 2.829 + else if ('q' == key) 2.830 + { 2.831 + exit(0); 2.832 + } 2.833 + else if ('f' == key) 2.834 + { 2.835 + if (fullscreen) 2.836 + { 2.837 + glutReshapeWindow(width, height); 2.838 + fullscreen = 0; 2.839 + } 2.840 + else 2.841 + { 2.842 + width = glutGet(GLUT_WINDOW_WIDTH); 2.843 + height = glutGet(GLUT_WINDOW_HEIGHT); 2.844 + glutFullScreen(); 2.845 + fullscreen = 1; 2.846 + } 2.847 + } 2.848 + else if ('o' == key) 2.849 + { 2.850 + // 'o' for 'outline' - toggle wireframe rendering 2.851 + polymode = (polymode == GL_FILL) ? GL_LINE : GL_FILL; 2.852 + glPolygonMode(GL_FRONT_AND_BACK, polymode); 2.853 + } 2.854 + else if ('p' == key) 2.855 + { 2.856 + // 'p' for 'print screen' - save a screenshot 2.857 + char filename[20]; 2.858 + get_next_file_name(filename); 2.859 2.860 - gltGrabScreenTGA(filename); 2.861 - } 2.862 + gltGrabScreenTGA(filename); 2.863 + } 2.864 2.865 - if (changed) 2.866 - { 2.867 - glutPostRedisplay(); 2.868 - } 2.869 - } 2.870 + if (changed) 2.871 + { 2.872 + glutPostRedisplay(); 2.873 + } 2.874 + } 2.875 2.876 //////////////////////////////////////////////////////////////////////////////// 2.877 void MouseMotionFunc (int x, int y) 2.878 - { 2.879 - static float angular = (float) m3dDegToRad(0.5f); 2.880 - static int xx = -1; 2.881 - static int yy = -1; 2.882 + { 2.883 + static float angular = (float) m3dDegToRad(0.5f); 2.884 + static int xx = -1; 2.885 + static int yy = -1; 2.886 2.887 - if (-1 == xx) 2.888 - { 2.889 - xx = x; 2.890 - yy = y; 2.891 - } 2.892 + if (-1 == xx) 2.893 + { 2.894 + xx = x; 2.895 + yy = y; 2.896 + } 2.897 2.898 - if ((0 == x) || (x < xx)) 2.899 - { 2.900 - cameraFrame.RotateWorld(angular, 0.0f, 1.0f, 0.0f); 2.901 - glutPostRedisplay(); 2.902 - } 2.903 - else if ((x == glutGet(GLUT_WINDOW_WIDTH) -1) || (x > xx)) 2.904 - { 2.905 - cameraFrame.RotateWorld(-angular, 0.0f, 1.0f, 0.0f); 2.906 - glutPostRedisplay(); 2.907 - } 2.908 - // Hmm. Need to transform normal vector, don't I? 2.909 - // if ((0 == y) || (y < yy)) 2.910 - // { 2.911 - // cameraFrame.RotateWorld(angular, 1.0f, 0.0f, 0.0f); 2.912 - // } 2.913 - // else if ((y == glutGet(GLUT_WINDOW_HEIGHT) -1) || (y > yy)) 2.914 - // { 2.915 - // cameraFrame.RotateWorld(-angular, 1.0f, 0.0f, 0.0f); 2.916 - // } 2.917 + if ((0 == x) || (x < xx)) 2.918 + { 2.919 + cameraFrame.RotateWorld(angular, 0.0f, 1.0f, 0.0f); 2.920 + glutPostRedisplay(); 2.921 + } 2.922 + else if ((x == glutGet(GLUT_WINDOW_WIDTH) -1) || (x > xx)) 2.923 + { 2.924 + cameraFrame.RotateWorld(-angular, 0.0f, 1.0f, 0.0f); 2.925 + glutPostRedisplay(); 2.926 + } 2.927 + // Hmm. Need to transform normal vector, don't I? 2.928 + // if ((0 == y) || (y < yy)) 2.929 + // { 2.930 + // cameraFrame.RotateWorld(angular, 1.0f, 0.0f, 0.0f); 2.931 + // } 2.932 + // else if ((y == glutGet(GLUT_WINDOW_HEIGHT) -1) || (y > yy)) 2.933 + // { 2.934 + // cameraFrame.RotateWorld(-angular, 1.0f, 0.0f, 0.0f); 2.935 + // } 2.936 2.937 - xx = x; 2.938 - yy = y; 2.939 - } 2.940 + xx = x; 2.941 + yy = y; 2.942 + } 2.943 2.944 //////////////////////////////////////////////////////////////////////////////// 2.945 int main (int argc, char * argv[]) 2.946 - { 2.947 - gltSetWorkingDirectory(argv[0]); 2.948 - glutInit(&argc, argv); 2.949 - glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL); 2.950 - glutInitWindowSize(800, 600); 2.951 - glutCreateWindow("OpenGL SphereWorld"); 2.952 + { 2.953 + gltSetWorkingDirectory(argv[0]); 2.954 + glutInit(&argc, argv); 2.955 + glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL); 2.956 + glutInitWindowSize(800, 600); 2.957 + glutCreateWindow("OpenGL Solar System"); 2.958 2.959 - glutReshapeFunc(ChangeSize); 2.960 - glutDisplayFunc(RenderScene); 2.961 - glutSpecialFunc(SpecialKeys); 2.962 - glutKeyboardFunc(KeyboardFunc); 2.963 - glutMotionFunc(MouseMotionFunc); 2.964 - glutPassiveMotionFunc(MouseMotionFunc); 2.965 - glutSetCursor(GLUT_CURSOR_NONE); 2.966 + glutReshapeFunc(ChangeSize); 2.967 + glutDisplayFunc(RenderScene); 2.968 + glutSpecialFunc(SpecialKeys); 2.969 + glutKeyboardFunc(KeyboardFunc); 2.970 + glutMotionFunc(MouseMotionFunc); 2.971 + glutPassiveMotionFunc(MouseMotionFunc); 2.972 + glutSetCursor(GLUT_CURSOR_NONE); 2.973 2.974 - GLenum err = glewInit(); 2.975 - if (GLEW_OK != err) 2.976 - { 2.977 - fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err)); 2.978 - return 1; 2.979 - } 2.980 + GLenum err = glewInit(); 2.981 + if (GLEW_OK != err) 2.982 + { 2.983 + fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err)); 2.984 + return 1; 2.985 + } 2.986 2.987 - // This enabled vertical sync on Linux 2.988 - // For full generality I should use Glew and check what OS I'm on. 2.989 - // Note that the ATI Catalyst driver exports the WGL_EXT_swap_control 2.990 - // extension name instead of SGI_swap_control as it should. 2.991 - // but nonetheless the actual function provided is glXSwapIntervalSGI 2.992 + // This enabled vertical sync on Linux 2.993 + // For full generality I should use Glew and check what OS I'm on. 2.994 + // Note that the ATI Catalyst driver exports the WGL_EXT_swap_control 2.995 + // extension name instead of SGI_swap_control as it should. 2.996 + // but nonetheless the actual function provided is glXSwapIntervalSGI 2.997 2.998 - PFNGLXSWAPINTERVALSGIPROC SwapInterval; 2.999 - SwapInterval = (PFNGLXSWAPINTERVALSGIPROC)glXGetProcAddress((const GLubyte*)"glXSwapIntervalSGI"); 2.1000 + PFNGLXSWAPINTERVALSGIPROC SwapInterval; 2.1001 + SwapInterval = (PFNGLXSWAPINTERVALSGIPROC)glXGetProcAddress((const GLubyte*)"glXSwapIntervalSGI"); 2.1002 2.1003 - if (SwapInterval) 2.1004 - SwapInterval(1); 2.1005 + if (SwapInterval) 2.1006 + SwapInterval(1); 2.1007 2.1008 - SetupRC(); 2.1009 - glutMainLoop(); 2.1010 - ShutDownRC(); 2.1011 + SetupRC(); 2.1012 + glutMainLoop(); 2.1013 + ShutDownRC(); 2.1014 2.1015 - return 0; 2.1016 - } 2.1017 + return 0; 2.1018 + } 2.1019 2.1020 2.1021
3.1 Binary file textures/Marble.tga has changed
4.1 Binary file textures/Marslike.tga has changed
5.1 Binary file textures/MoonLike.tga has changed
6.1 Binary file textures/jupiter.md2 has changed