Minor SDL improvements

This commit is contained in:
Eduardo Bart
2013-03-11 14:43:42 -03:00
parent d60413f7d6
commit 8f0ad27735
8 changed files with 25 additions and 10 deletions

View File

@@ -238,6 +238,7 @@ end
function tryLogout()
if not g_game.isOnline() then
exit()
return
end
if logoutWindow then

View File

@@ -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;

View File

@@ -31,7 +31,7 @@
class GraphicalApplication : public Application
{
enum {
POLL_CYCLE_DELAY = 10
POLL_CYCLE_DELAY = 1000
};
public:

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -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;
}