1. // Lab1
  2. //
  3. //  9 January 2012
  4.  
  5. #include "stdafx.h"
  6. #include "world.h"
  7.  
  8. int main(void)
  9. {
  10.     // Initialize GLFW
  11.     if (glfwInit() != GL_TRUE)
  12.         return EXIT_FAILURE;
  13.  
  14.     // Initialize main window
  15.     glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); // Use OpenGL Core v3.2
  16.     glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
  17.     glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  18.     if (glfwOpenWindow(1024, 768, 0, 0, 0, 0, 0, 0, GLFW_WINDOW) != GL_TRUE)
  19.     {
  20.         glfwTerminate();
  21.         return EXIT_FAILURE;
  22.     }
  23.     else if (glewInit() != GLEW_OK)
  24.     {
  25.         return EXIT_FAILURE;
  26.     }
  27.     glfwSetWindowTitle("Lab1");
  28.     glfwSetWindowPos(0, 0);
  29.     glfwDisable(GLFW_MOUSE_CURSOR);
  30.  
  31.     // Prepare the world
  32.     World *game = new World();
  33.     static double time = glfwGetTime();
  34.     double now;
  35.  
  36.     // Main loop
  37.     do
  38.     {
  39.         // Calculate time elapsed and update world
  40.         now = glfwGetTime();
  41.         game->Update(now - time);
  42.         time = now;
  43.  
  44.         // Render!
  45.         glClear(GL_COLOR_BUFFER_BIT);
  46.         game->Render();
  47.         glfwSwapBuffers();
  48.     } while (!glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED));
  49.  
  50.     // Destroy our world
  51.     delete game;
  52.     game = NULL;
  53.  
  54.     // Close window and terminate GLFW
  55.     glfwCloseWindow();
  56.     glfwTerminate();
  57.     return EXIT_SUCCESS;
  58. }