Merge minor into dynamiccore2

--HG--
branch : dynamiccore2
This commit is contained in:
Bart van Strien
2016-11-26 22:19:12 +01:00
61 changed files with 4909 additions and 1720 deletions
+17
View File
@@ -112,6 +112,8 @@ Event::~Event()
void Event::pump()
{
exceptionIfInRenderPass();
SDL_Event e;
while (SDL_PollEvent(&e))
@@ -127,6 +129,8 @@ void Event::pump()
Message *Event::wait()
{
exceptionIfInRenderPass();
SDL_Event e;
if (SDL_WaitEvent(&e) != 1)
@@ -137,6 +141,8 @@ Message *Event::wait()
void Event::clear()
{
exceptionIfInRenderPass();
SDL_Event e;
while (SDL_PollEvent(&e))
@@ -147,6 +153,17 @@ void Event::clear()
love::event::Event::clear();
}
void Event::exceptionIfInRenderPass()
{
// Some core OS graphics functionality (e.g. swap buffers on some platforms)
// happens inside SDL_PumpEvents - which is called by SDL_PollEvent and
// friends. It's probably a bad idea to call those functions while we're in
// a render pass.
auto gfx = Module::getInstance<graphics::Graphics>(Module::M_GRAPHICS);
if (gfx != nullptr && gfx->isPassActive())
throw love::Exception("Cannot call this function while a render pass is active in love.graphics.");
}
Message *Event::convert(const SDL_Event &e) const
{
Message *msg = nullptr;
+2
View File
@@ -68,6 +68,8 @@ public:
private:
void exceptionIfInRenderPass();
Message *convert(const SDL_Event &e) const;
Message *convertJoystickEvent(const SDL_Event &e) const;
Message *convertWindowEvent(const SDL_Event &e) const;
+6 -5
View File
@@ -53,15 +53,16 @@ int w_poll(lua_State *L)
return 1;
}
int w_pump(lua_State *)
int w_pump(lua_State *L)
{
instance()->pump();
luax_catchexcept(L, [&]() { instance()->pump(); });
return 0;
}
int w_wait(lua_State *L)
{
Message *m = instance()->wait();
Message *m = nullptr;
luax_catchexcept(L, [&]() { m = instance()->wait(); });
if (m)
{
int args = m->toLua(L);
@@ -85,9 +86,9 @@ int w_push(lua_State *L)
return 1;
}
int w_clear(lua_State *)
int w_clear(lua_State *L)
{
instance()->clear();
luax_catchexcept(L, [&]() { instance()->clear(); });
return 0;
}