Allow passing a timeout to waitevents
This commit is contained in:
parent
948f66b065
commit
2d3b7d15c7
@ -21,7 +21,7 @@ static PyMethodDef module_methods[] = {
|
|||||||
{"glfw_terminate", (PyCFunction)glfw_terminate, METH_NOARGS, ""},
|
{"glfw_terminate", (PyCFunction)glfw_terminate, METH_NOARGS, ""},
|
||||||
{"glfw_window_hint", (PyCFunction)glfw_window_hint, METH_VARARGS, ""},
|
{"glfw_window_hint", (PyCFunction)glfw_window_hint, METH_VARARGS, ""},
|
||||||
{"glfw_swap_interval", (PyCFunction)glfw_swap_interval, METH_VARARGS, ""},
|
{"glfw_swap_interval", (PyCFunction)glfw_swap_interval, METH_VARARGS, ""},
|
||||||
{"glfw_wait_events", (PyCFunction)glfw_wait_events, METH_NOARGS, ""},
|
{"glfw_wait_events", (PyCFunction)glfw_wait_events, METH_VARARGS, ""},
|
||||||
{"glfw_post_empty_event", (PyCFunction)glfw_post_empty_event, METH_NOARGS, ""},
|
{"glfw_post_empty_event", (PyCFunction)glfw_post_empty_event, METH_NOARGS, ""},
|
||||||
{"glfw_get_physical_dpi", (PyCFunction)glfw_get_physical_dpi, METH_NOARGS, ""},
|
{"glfw_get_physical_dpi", (PyCFunction)glfw_get_physical_dpi, METH_NOARGS, ""},
|
||||||
{NULL, NULL, 0, NULL} /* Sentinel */
|
{NULL, NULL, 0, NULL} /* Sentinel */
|
||||||
|
|||||||
@ -155,9 +155,12 @@ glfw_swap_interval(PyObject UNUSED *self, PyObject *args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PyObject*
|
PyObject*
|
||||||
glfw_wait_events(PyObject UNUSED *self) {
|
glfw_wait_events(PyObject UNUSED *self, PyObject *args) {
|
||||||
|
double time = -1;
|
||||||
|
if(!PyArg_ParseTuple(args, "|d", &time)) return NULL;
|
||||||
Py_BEGIN_ALLOW_THREADS;
|
Py_BEGIN_ALLOW_THREADS;
|
||||||
glfwWaitEvents();
|
if (time < 0) glfwWaitEvents();
|
||||||
|
else glfwWaitEventsTimeout(time);
|
||||||
Py_END_ALLOW_THREADS;
|
Py_END_ALLOW_THREADS;
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,6 @@ PyObject* glfw_init(PyObject UNUSED *self);
|
|||||||
PyObject* glfw_terminate(PyObject UNUSED *self);
|
PyObject* glfw_terminate(PyObject UNUSED *self);
|
||||||
PyObject* glfw_window_hint(PyObject UNUSED *self, PyObject *args);
|
PyObject* glfw_window_hint(PyObject UNUSED *self, PyObject *args);
|
||||||
PyObject* glfw_swap_interval(PyObject UNUSED *self, PyObject *args);
|
PyObject* glfw_swap_interval(PyObject UNUSED *self, PyObject *args);
|
||||||
PyObject* glfw_wait_events(PyObject UNUSED *self);
|
PyObject* glfw_wait_events(PyObject UNUSED *self, PyObject*);
|
||||||
PyObject* glfw_post_empty_event(PyObject UNUSED *self);
|
PyObject* glfw_post_empty_event(PyObject UNUSED *self);
|
||||||
PyObject* glfw_get_physical_dpi(PyObject UNUSED *self);
|
PyObject* glfw_get_physical_dpi(PyObject UNUSED *self);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user