From bf6de9b9b09c385c736f5bb7df2eaefd8729162c Mon Sep 17 00:00:00 2001 From: Rtch90 <ritchie.cunningham@protonmail.com> Date: Mon, 9 Apr 2012 20:46:54 +0100 Subject: [PATCH] [Change] Moving to SDL instead of X11 and WINAPI --- src/Global/Constants.h | 4 ++++ src/Main/main.cpp | 23 +++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Global/Constants.h b/src/Global/Constants.h index 38ec842..e0d1ac1 100644 --- a/src/Global/Constants.h +++ b/src/Global/Constants.h @@ -5,3 +5,7 @@ const int WINDOW_WIDTH = 800; const int WINDOW_HEIGHT = 600; const int WINDOW_BPP = 16; const int WINDOW_FULLSCREEN = false; + +const SDL_VideoInfo* info = NULL; + +int flags = 0; diff --git a/src/Main/main.cpp b/src/Main/main.cpp index 4e8d0ae..19c3a7a 100644 --- a/src/Main/main.cpp +++ b/src/Main/main.cpp @@ -9,6 +9,8 @@ #include <windows.h> #endif +#include <SDL/SDL.h> +#include <GL/gl.h> #include "Game.h" #include "../Global/Globals.h" #include "../Global/Constants.h" @@ -30,13 +32,30 @@ int main(int argc, char** argv) { // Our game code. 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"); } else { + Destroy(); 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.."); SDL_WM_SetCaption("LibD", NULL);