[Fix] Fixed some of Allanis' SDL initialisation errors.

This commit is contained in:
Tamir Atias 2012-04-09 23:00:48 +03:00
parent bf6de9b9b0
commit abddca4c8a
3 changed files with 43 additions and 12 deletions

View File

@ -84,6 +84,8 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\src\Actor\Player.h" />
<ClInclude Include="..\..\src\Global\Constants.h" />
<ClInclude Include="..\..\src\Global\Globals.h" />
<ClInclude Include="..\..\src\glx\glext.h" />
<ClInclude Include="..\..\src\glx\wglext.h" />
<ClInclude Include="..\..\src\IO\Input.h" />
@ -99,6 +101,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\Actor\Player.cpp" />
<ClCompile Include="..\..\src\Global\Globals.cpp" />
<ClCompile Include="..\..\src\IO\Input.cpp" />
<ClCompile Include="..\..\src\Main\Game.cpp" />
<ClCompile Include="..\..\src\Main\GLWindow.cpp" />

View File

@ -25,6 +25,9 @@
<Filter Include="IO">
<UniqueIdentifier>{5b78104c-8316-4d75-8ad0-3f9a6bfbfde8}</UniqueIdentifier>
</Filter>
<Filter Include="Global">
<UniqueIdentifier>{cd864d04-89ef-4529-bce8-f693b304b504}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\Main\GLWindow.h">
@ -66,6 +69,12 @@
<ClInclude Include="..\..\src\IO\Input.h">
<Filter>IO</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Global\Globals.h">
<Filter>Global</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Global\Constants.h">
<Filter>Global</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\Main\main.cpp">
@ -101,5 +110,8 @@
<ClCompile Include="..\..\src\IO\Input.cpp">
<Filter>IO</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Global\Globals.cpp">
<Filter>Global</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -11,6 +11,7 @@
#include <SDL/SDL.h>
#include <GL/gl.h>
#include <time.h>
#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();