summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpixel <pixel>2003-03-09 17:58:46 +0000
committerpixel <pixel>2003-03-09 17:58:46 +0000
commit55ac920fdd64668b453955c7708028a04d942b3e (patch)
tree83f011eddf44fac3e25e5911fa86530507a11442
parent3e0ecd83bcc10000600e997e4e60ca84aa20bb59 (diff)
Testing mouse
-rw-r--r--include/engine.h7
-rw-r--r--lib/engine.cc26
-rw-r--r--lib/sprite.cc2
3 files changed, 34 insertions, 1 deletions
diff --git a/include/engine.h b/include/engine.h
index cc78fc3..64e823d 100644
--- a/include/engine.h
+++ b/include/engine.h
@@ -18,12 +18,19 @@ namespace mogltk {
static void setcursorvisible(bool);
static bool getcursorvisible();
static bool quitrequested();
+ static int mouseX();
+ static int mouseY();
+ static int mousebuttons();
private:
static bool inited;
static bool postsetuped;
static bool appactive;
static bool cursorvisible;
static bool quitrequest;
+ static int mx;
+ static int my;
+ static int mbuttons;
+ static void updatemouse();
};
};
diff --git a/lib/engine.cc b/lib/engine.cc
index e012468..ed52d8c 100644
--- a/lib/engine.cc
+++ b/lib/engine.cc
@@ -4,6 +4,7 @@
bool mogltk::engine::inited = false, mogltk::engine::postsetuped = false;
bool mogltk::engine::appactive = false, mogltk::engine::cursorvisible = false, mogltk::engine::quitrequest = false;
+int mogltk::engine::mx, mogltk::engine::my, mogltk::engine::mbuttons;
int mogltk::engine::setup() throw(GeneralException) {
if (inited) {
@@ -111,20 +112,28 @@ void mogltk::engine::pollevents() {
while(true) {
if (hastoreturn)
- if (!SDL_PollEvent(NULL))
+ if (!SDL_PollEvent(NULL)) {
+ updatemouse();
return;
+ }
SDL_WaitEvent(&event);
switch(event.type) {
case SDL_ACTIVEEVENT:
switch (event.active.state) {
case SDL_APPMOUSEFOCUS:
printm(M_INFO, String("Application ") + (event.active.gain ? "gained" : "loosed") + " mouse focus\n");
+ if (cursorvisible)
+ hastoreturn = true;
break;
case SDL_APPINPUTFOCUS:
printm(M_INFO, String("Application ") + (event.active.gain ? "gained" : "loosed") + " input focus\n");
+ if (cursorvisible)
+ hastoreturn = true;
break;
case SDL_APPACTIVE:
printm(M_INFO, String("Application was ") + (event.active.gain ? "restored" : "iconified"));
+ if (cursorvisible)
+ hastoreturn = true;
break;
}
break;
@@ -173,3 +182,18 @@ bool mogltk::engine::quitrequested() {
return quitrequest;
}
+void mogltk::engine::updatemouse() {
+ mbuttons = SDL_GetMouseState(&mx, &my);
+}
+
+int mogltk::engine::mouseX() {
+ return mx;
+}
+
+int mogltk::engine::mouseY() {
+ return my;
+}
+
+int mogltk::engine::mousebuttons() {
+ return mbuttons;
+}
diff --git a/lib/sprite.cc b/lib/sprite.cc
index 26b57dd..fce982b 100644
--- a/lib/sprite.cc
+++ b/lib/sprite.cc
@@ -132,6 +132,8 @@ void mogltk::Sprite::draw(int dx, int dy, Color c) {
if (!was2D)
mogltk::glbase::Enter2DMode();
+
+ c.Bind();
tlist->Bind();
glBegin(GL_TRIANGLE_STRIP);