// Lab1
//
// 9 January 2012
#include "stdafx.h"
#include "world.h"
int main(void)
{
// Initialize GLFW
if (glfwInit() != GL_TRUE)
return EXIT_FAILURE;
// Initialize main window
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); // Use OpenGL Core v3.2
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
if (glfwOpenWindow(1024, 768, 0, 0, 0, 0, 0, 0, GLFW_WINDOW) != GL_TRUE)
{
glfwTerminate();
return EXIT_FAILURE;
}
else if (glewInit() != GLEW_OK)
{
return EXIT_FAILURE;
}
glfwSetWindowTitle("Lab1");
glfwSetWindowPos(0, 0);
glfwDisable(GLFW_MOUSE_CURSOR);
// Prepare the world
World *game = new World();
static double time = glfwGetTime();
double now;
// Main loop
do
{
// Calculate time elapsed and update world
now = glfwGetTime();
game->Update(now - time);
time = now;
// Render!
glClear(GL_COLOR_BUFFER_BIT);
game->Render();
glfwSwapBuffers();
} while (!glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED));
// Destroy our world
delete game;
game = NULL;
// Close window and terminate GLFW
glfwCloseWindow();
glfwTerminate();
return EXIT_SUCCESS;
}