[Change] Moving to SDL instead of X11 and WINAPI

This commit is contained in:
Rtch90 2012-04-09 20:46:54 +01:00
parent b7949795ae
commit bf6de9b9b0
2 changed files with 25 additions and 2 deletions

View File

@ -5,3 +5,7 @@ const int WINDOW_WIDTH = 800;
const int WINDOW_HEIGHT = 600; const int WINDOW_HEIGHT = 600;
const int WINDOW_BPP = 16; const int WINDOW_BPP = 16;
const int WINDOW_FULLSCREEN = false; const int WINDOW_FULLSCREEN = false;
const SDL_VideoInfo* info = NULL;
int flags = 0;

View File

@ -9,6 +9,8 @@
#include <windows.h> #include <windows.h>
#endif #endif
#include <SDL/SDL.h>
#include <GL/gl.h>
#include "Game.h" #include "Game.h"
#include "../Global/Globals.h" #include "../Global/Globals.h"
#include "../Global/Constants.h" #include "../Global/Constants.h"
@ -30,13 +32,30 @@ int main(int argc, char** argv) {
// Our game code. // Our game code.
Game game; Game game;
if(SDL_Init(SDL_INIT_VIDEO == -1)) { // Setup OpenGL.
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
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"); Debug::logger->message("Error: Could not load SDL");
} else { } else {
Destroy();
Debug::logger->message("SDL loaded.."); Debug::logger->message("SDL loaded..");
} }
screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32, SDL_HWSURFACE); info = SDL_GetVideoInfo();
if(!info) {
// This should never accur.
Debug::logger->message("Video query failed!");
Destroy();
}
flags = SDL_OPENGL | SDL_HWSURFACE;
screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32, flags);
Debug::logger->message("Video mode set.."); Debug::logger->message("Video mode set..");
SDL_WM_SetCaption("LibD", NULL); SDL_WM_SetCaption("LibD", NULL);