mirror of
https://github.com/edubart/otclient.git
synced 2025-11-01 11:16:23 +01:00
Minor SDL improvements
This commit is contained in:
@@ -238,6 +238,7 @@ end
|
|||||||
function tryLogout()
|
function tryLogout()
|
||||||
if not g_game.isOnline() then
|
if not g_game.isOnline() then
|
||||||
exit()
|
exit()
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if logoutWindow then
|
if logoutWindow then
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ const TexturePtr& ThingType::getTexture(int animationPhase)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
animationPhaseTexture = TexturePtr(new TextureOGL(fullImage, true));
|
animationPhaseTexture = TexturePtr(new TextureOGL(fullImage));
|
||||||
animationPhaseTexture->setSmooth(true);
|
animationPhaseTexture->setSmooth(true);
|
||||||
}
|
}
|
||||||
return animationPhaseTexture;
|
return animationPhaseTexture;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
class GraphicalApplication : public Application
|
class GraphicalApplication : public Application
|
||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
POLL_CYCLE_DELAY = 10
|
POLL_CYCLE_DELAY = 1000
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -223,5 +223,7 @@ void TextureOGL::setupPixels(int level, const Size& size, uchar* pixels, int cha
|
|||||||
format = GL_LUMINANCE;
|
format = GL_LUMINANCE;
|
||||||
break;
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ public:
|
|||||||
virtual void setMouseCursor(int cursorId) = 0;
|
virtual void setMouseCursor(int cursorId) = 0;
|
||||||
virtual void restoreMouseCursor() = 0;
|
virtual void restoreMouseCursor() = 0;
|
||||||
|
|
||||||
virtual void showInputKeyboard() { }
|
virtual void showTextInput() { }
|
||||||
virtual void hideInputKeyboard() { }
|
virtual void hideTextInput() { }
|
||||||
|
|
||||||
virtual void setTitle(const std::string& title) = 0;
|
virtual void setTitle(const std::string& title) = 0;
|
||||||
virtual void setMinimumSize(const Size& minimumSize) = 0;
|
virtual void setMinimumSize(const Size& minimumSize) = 0;
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ void SDLWindow::init()
|
|||||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
|
||||||
|
|
||||||
#ifdef OPENGL_ES
|
#ifdef OPENGL_ES
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 16);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, OPENGL_ES);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, OPENGL_ES);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -150,12 +151,15 @@ void SDLWindow::poll()
|
|||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_MINIMIZED:
|
case SDL_WINDOWEVENT_MINIMIZED:
|
||||||
m_maximized = false;
|
m_maximized = false;
|
||||||
|
m_visible = false;
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||||
m_maximized = true;
|
m_maximized = true;
|
||||||
|
m_visible = true;
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_RESTORED:
|
case SDL_WINDOWEVENT_RESTORED:
|
||||||
m_maximized = false;
|
m_maximized = false;
|
||||||
|
m_visible = true;
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||||
m_focused = true;
|
m_focused = true;
|
||||||
@@ -163,6 +167,8 @@ void SDLWindow::poll()
|
|||||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||||
m_focused = false;
|
m_focused = false;
|
||||||
break;
|
break;
|
||||||
|
case SDL_WINDOWEVENT_CLOSE:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -171,6 +177,10 @@ void SDLWindow::poll()
|
|||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
break;
|
break;
|
||||||
case SDL_TEXTINPUT:
|
case SDL_TEXTINPUT:
|
||||||
|
m_inputEvent.reset(Fw::KeyTextInputEvent);
|
||||||
|
m_inputEvent.keyText = event.text.text;
|
||||||
|
if(m_onInputEvent)
|
||||||
|
m_onInputEvent(m_inputEvent);
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
m_inputEvent.reset();
|
m_inputEvent.reset();
|
||||||
@@ -255,7 +265,7 @@ void SDLWindow::poll()
|
|||||||
m_inputEvent.type = Fw::MouseMoveInputEvent;
|
m_inputEvent.type = Fw::MouseMoveInputEvent;
|
||||||
m_inputEvent.mouseMoved = Point(event.tfinger.dx, event.tfinger.dy);
|
m_inputEvent.mouseMoved = Point(event.tfinger.dx, event.tfinger.dy);
|
||||||
m_inputEvent.mousePos = Point(event.tfinger.x, event.tfinger.y);
|
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)
|
if(m_onInputEvent)
|
||||||
m_onInputEvent(m_inputEvent);
|
m_onInputEvent(m_inputEvent);
|
||||||
break;
|
break;
|
||||||
@@ -295,12 +305,12 @@ void SDLWindow::restoreMouseCursor()
|
|||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLWindow::showInputKeyboard()
|
void SDLWindow::showTextInput()
|
||||||
{
|
{
|
||||||
SDL_StartTextInput();
|
SDL_StartTextInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLWindow::hideInputKeyboard()
|
void SDLWindow::hideTextInput()
|
||||||
{
|
{
|
||||||
SDL_StopTextInput();
|
SDL_StopTextInput();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ public:
|
|||||||
void setMouseCursor(int cursorId);
|
void setMouseCursor(int cursorId);
|
||||||
void restoreMouseCursor();
|
void restoreMouseCursor();
|
||||||
|
|
||||||
void showInputKeyboard();
|
void showTextInput();
|
||||||
void hideInputKeyboard();
|
void hideTextInput();
|
||||||
|
|
||||||
void setTitle(const std::string& title);
|
void setTitle(const std::string& title);
|
||||||
void setMinimumSize(const Size& minimumSize);
|
void setMinimumSize(const Size& minimumSize);
|
||||||
|
|||||||
@@ -58,5 +58,7 @@ int main(int argc, char** argv)
|
|||||||
// terminate everything and free memory
|
// terminate everything and free memory
|
||||||
g_client.terminate();
|
g_client.terminate();
|
||||||
g_app.terminate();
|
g_app.terminate();
|
||||||
|
|
||||||
|
exit(0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user