Пример #1
0
void glut_drag(int x, int y)
{
    lua_rawgeti(L, LUA_REGISTRYINDEX, lf_drag);
    lua_pushnumber(L, x);
    lua_pushnumber(L, y);
    luacall(2);
}
Пример #2
0
		function_result invoke(types<>, std::index_sequence<>, std::ptrdiff_t n) const {
			int stacksize = lua_gettop(base_t::lua_state());
			int firstreturn = (std::max)(1, stacksize - static_cast<int>(n));
			luacall(n, LUA_MULTRET);
			int poststacksize = lua_gettop(base_t::lua_state());
			int returncount = poststacksize - (firstreturn - 1);
			return function_result(base_t::lua_state(), firstreturn, returncount);
		}
Пример #3
0
void glut_keyup(unsigned char key, int x, int y)
{
    lua_rawgeti(L, LUA_REGISTRYINDEX, lf_keypress);
    char str[2] = {key, '\0'};
    lua_pushstring(L, str);
    lua_pushboolean(L, false);
    luacall(2);
}
Пример #4
0
void glut_click(int button, int state, int x, int y)
{
    lua_rawgeti(L, LUA_REGISTRYINDEX, lf_click);
    lua_pushnumber(L, button);
    lua_pushnumber(L, state);
    lua_pushnumber(L, x);
    lua_pushnumber(L, y);
    luacall(4);
}
Пример #5
0
void glut_display()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glLoadIdentity();

    gluPerspective(45.0f, SCREEN_WIDTH*1.0/SCREEN_HEIGHT, 0.5f, 300000.0f);

    lua_rawgeti(L, LUA_REGISTRYINDEX, lf_display);
    luacall(0);

    glutSwapBuffers();

}
Пример #6
0
void glut_special_keyboard(int key, int x, int y)
{
    lua_rawgeti(L, LUA_REGISTRYINDEX, lf_keypress);
    const char *str = NULL;
    switch(key) {
        MAP(GLUT_KEY_UP, "up");
        MAP(GLUT_KEY_DOWN, "down");
        MAP(GLUT_KEY_LEFT, "left");
        MAP(GLUT_KEY_RIGHT, "right");
    }

    if(str == NULL) {
        //send the ugly raw key int
        lua_pushnumber(L, key);
    } else {
        //send the nice pretty string
        lua_pushstring(L, str);
    }
    lua_pushboolean(L, true);
    luacall(2);
}
Пример #7
0
		void invoke(types<void>, std::index_sequence<I>, std::ptrdiff_t n) const {
			luacall(n, 0);
		}
Пример #8
0
		Ret invoke(types<Ret>, std::index_sequence<I>, std::ptrdiff_t n) const {
			luacall(n, lua_size<Ret>::value);
			return stack::pop<Ret>(base_t::lua_state());
		}
Пример #9
0
		auto invoke(types<Ret...>, std::index_sequence<I...>, std::ptrdiff_t n) const {
			luacall(n, lua_size<std::tuple<Ret...>>::value);
			return stack::pop<std::tuple<Ret...>>(base_t::lua_state());
		}