summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/glwidgets.h6
-rw-r--r--lib/engine.cc2
-rw-r--r--lib/glbase.cc9
-rw-r--r--lib/gltexture.cc6
-rw-r--r--lib/glwidgets.cc30
5 files changed, 49 insertions, 4 deletions
diff --git a/include/glwidgets.h b/include/glwidgets.h
index 3529fab..1894924 100644
--- a/include/glwidgets.h
+++ b/include/glwidgets.h
@@ -8,6 +8,12 @@ namespace mogltk {
public:
widget();
virtual ~widget();
+ protected:
+ widget(widget * father, int x, int y, int sx, int sy) throw (GeneralException);
+ private:
+ int x, y, sx, sy;
+ widget * father, * next, * prev, * child, * root;
+ static widget * cur_father;
};
};
diff --git a/lib/engine.cc b/lib/engine.cc
index c30b1d9..35c9971 100644
--- a/lib/engine.cc
+++ b/lib/engine.cc
@@ -170,6 +170,8 @@ void mogltk::engine::pollevents() {
case SDL_KEYUP:
printm(M_INFO, String("Key ") + event.key.keysym.scancode + " on keyboard " + event.key.which + (event.key.state == SDL_PRESSED ? " pressed" : " released") + "\n");
printm(M_INFO, "SDL keysym: %i - Unicode: %04x - modifiers: %04x\n", event.key.keysym.sym, event.key.keysym.unicode, event.key.keysym.mod);
+ if (event.key.keysym.sym == 27)
+ hastoreturn = quitrequest = true;
break;
case SDL_MOUSEMOTION:
printm(M_INFO, "Mouse slept over the screen - (%i, %i)\n", event.motion.x, event.motion.y);
diff --git a/lib/glbase.cc b/lib/glbase.cc
index 67b1b9c..3cdea12 100644
--- a/lib/glbase.cc
+++ b/lib/glbase.cc
@@ -25,7 +25,8 @@ int mogltk::glbase::setup(int w, int h, int flags) throw(GeneralException) {
throw GeneralException(String("Couldn't initialise Video SubSystem: ") + SDL_GetError());
}
- if (!(surface = SDL_SetVideoMode(width, height, 0, flags | SDL_OPENGL))) {
+ if (!(surface = SDL_SetVideoMode(width, height, 0, flags | SDL_OPENGL | SDL_FULLSCREEN))) {
+// if (!(surface = SDL_SetVideoMode(1024, 768, 0, flags | SDL_OPENGL))) {
throw GeneralException(String("Couldn't set GL mode: ") + SDL_GetError());
}
@@ -68,7 +69,8 @@ int mogltk::glbase::setup(int w, int h, int flags) throw(GeneralException) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_ShowCursor(0);
- Flip();
+ SDL_GL_SwapBuffers();
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
return 0;
}
@@ -122,9 +124,10 @@ void mogltk::glbase::Leave2DMode(void) {
}
void mogltk::glbase::Flip() {
+ printm(M_INFO, "Flipping\n");
+ mogltk::engine::pollevents();
SDL_GL_SwapBuffers();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- mogltk::engine::pollevents();
}
bool mogltk::glbase::is2D() {
diff --git a/lib/gltexture.cc b/lib/gltexture.cc
index 9b8f7e3..b0bc7c4 100644
--- a/lib/gltexture.cc
+++ b/lib/gltexture.cc
@@ -169,6 +169,7 @@ void mogltk::texture::Generate() {
glBindTexture(GL_TEXTURE_2D, tex);
+#if 0
if (planar) {
#ifdef DEBUG
printm(M_INFO, _("Generating planar texture: %i\n"), tex);
@@ -177,6 +178,7 @@ void mogltk::texture::Generate() {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels);
} else {
+#endif
#ifdef DEBUG
printm(M_INFO, _("Generating 3D texture: %i\n"), tex);
#endif
@@ -186,8 +188,10 @@ void mogltk::texture::Generate() {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, width, height, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels);
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels);
+#if 0
}
-
+#endif
+
texture_allocated = true;
tainted = false;
}
diff --git a/lib/glwidgets.cc b/lib/glwidgets.cc
index b381092..56b8e2f 100644
--- a/lib/glwidgets.cc
+++ b/lib/glwidgets.cc
@@ -3,8 +3,38 @@
#include "glfont.h"
#include "glwidgets.h"
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef _
+#define _(x) x
+#endif
+
mogltk::widget::widget() {
}
+mogltk::widget::widget(widget * _father, int _x, int _y, int _sx, int _sy) throw (GeneralException) :
+ x(_x), y(_y), sx(_sx), sy(_sy), father(_father) {
+ if (!father)
+ throw GeneralException(_("No father. Only root can be adam."));
+
+ next = father->child;
+ prev = 0;
+ father->child = this;
+ child = 0;
+ root = father->root;
+}
+
mogltk::widget::~widget() {
+ while(child)
+ delete child;
+
+ if (prev)
+ prev->next = next;
+ else if (father)
+ father->child = next;
+
+ if (next)
+ next->prev = prev;
}