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

View File

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

View File

@ -11,6 +11,7 @@
#include <SDL/SDL.h> #include <SDL/SDL.h>
#include <GL/gl.h> #include <GL/gl.h>
#include <time.h>
#include "Game.h" #include "Game.h"
#include "../Global/Globals.h" #include "../Global/Globals.h"
#include "../Global/Constants.h" #include "../Global/Constants.h"
@ -32,6 +33,14 @@ int main(int argc, char** argv) {
// Our game code. // Our game code.
Game game; 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. // Setup OpenGL.
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_GREEN_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_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
if(SDL_Init(SDL_INIT_VIDEO) < 0) { flags = SDL_OPENGL | SDL_HWSURFACE;
Debug::logger->message("Error: Could not load SDL");
} else { screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32, flags);
Destroy(); Debug::logger->message("Video mode set..");
Debug::logger->message("SDL loaded..");
}
info = SDL_GetVideoInfo(); info = SDL_GetVideoInfo();
if(!info) { if(!info) {
// This should never accur. // This should never accur.
Debug::logger->message("Video query failed!"); Debug::logger->message("Video query failed!");
Destroy(); 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); SDL_WM_SetCaption("LibD", NULL);
srand((unsigned int)time(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 ----- Engine Initialization Complete -----");
Debug::logger->message("\n ----- Logic -----"); Debug::logger->message("\n ----- Logic -----");
game.Init();
bool isRunning = true; bool isRunning = true;
while(isRunning) { 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(); Destroy();