summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorpixel <pixel>2003-10-20 16:21:24 +0000
committerpixel <pixel>2003-10-20 16:21:24 +0000
commitd7575bef1e530eac004c973b0384a12561f0bb8b (patch)
tree9708064eeaa48be1dc4e871cc9aa0241ca32c15f /lib
parent5b14b34d6e11611fb395e3cffaf888bcca0f3661 (diff)
Commit of the month
Diffstat (limited to 'lib')
-rw-r--r--lib/base.cc2
-rw-r--r--lib/engine.cc22
-rw-r--r--lib/glbase.cc2
-rw-r--r--lib/glsprite.cc26
-rw-r--r--lib/sprite.cc4
5 files changed, 41 insertions, 15 deletions
diff --git a/lib/base.cc b/lib/base.cc
index 7891d50..49e883e 100644
--- a/lib/base.cc
+++ b/lib/base.cc
@@ -55,7 +55,7 @@ void mogltk::base::Flip() {
mogltk::base::base(int w, int h, int flags, int) : surface(0) {
width = w;
height = h;
-
+
SDL_ShowCursor(SDL_DISABLE);
}
diff --git a/lib/engine.cc b/lib/engine.cc
index 6792706..40426c1 100644
--- a/lib/engine.cc
+++ b/lib/engine.cc
@@ -10,7 +10,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::mx, mogltk::engine::my, mogltk::engine::mz = 0, mogltk::engine::mbuttons;
int mogltk::engine::frames, mogltk::engine::locked = 0;
double mogltk::engine::curfps = -1;
Uint32 mogltk::engine::curticks;
@@ -133,7 +133,7 @@ SDL_RWops * mogltk::engine::RWFromHandle(Handle * h) throw (GeneralException) {
return r;
}
-void mogltk::engine::pollevents() {
+void mogltk::engine::pollevents() throw (GeneralException) {
SDL_Event event;
bool hastoreturn = appactive;
@@ -158,7 +158,9 @@ void mogltk::engine::pollevents() {
updatemouse();
return;
}
- SDL_WaitEvent(&event);
+ if (!SDL_WaitEvent(&event)) {
+ throw GeneralException("Error polling for SDL Event");
+ }
switch(event.type) {
case SDL_ACTIVEEVENT:
switch (event.active.state) {
@@ -205,7 +207,15 @@ void mogltk::engine::pollevents() {
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);
+ printm(M_INFO, String().set("Mouse button %02x ", event.button.button) + String((event.button.state == SDL_PRESSED ? "pressed" : "released")) + " at (" + event.button.x + ", " + event.button.y + ")\n");
+ if (event.button.state == SDL_PRESSED) {
+ if (event.button.button == 4) {
+ mz--;
+ }
+ if (event.button.button == 5) {
+ mz++;
+ }
+ }
break;
case SDL_QUIT:
printm(M_INFO, "Quit requested\n");
@@ -254,6 +264,10 @@ int mogltk::engine::mouseY() {
return my;
}
+int mogltk::engine::mouseZ() {
+ return mz;
+}
+
int mogltk::engine::mousebuttons() {
return mbuttons;
}
diff --git a/lib/glbase.cc b/lib/glbase.cc
index 3808620..b6d41ef 100644
--- a/lib/glbase.cc
+++ b/lib/glbase.cc
@@ -60,6 +60,8 @@ mogltk::glbase::glbase(int w, int h, int flags) throw (GeneralException) : moglt
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_GL_SwapBuffers();
+ SDL_ShowCursor(SDL_DISABLE);
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
setsurface(surface);
diff --git a/lib/glsprite.cc b/lib/glsprite.cc
index 18df7eb..f60c3a2 100644
--- a/lib/glsprite.cc
+++ b/lib/glsprite.cc
@@ -14,28 +14,38 @@ mogltk::glSprite::glSprite(Uint8 * p, int asx, int asy) : Sprite(p, asx, asy) {
mogltk::glSprite::~glSprite() {
}
-void mogltk::glSprite::draw(int dx, int dy, ColorP c) {
+void mogltk::glSprite::draw(int dx, int dy, ColorP c, float sx, float sy) {
bool was2D;
- was2D = mogltk::engine::glbase_o->is2D();
-
- if (!was2D)
+ if (!(was2D = mogltk::engine::glbase_o->is2D()))
mogltk::engine::glbase_o->Enter2DMode();
c.Bind();
Bind();
glBegin(GL_TRIANGLE_STRIP);
- glTexCoord2i(GetPX() , GetPY() ); glVertex2i(dx , dy );
- glTexCoord2i(GetPX() + GetSX(), GetPY() ); glVertex2i(dx + GetSX(), dy );
- glTexCoord2i(GetPX() , GetPY() + GetSY()); glVertex2i(dx , dy + GetSY());
- glTexCoord2i(GetPX() + GetSX(), GetPY() + GetSY()); glVertex2i(dx + GetSX(), dy + GetSY());
+ glTexCoord2i(GetPX() , GetPY() ); glVertex2i(dx , dy );
+ glTexCoord2i(GetPX() + GetSX(), GetPY() ); glVertex2i(dx + GetSX() * sx, dy );
+ glTexCoord2i(GetPX() , GetPY() + GetSY()); glVertex2i(dx , dy + GetSY() * sy);
+ glTexCoord2i(GetPX() + GetSX(), GetPY() + GetSY()); glVertex2i(dx + GetSX() * sx, dy + GetSY() * sy);
glEnd();
if (!was2D)
mogltk::engine::glbase_o->Leave2DMode();
}
+void mogltk::glSprite::bindcorner(float fx, float fy) {
+ if (fx > 1)
+ fx = 1;
+ if (fy > 1)
+ fy = 1;
+ if (fx < 0)
+ fx = 0;
+ if (fy < 0)
+ fy = 0;
+ glTexCoord2i(GetPX() + fx * GetSX(), GetPY() + fy * GetSY());
+}
+
void mogltk::glSprite::drawrotate(int cx, int cy, double a, ColorP c) {
bool was2D;
diff --git a/lib/sprite.cc b/lib/sprite.cc
index 9c1a320..e62fb1b 100644
--- a/lib/sprite.cc
+++ b/lib/sprite.cc
@@ -127,9 +127,9 @@ bool mogltk::Sprite::canfit(int x1, int y1, int x2, int y2) const {
return false;
}
-void mogltk::Sprite::draw(int dx, int dy, ColorP c) {
+void mogltk::Sprite::draw(int dx, int dy, ColorP c, float sx, float sy) {
bool locked = false;
-
+
if (SDL_MUSTLOCK(mogltk::engine::base_o->getsurface())) {
locked = true;
SDL_LockSurface(mogltk::engine::base_o->getsurface());