summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpixel <pixel>2003-05-20 01:53:24 +0000
committerpixel <pixel>2003-05-20 01:53:24 +0000
commite0f0cfd81fbec4fc20a591409f1bef67e16d62e7 (patch)
tree141b2742806249e1746d92b79b392022c95cfb2a
parente7595adabac15fd3a523327bf8c42655f989f9c2 (diff)
Bugfixes
-rw-r--r--include/engine.h7
-rw-r--r--include/shape.h4
-rw-r--r--lib/engine.cc25
-rw-r--r--lib/glshape.cc6
-rw-r--r--lib/shape.cc38
5 files changed, 80 insertions, 0 deletions
diff --git a/include/engine.h b/include/engine.h
index 66f2f3c..b39841d 100644
--- a/include/engine.h
+++ b/include/engine.h
@@ -10,6 +10,11 @@
namespace mogltk {
class engine : public Base {
public:
+ class keyevent : public Base {
+ public:
+ virtual void down(SDL_keysym);
+ virtual void up(SDL_keysym);
+ };
static int setup() throw(GeneralException);
static int postsetup() throw(GeneralException);
static int GetInited();
@@ -26,6 +31,7 @@ namespace mogltk {
static double FPS();
static void lockmouse();
static void unlockmouse();
+ static void setkeyevent(keyevent *);
static glbase * glbase_o;
static base * base_o;
private:
@@ -41,6 +47,7 @@ namespace mogltk {
static double curfps;
static Uint32 curticks;
static int locked;
+ static keyevent * keyevent_h;
static void updatemouse();
};
};
diff --git a/include/shape.h b/include/shape.h
index f107a00..58f4c07 100644
--- a/include/shape.h
+++ b/include/shape.h
@@ -32,6 +32,7 @@ namespace mogltk {
void walk(fillwalker *);
void swalk(segwalker *);
void insert(int, int, int, int);
+ void insertfix(int, int);
int GetMinX() const;
int GetMinY() const;
int GetMaxX() const;
@@ -52,6 +53,7 @@ namespace mogltk {
virtual ~sline();
int GetY() const;
void insert(int, int);
+ void insertfix(int, int);
void walk(fillwalker *);
private:
class point : public Base {
@@ -74,6 +76,8 @@ namespace mogltk {
protected:
point * pheader;
friend class point;
+ private:
+ int count() const;
};
int minX, minY, maxX, maxY;
texture * cached;
diff --git a/lib/engine.cc b/lib/engine.cc
index 036aa25..6792706 100644
--- a/lib/engine.cc
+++ b/lib/engine.cc
@@ -18,8 +18,18 @@ Uint32 mogltk::engine::curticks;
mogltk::glbase * mogltk::engine::glbase_o = 0;
mogltk::base * mogltk::engine::base_o = 0;
+mogltk::engine::keyevent * mogltk::engine::keyevent_h = 0;
+
#define UPDATERATE 1000
+void mogltk::engine::keyevent::up(SDL_keysym) {
+ printm(M_INFO, "Generic keyevent::up called\n");
+}
+
+void mogltk::engine::keyevent::down(SDL_keysym) {
+ printm(M_INFO, "Generic keyevent::down called\n");
+}
+
int mogltk::engine::setup() throw(GeneralException) {
if (inited) {
printm(M_WARNING, _("mogltk::engine::setup() called twice, ignoring second call.\n"));
@@ -175,6 +185,13 @@ void mogltk::engine::pollevents() {
printm(M_INFO, "SDL keysym: %i - Unicode: %04x = `%c`- modifiers: %04x\n", event.key.keysym.sym, event.key.keysym.unicode, event.key.keysym.unicode, event.key.keysym.mod);
if (event.key.keysym.sym == 27)
hastoreturn = quitrequest = true;
+ if (keyevent_h) {
+ if (event.key.state == SDL_PRESSED) {
+ keyevent_h->down(event.key.keysym);
+ } else {
+ keyevent_h->up(event.key.keysym);
+ }
+ }
break;
case SDL_MOUSEMOTION:
printm(M_INFO, "Mouse slept over the screen - (%i, %i)\n", event.motion.x, event.motion.y);
@@ -186,6 +203,10 @@ void mogltk::engine::pollevents() {
if (cursorvisible)
hastoreturn = true;
break;
+ case SDL_MOUSEBUTTONDOWN:
+ case SDL_MOUSEBUTTONUP:
+ printm(M_INFO, String("Mouse button %02x ") + (event.button.state == SDL_PRESSED ? "pressed" : "released") + " at (%i, %i)\n", event.button.button, event.button.x, event.button.y);
+ break;
case SDL_QUIT:
printm(M_INFO, "Quit requested\n");
hastoreturn = quitrequest = true;
@@ -249,3 +270,7 @@ void mogltk::engine::unlockmouse() {
locked = 0;
}
+void mogltk::engine::setkeyevent(keyevent * k) {
+ printm(M_INFO, "Setting up a new keyevent\n");
+ keyevent_h = k;
+}
diff --git a/lib/glshape.cc b/lib/glshape.cc
index 7662334..270279d 100644
--- a/lib/glshape.cc
+++ b/lib/glshape.cc
@@ -172,6 +172,9 @@ void mogltk::glshape::Leave(bool was2D) {
void mogltk::glshape::fdraw(fill * f, ColorP c, int sx, int sy) {
ENTERT;
+ if (!f)
+ return;
+
texture * t = f->GetTexture();
if (!t) {
@@ -200,6 +203,9 @@ void mogltk::glshape::fdraw(fill * f, ColorP c, int sx, int sy) {
void mogltk::glshape::sdraw(fill * f, ColorP c, int sx, int sy) {
ENTERT;
+ if (!f)
+ return;
+
texture * t = f->GetSTexture();
if (!t) {
diff --git a/lib/shape.cc b/lib/shape.cc
index fcca584..f566f3d 100644
--- a/lib/shape.cc
+++ b/lib/shape.cc
@@ -115,6 +115,13 @@ void mogltk::fill::insert(int x1, int y1, int x2, int y2) {
insert(x + i2, y);
}
+void mogltk::fill::insertfix(int x, int y) {
+ if (!header)
+ return;
+
+ header->insertfix(x, y);
+}
+
int mogltk::fill::GetMaxX() const {
return maxX;
}
@@ -217,6 +224,31 @@ void mogltk::fill::sline::insert(int ax, int ay) {
}
}
+void mogltk::fill::sline::insertfix(int ax, int ay) {
+ sline * f;
+
+ if (ay == y) {
+ if (count() & 1) {
+ insert(ax, ay);
+ }
+ } else {
+ f = header->header->look(ay);
+ if (!f)
+ return;
+
+ f->insertfix(ax, ay);
+ }
+}
+
+int mogltk::fill::sline::count() const {
+ int r = 0;
+
+ if (next)
+ r = next->count();
+
+ return r + 1;
+}
+
void mogltk::fill::sline::walk(fillwalker * w) {
if (pheader)
pheader->walk(w);
@@ -653,6 +685,8 @@ void mogltk::filldrawer::step(int x, int y) {
void mogltk::shape::fdraw(fill * f, ColorP c, int sx, int sy) {
ENTER;
+ if (!f)
+ return;
if (!f->GetTexture()) {
filldrawer * w = new filldrawer(f, f->Talloc(), c);
f->walk(w);
@@ -690,6 +724,10 @@ void mogltk::segdrawer::step(int x1, int y1, int x2, int y2) {
void mogltk::shape::sdraw(fill * f, ColorP c, int sx, int sy) {
ENTER;
+
+ if (!f)
+ return;
+
if (!f->GetSTexture()) {
segdrawer * w = new segdrawer(f, f->STalloc(), c);
f->swalk(w);