summaryrefslogtreecommitdiff
path: root/lib/glbase.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/glbase.cc')
-rw-r--r--lib/glbase.cc37
1 files changed, 10 insertions, 27 deletions
diff --git a/lib/glbase.cc b/lib/glbase.cc
index 86d0774..df093dd 100644
--- a/lib/glbase.cc
+++ b/lib/glbase.cc
@@ -8,26 +8,20 @@
#include "config.h"
#endif
-int mogltk::glbase::width, mogltk::glbase::height, mogltk::glbase::inited = 0, mogltk::glbase::twoD = 0;
-SDL_Surface * mogltk::glbase::surface = 0;
+mogltk::glbase::glbase(int w, int h, int flags) throw (GeneralException) : mogltk::base(w, h, flags, 0), twoD(0) {
+ SDL_Surface * surface;
-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))) {
+ if (!(surface = SDL_SetVideoMode(w, h, 0, flags | SDL_OPENGL))) {
throw GeneralException(String("Couldn't set GL mode: ") + SDL_GetError());
}
+
+ mogltk::engine::glbase_o = this;
+ mogltk::engine::base_o = this;
float ratio = surface->w;
ratio /= surface->h;
@@ -41,8 +35,6 @@ int mogltk::glbase::setup(int w, int h, int flags) throw(GeneralException) {
printm(M_INFO, String("Version : ") + (char *) glGetString(GL_VERSION) + "\n");
printm(M_INFO, String("Extensions: ") + (char *) glGetString(GL_EXTENSIONS) + "\n");
- inited = 1;
-
glViewport(0, 0, surface->w, surface->h);
glCullFace(GL_BACK);
@@ -67,23 +59,14 @@ int mogltk::glbase::setup(int w, int h, int flags) throw(GeneralException) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- SDL_ShowCursor(0);
SDL_GL_SwapBuffers();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- return 0;
-}
-
-int mogltk::glbase::GetWidth(void) {
- return width;
-}
-
-int mogltk::glbase::GetHeight(void) {
- return height;
+ setsurface(surface);
+ mogltk::engine::postsetup();
}
-int mogltk::glbase::GetInited(void) {
- return inited;
+mogltk::glbase::~glbase() {
}
void mogltk::glbase::Enter2DMode(void) {
@@ -99,7 +82,7 @@ void mogltk::glbase::Enter2DMode(void) {
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
- glOrtho(0.0, width, height, 0.0, 0.0, 1.0);
+ glOrtho(0.0, GetWidth(), GetHeight(), 0.0, 0.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();