#include #include #include "base.h" #include "engine.h" #include "generic.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "gettext.h" mogltk::base::base(int w, int h, int flags) throw(GeneralException) : surface(0) { width = w; height = h; mogltk::engine::setup(); if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { throw GeneralException(String("Couldn't initialise Video SubSystem: ") + SDL_GetError()); } if (!(surface = SDL_SetVideoMode(width, height, 0, flags))) { throw GeneralException(String("Couldn't set GL mode: ") + SDL_GetError()); } mogltk::engine::base_o = this; float ratio = surface->w; ratio /= surface->h; printm(M_INFO, "Video resolution: %dx%dx%d (ratio = %3.2f)\n", surface->w, surface->h, surface->format->BitsPerPixel, ratio); SDL_ShowCursor(SDL_DISABLE); SDL_FillRect(surface, NULL, 0); SDL_Flip(surface); SDL_FillRect(surface, NULL, 0); mogltk::engine::postsetup(); } mogltk::base::~base() { } int mogltk::base::GetWidth(void) { return width; } int mogltk::base::GetHeight(void) { return height; } void mogltk::base::Flip() { printm(M_INFO, "Flipping\n"); mogltk::engine::pollevents(); SDL_Flip(surface); SDL_FillRect(surface, NULL, 0); } mogltk::base::base(int w, int h, int flags, int) : surface(0) { width = w; height = h; SDL_ShowCursor(SDL_DISABLE); } void mogltk::base::setsurface(SDL_Surface * _surface) throw (GeneralException) { if (surface) throw GeneralException("Can't set video surface twice"); surface = _surface; } SDL_Surface * mogltk::base::getsurface() { return surface; } void mogltk::base::Enter2DMode() { } void mogltk::base::Leave2DMode() { }