diff options
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | include/engine.h | 6 | ||||
-rw-r--r-- | lib/engine.cc | 28 | ||||
-rw-r--r-- | lib/glbase.cc | 2 | ||||
-rw-r--r-- | lib/gltexture.cc | 10 |
5 files changed, 41 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac index ab76acb..e372c4d 100644 --- a/configure.ac +++ b/configure.ac @@ -38,7 +38,6 @@ AC_SEARCH_LIBS(gluPerspective, GLU, , [ LDFLAGS="-L/usr/X11R6/lib $LDFLAGS" AC_SEARCH_LIBS(gluPerspective, GLU, , AC_MSG_ERROR([can't find GLU])) ]) -AC_SEARCH_LIBS(IMG_Load_RW, SDL_image, , [AC_MSG_ERROR([can't find SDL_image])]) # Checks for header files. AC_FUNC_ALLOCA diff --git a/include/engine.h b/include/engine.h index d739bde..58ca46f 100644 --- a/include/engine.h +++ b/include/engine.h @@ -12,8 +12,14 @@ namespace mogltk { static int GetInited(); static SDL_RWops * RWFromHandle(Handle *) throw (GeneralException); static void pollevents(); + static void setappactive(bool); + static bool getappactive(); + static void setcursorvisible(bool); + static bool getcursorvisible(); private: static int inited; + static bool appactive; + static bool cursorvisible; }; }; diff --git a/lib/engine.cc b/lib/engine.cc index d065346..fac660e 100644 --- a/lib/engine.cc +++ b/lib/engine.cc @@ -3,6 +3,7 @@ #define _(x) x int mogltk::engine::inited = 0; +bool mogltk::engine::appactive = false, mogltk::engine::cursorvisible = false; int mogltk::engine::setup() throw(GeneralException) { if (inited) { @@ -14,8 +15,6 @@ int mogltk::engine::setup() throw(GeneralException) { } atexit(SDL_Quit); - SDL_ShowCursor(0); - inited = 1; return 0; @@ -92,15 +91,22 @@ SDL_RWops * mogltk::engine::RWFromHandle(Handle * h) throw (GeneralException) { void mogltk::engine::pollevents() { SDL_Event event; + bool hastoreturn = appactive; while(true) { + if (hastoreturn) + if (!SDL_PollEvent(NULL)) + return; SDL_WaitEvent(&event); switch(event.type) { case SDL_VIDEOEXPOSE: printm(M_INFO, "Needs to redraw\n"); - return; + hastoreturn = true; + break; case SDL_MOUSEMOTION: printm(M_INFO, "Mouse has gone over the screen - (%i, %i)\n", event.motion.x, event.motion.y); + if (cursorvisible) + hastoreturn = true; break; case SDL_QUIT: printm(M_INFO, "Quit requested\n"); @@ -125,3 +131,19 @@ void mogltk::engine::pollevents() { } } } + +void mogltk::engine::setappactive(bool p) { + appactive = p; +} + +bool mogltk::engine::getappactive() { + return appactive; +} + +void mogltk::engine::setcursorvisible(bool p) { + cursorvisible = p; +} + +bool mogltk::engine::getcursorvisible() { + return cursorvisible; +} diff --git a/lib/glbase.cc b/lib/glbase.cc index 346421f..5e9a74e 100644 --- a/lib/glbase.cc +++ b/lib/glbase.cc @@ -64,6 +64,8 @@ int mogltk::glbase::setup(int w, int h, int flags) throw(GeneralException) { glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + SDL_ShowCursor(0); Flip(); return 0; diff --git a/lib/gltexture.cc b/lib/gltexture.cc index 49a5157..76cfe5a 100644 --- a/lib/gltexture.cc +++ b/lib/gltexture.cc @@ -1,6 +1,5 @@ #include <sys/types.h> #include <SDL.h> -#include <SDL_image.h> #include <SDL_opengl.h> #include <generic.h> #include "gltexture.h" @@ -56,11 +55,16 @@ mogltk::texture::texture(Handle * h, bool plane) throw (GeneralException) : SDL_Surface * temp; +#if 0 if (!(temp = IMG_Load_RW(engine::RWFromHandle(h), 1))) throw GeneralException(_("Can't load image from Handle ") + h->GetName()); - + width = temp->w; height = temp->h; +#else + width = 256; + height = 256; +#endif if ((BITCOUNT(width) != 1) || (BITCOUNT(height) != 1)) { SDL_FreeSurface(temp); @@ -84,8 +88,10 @@ mogltk::texture::texture(Handle * h, bool plane) throw (GeneralException) : throw GeneralException(_("Can't create RGB Surface")); } +#if 0 SDL_BlitSurface(temp, 0, surface, 0); SDL_FreeSurface(temp); +#endif #ifdef TRACE_TEXTURES next = 0; |