From 8f0ad277355a6b9283f3df562887a10d79bccfd7 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Mon, 11 Mar 2013 14:43:42 -0300 Subject: [PATCH] Minor SDL improvements --- modules/game_interface/gameinterface.lua | 1 + src/client/thingtype.cpp | 2 +- src/framework/core/graphicalapplication.h | 2 +- src/framework/graphics/ogl/textureogl.cpp | 4 +++- src/framework/platform/platformwindow.h | 4 ++-- src/framework/platform/sdlwindow.cpp | 16 +++++++++++++--- src/framework/platform/sdlwindow.h | 4 ++-- src/main.cpp | 2 ++ 8 files changed, 25 insertions(+), 10 deletions(-) diff --git a/modules/game_interface/gameinterface.lua b/modules/game_interface/gameinterface.lua index 55621a63..af07f214 100644 --- a/modules/game_interface/gameinterface.lua +++ b/modules/game_interface/gameinterface.lua @@ -238,6 +238,7 @@ end function tryLogout() if not g_game.isOnline() then exit() + return end if logoutWindow then diff --git a/src/client/thingtype.cpp b/src/client/thingtype.cpp index f8f69717..76f91671 100644 --- a/src/client/thingtype.cpp +++ b/src/client/thingtype.cpp @@ -284,7 +284,7 @@ const TexturePtr& ThingType::getTexture(int animationPhase) } } } - animationPhaseTexture = TexturePtr(new TextureOGL(fullImage, true)); + animationPhaseTexture = TexturePtr(new TextureOGL(fullImage)); animationPhaseTexture->setSmooth(true); } return animationPhaseTexture; diff --git a/src/framework/core/graphicalapplication.h b/src/framework/core/graphicalapplication.h index 73cbec49..7d0d9c2f 100644 --- a/src/framework/core/graphicalapplication.h +++ b/src/framework/core/graphicalapplication.h @@ -31,7 +31,7 @@ class GraphicalApplication : public Application { enum { - POLL_CYCLE_DELAY = 10 + POLL_CYCLE_DELAY = 1000 }; public: diff --git a/src/framework/graphics/ogl/textureogl.cpp b/src/framework/graphics/ogl/textureogl.cpp index f7717c45..905d38f6 100644 --- a/src/framework/graphics/ogl/textureogl.cpp +++ b/src/framework/graphics/ogl/textureogl.cpp @@ -223,5 +223,7 @@ void TextureOGL::setupPixels(int level, const Size& size, uchar* pixels, int cha format = GL_LUMINANCE; break; } - glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, size.width(), size.height(), 0, format, GL_UNSIGNED_BYTE, pixels); + GLenum internalFormat = GL_RGBA; + //TODO: compression support + glTexImage2D(GL_TEXTURE_2D, level, internalFormat, size.width(), size.height(), 0, format, GL_UNSIGNED_BYTE, pixels); } diff --git a/src/framework/platform/platformwindow.h b/src/framework/platform/platformwindow.h index cbf3c6da..63feed06 100644 --- a/src/framework/platform/platformwindow.h +++ b/src/framework/platform/platformwindow.h @@ -58,8 +58,8 @@ public: virtual void setMouseCursor(int cursorId) = 0; virtual void restoreMouseCursor() = 0; - virtual void showInputKeyboard() { } - virtual void hideInputKeyboard() { } + virtual void showTextInput() { } + virtual void hideTextInput() { } virtual void setTitle(const std::string& title) = 0; virtual void setMinimumSize(const Size& minimumSize) = 0; diff --git a/src/framework/platform/sdlwindow.cpp b/src/framework/platform/sdlwindow.cpp index 3afd36cf..fae70f13 100644 --- a/src/framework/platform/sdlwindow.cpp +++ b/src/framework/platform/sdlwindow.cpp @@ -43,6 +43,7 @@ void SDLWindow::init() SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); #ifdef OPENGL_ES + SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, OPENGL_ES); #endif @@ -150,12 +151,15 @@ void SDLWindow::poll() break; case SDL_WINDOWEVENT_MINIMIZED: m_maximized = false; + m_visible = false; break; case SDL_WINDOWEVENT_MAXIMIZED: m_maximized = true; + m_visible = true; break; case SDL_WINDOWEVENT_RESTORED: m_maximized = false; + m_visible = true; break; case SDL_WINDOWEVENT_FOCUS_GAINED: m_focused = true; @@ -163,6 +167,8 @@ void SDLWindow::poll() case SDL_WINDOWEVENT_FOCUS_LOST: m_focused = false; break; + case SDL_WINDOWEVENT_CLOSE: + break; } break; } @@ -171,6 +177,10 @@ void SDLWindow::poll() case SDL_KEYUP: break; case SDL_TEXTINPUT: + m_inputEvent.reset(Fw::KeyTextInputEvent); + m_inputEvent.keyText = event.text.text; + if(m_onInputEvent) + m_onInputEvent(m_inputEvent); break; case SDL_MOUSEMOTION: m_inputEvent.reset(); @@ -255,7 +265,7 @@ void SDLWindow::poll() m_inputEvent.type = Fw::MouseMoveInputEvent; m_inputEvent.mouseMoved = Point(event.tfinger.dx, event.tfinger.dy); m_inputEvent.mousePos = Point(event.tfinger.x, event.tfinger.y); - g_logger.info(stdext::format("motion %d %d", event.tfinger.x, event.tfinger.y)); + //g_logger.info(stdext::format("motion %d %d", event.tfinger.x, event.tfinger.y)); if(m_onInputEvent) m_onInputEvent(m_inputEvent); break; @@ -295,12 +305,12 @@ void SDLWindow::restoreMouseCursor() //TODO } -void SDLWindow::showInputKeyboard() +void SDLWindow::showTextInput() { SDL_StartTextInput(); } -void SDLWindow::hideInputKeyboard() +void SDLWindow::hideTextInput() { SDL_StopTextInput(); } diff --git a/src/framework/platform/sdlwindow.h b/src/framework/platform/sdlwindow.h index fa372373..4db36e30 100644 --- a/src/framework/platform/sdlwindow.h +++ b/src/framework/platform/sdlwindow.h @@ -48,8 +48,8 @@ public: void setMouseCursor(int cursorId); void restoreMouseCursor(); - void showInputKeyboard(); - void hideInputKeyboard(); + void showTextInput(); + void hideTextInput(); void setTitle(const std::string& title); void setMinimumSize(const Size& minimumSize); diff --git a/src/main.cpp b/src/main.cpp index 00a524f3..b65aac35 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -58,5 +58,7 @@ int main(int argc, char** argv) // terminate everything and free memory g_client.terminate(); g_app.terminate(); + + exit(0); return 0; }