From ec510c6361cf39fe3d1cad02c77de887b9d70e7a Mon Sep 17 00:00:00 2001 From: Pixel Date: Mon, 4 Nov 2002 15:19:18 +0000 Subject: Working on mogltk --- mogltk/engine.cpp | 24 ++++++++++++++++++++++++ mogltk/glbase.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 mogltk/engine.cpp create mode 100644 mogltk/glbase.cpp (limited to 'mogltk') diff --git a/mogltk/engine.cpp b/mogltk/engine.cpp new file mode 100644 index 0000000..ff40514 --- /dev/null +++ b/mogltk/engine.cpp @@ -0,0 +1,24 @@ +#include +#include "engine.h" +#include "generic.h" + +int mogltk::engine::inited = 0; + +int mogltk::engine::setup() throw(GeneralException) { + if (inited) { + printm(M_WARNING, "mogltk::engine::startup() called twice, ignoring second call.\n"); + return -1; + } + if (SDL_Init(0) < 0) { + throw GeneralException("Unable to start SDL base system"); + } + atexit(SDL_Quit); + + inited = 1; + + return 0; +} + +int mogltk::engine::GetInited() { + return inited; +} diff --git a/mogltk/glbase.cpp b/mogltk/glbase.cpp new file mode 100644 index 0000000..71fcaa0 --- /dev/null +++ b/mogltk/glbase.cpp @@ -0,0 +1,51 @@ +#include "glbase.h" +#include "engine.h" +#include "generic.h" +#include +#include + +int mogltk::glbase::width, mogltk::glbase::height, mogltk::glbase::inited = 0; +SDL_Surface * mogltk::glbase::surface = 0; + +int mogltk::glbase::setup(int w, int h, int flags) throw(GeneralException) { + if (inited) { + printm(M_WARNING, "mogltk::glbase::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 | SDL_OPENGL))) { + throw GeneralException(String("Couldn't set GL mode: ") + SDL_GetError()); + } + + printm(M_INFO, "Video resolution: %dx%dx%d\n", surface->w, surface->h, surface->format->BitsPerPixel); + printm(M_INFO, "\n"); + printm(M_INFO, "OpenGL infos\n"); + printm(M_INFO, "------------\n"); + printm(M_INFO, String("Vendor : ") + (char *) glGetString(GL_VENDOR) + "\n"); + printm(M_INFO, String("Renderer : ") + (char *) glGetString(GL_RENDERER) + "\n"); + printm(M_INFO, String("Version : ") + (char *) glGetString(GL_VERSION) + "\n"); + printm(M_INFO, String("Extensions: ") + (char *) glGetString(GL_EXTENSIONS) + "\n"); + + inited = 1; + return 0; +} + +int mogltk::glbase::GetWidth(void) { + return width; +} + +int mogltk::glbase::GetHeight(void) { + return height; +} + +int mogltk::glbase::GetInited(void) { + return inited; +} -- cgit v1.2.3