From abddca4c8afa3d6b226033d0b2796cf46e85073f Mon Sep 17 00:00:00 2001 From: Tamir Atias Date: Mon, 9 Apr 2012 23:00:48 +0300 Subject: [PATCH] [Fix] Fixed some of Allanis' SDL initialisation errors. --- Bin/VC10/VC10.vcxproj | 3 +++ Bin/VC10/VC10.vcxproj.filters | 12 +++++++++++ src/Main/main.cpp | 40 ++++++++++++++++++++++++----------- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/Bin/VC10/VC10.vcxproj b/Bin/VC10/VC10.vcxproj index 16be18b..e055682 100644 --- a/Bin/VC10/VC10.vcxproj +++ b/Bin/VC10/VC10.vcxproj @@ -84,6 +84,8 @@ + + @@ -99,6 +101,7 @@ + diff --git a/Bin/VC10/VC10.vcxproj.filters b/Bin/VC10/VC10.vcxproj.filters index a41e568..f65ab46 100644 --- a/Bin/VC10/VC10.vcxproj.filters +++ b/Bin/VC10/VC10.vcxproj.filters @@ -25,6 +25,9 @@ {5b78104c-8316-4d75-8ad0-3f9a6bfbfde8} + + {cd864d04-89ef-4529-bce8-f693b304b504} + @@ -66,6 +69,12 @@ IO + + Global + + + Global + @@ -101,5 +110,8 @@ IO + + Global + \ No newline at end of file diff --git a/src/Main/main.cpp b/src/Main/main.cpp index 19c3a7a..8d9fe9c 100644 --- a/src/Main/main.cpp +++ b/src/Main/main.cpp @@ -11,6 +11,7 @@ #include #include +#include #include "Game.h" #include "../Global/Globals.h" #include "../Global/Constants.h" @@ -32,6 +33,14 @@ int main(int argc, char** argv) { // Our game code. Game game; + if(SDL_Init(SDL_INIT_VIDEO) < 0) { + Debug::logger->message("Error: Could not load SDL"); + Destroy(); + return 1; + } else { + Debug::logger->message("SDL loaded.."); + } + // Setup OpenGL. SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); @@ -39,25 +48,19 @@ int main(int argc, char** argv) { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - if(SDL_Init(SDL_INIT_VIDEO) < 0) { - Debug::logger->message("Error: Could not load SDL"); - } else { - Destroy(); - Debug::logger->message("SDL loaded.."); - } + flags = SDL_OPENGL | SDL_HWSURFACE; + + screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32, flags); + Debug::logger->message("Video mode set.."); info = SDL_GetVideoInfo(); if(!info) { // This should never accur. Debug::logger->message("Video query failed!"); Destroy(); + return 1; } - flags = SDL_OPENGL | SDL_HWSURFACE; - - screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32, flags); - Debug::logger->message("Video mode set.."); - SDL_WM_SetCaption("LibD", NULL); srand((unsigned int)time(NULL)); @@ -65,10 +68,23 @@ int main(int argc, char** argv) { Debug::logger->message("\n ----- Engine Initialization Complete -----"); Debug::logger->message("\n ----- Logic -----"); + game.Init(); + bool isRunning = true; while(isRunning) { - break; + SDL_Event ev; + while(SDL_PollEvent(&ev)){ + if(ev.type == SDL_QUIT) { + isRunning = false; + break; + } + } + + game.Render(); + SDL_GL_SwapBuffers(); } + + game.Shutdown(); Destroy();