diff options
author | pixel <pixel> | 2003-03-26 14:07:43 +0000 |
---|---|---|
committer | pixel <pixel> | 2003-03-26 14:07:43 +0000 |
commit | c00cd54ca5ed959cbccff7aa7261fb5025d1832c (patch) | |
tree | e706afd7029361a9f59882452a8ad2ecf2da0db6 /lib/base.cc | |
parent | a749e5e0f870dc2acde2de55cba2cd074d524442 (diff) |
bleh
Diffstat (limited to 'lib/base.cc')
-rw-r--r-- | lib/base.cc | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/lib/base.cc b/lib/base.cc new file mode 100644 index 0000000..049f53c --- /dev/null +++ b/lib/base.cc @@ -0,0 +1,77 @@ +#include <stdio.h> +#include <SDL.h> +#include "base.h" +#include "engine.h" +#include "generic.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include "gettext.h" + +int mogltk::base::setup(int w, int h, int flags) : surface(0) throw(GeneralException) { + if (inited) { + printm(M_WARNING, "mogltk::base::setup called twice, ignoring second call...\n"); + return -1; + } + + 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); + + inited = 1; + + SDL_ShowCursor(0); + SDL_FillRect(surface, NULL, 0); + SDL_SwapBuffers(); + SDL_FillRect(surface, NULL, 0); + mogltk::engine::postsetup(); +} + +int mogltk::base::GetWidth(void) { + return width; +} + +int mogltk::base::GetHeight(void) { + return height; +} + +int mogltk::base::GetInited(void) { + return inited; +} + +void mogltk::base::Flip() { + printm(M_INFO, "Flipping\n"); + mogltk::engine::pollevents(); + SDL_SwapBuffers(); + SDL_FillRect(surface, NULL, 0); +} + +int mogltk::base::setup(int w, int h, int flags) : surface(0) { + width = w; + height = h; + + inited = 1; + + SDL_ShowCursor(0); +} + +void mogltk::base::setsurface(SDL_Surface * _surface) throw (GeneralException) { + if (surface) + throw GeneralException("Can't set video surface twice"); + surface = _surface; +} |