gr-fosphor: Introduce a new glctx_update call back to refresh context
This is required for OSX where you need to tell the GL context when resize has occured and stuff like that. Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
parent
4ca8954908
commit
3dd8d53490
|
@ -47,7 +47,8 @@ namespace gr {
|
|||
* class. fosphor::wx_core_sink_c::make is the public interface for
|
||||
* creating new instances.
|
||||
*/
|
||||
static sptr make(PyObject *cb_init, PyObject *cb_fini, PyObject *cb_swap);
|
||||
static sptr make(PyObject *cb_init, PyObject *cb_fini,
|
||||
PyObject *cb_swap, PyObject *cb_update);
|
||||
|
||||
virtual void pycb_reshape(int width, int height) = 0;
|
||||
};
|
||||
|
|
|
@ -174,7 +174,10 @@ base_sink_c_impl::settings_get_and_reset_changed(void)
|
|||
void
|
||||
base_sink_c_impl::settings_apply(uint32_t settings)
|
||||
{
|
||||
if (settings & SETTING_DIMENSIONS) {
|
||||
if (settings & SETTING_DIMENSIONS)
|
||||
{
|
||||
this->glctx_update();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
|
|
|
@ -94,6 +94,7 @@ namespace gr {
|
|||
virtual void glctx_poll() = 0;
|
||||
virtual void glctx_swap() = 0;
|
||||
virtual void glctx_fini() = 0;
|
||||
virtual void glctx_update() = 0;
|
||||
|
||||
/* Callbacks from GL window */
|
||||
void cb_reshape(int width, int height);
|
||||
|
|
|
@ -143,6 +143,12 @@ glfw_sink_c_impl::glctx_fini()
|
|||
glfwTerminate();
|
||||
}
|
||||
|
||||
void
|
||||
glfw_sink_c_impl::glctx_update()
|
||||
{
|
||||
/* Nothing to do for GLFW */
|
||||
}
|
||||
|
||||
|
||||
} /* namespace fosphor */
|
||||
} /* namespace gr */
|
||||
|
|
|
@ -54,6 +54,7 @@ namespace gr {
|
|||
void glctx_swap();
|
||||
void glctx_poll();
|
||||
void glctx_fini();
|
||||
void glctx_update();
|
||||
|
||||
public:
|
||||
glfw_sink_c_impl();
|
||||
|
|
|
@ -86,6 +86,12 @@ qt_sink_c_impl::glctx_fini()
|
|||
this->d_gui->doneCurrent();
|
||||
}
|
||||
|
||||
void
|
||||
qt_sink_c_impl::glctx_update()
|
||||
{
|
||||
this->d_gui->makeCurrent();
|
||||
}
|
||||
|
||||
|
||||
#ifdef ENABLE_PYTHON
|
||||
PyObject*
|
||||
|
|
|
@ -48,6 +48,7 @@ namespace gr {
|
|||
void glctx_swap();
|
||||
void glctx_poll();
|
||||
void glctx_fini();
|
||||
void glctx_update();
|
||||
|
||||
public:
|
||||
qt_sink_c_impl(QWidget *parent=NULL);
|
||||
|
|
|
@ -31,19 +31,25 @@ namespace gr {
|
|||
namespace fosphor {
|
||||
|
||||
wx_core_sink_c::sptr
|
||||
wx_core_sink_c::make(PyObject *cb_init, PyObject *cb_fini, PyObject *cb_swap)
|
||||
wx_core_sink_c::make(PyObject *cb_init, PyObject *cb_fini,
|
||||
PyObject *cb_swap, PyObject *cb_update)
|
||||
{
|
||||
return gnuradio::get_initial_sptr(new wx_core_sink_c_impl(cb_init, cb_fini, cb_swap));
|
||||
return gnuradio::get_initial_sptr(
|
||||
new wx_core_sink_c_impl(cb_init, cb_fini, cb_swap, cb_update)
|
||||
);
|
||||
}
|
||||
|
||||
wx_core_sink_c_impl::wx_core_sink_c_impl(PyObject *cb_init, PyObject *cb_fini, PyObject *cb_swap)
|
||||
wx_core_sink_c_impl::wx_core_sink_c_impl(PyObject *cb_init, PyObject *cb_fini,
|
||||
PyObject *cb_swap, PyObject *cb_update)
|
||||
: base_sink_c("wx_core_sink_c"),
|
||||
d_cb_init(cb_init), d_cb_fini(cb_fini), d_cb_swap(cb_swap)
|
||||
d_cb_init(cb_init), d_cb_fini(cb_fini),
|
||||
d_cb_swap(cb_swap), d_cb_update(cb_update)
|
||||
{
|
||||
/* Make sure we keep reference to callbacks */
|
||||
Py_INCREF(this->d_cb_init);
|
||||
Py_INCREF(this->d_cb_fini);
|
||||
Py_INCREF(this->d_cb_swap);
|
||||
Py_INCREF(this->d_cb_update);
|
||||
}
|
||||
|
||||
wx_core_sink_c_impl::~wx_core_sink_c_impl()
|
||||
|
@ -52,6 +58,7 @@ wx_core_sink_c_impl::~wx_core_sink_c_impl()
|
|||
Py_DECREF(this->d_cb_init);
|
||||
Py_DECREF(this->d_cb_fini);
|
||||
Py_DECREF(this->d_cb_swap);
|
||||
Py_DECREF(this->d_cb_update);
|
||||
}
|
||||
|
||||
|
||||
|
@ -99,6 +106,12 @@ wx_core_sink_c_impl::glctx_fini()
|
|||
this->pycall(this->d_cb_fini);
|
||||
}
|
||||
|
||||
void
|
||||
wx_core_sink_c_impl::glctx_update()
|
||||
{
|
||||
this->pycall(this->d_cb_update);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
wx_core_sink_c_impl::pycb_reshape(int width, int height)
|
||||
|
|
|
@ -42,6 +42,7 @@ namespace gr {
|
|||
PyObject *d_cb_init;
|
||||
PyObject *d_cb_fini;
|
||||
PyObject *d_cb_swap;
|
||||
PyObject *d_cb_update;
|
||||
|
||||
protected:
|
||||
/* Delegated implementation of GL context management */
|
||||
|
@ -49,9 +50,11 @@ namespace gr {
|
|||
void glctx_swap();
|
||||
void glctx_poll();
|
||||
void glctx_fini();
|
||||
void glctx_update();
|
||||
|
||||
public:
|
||||
wx_core_sink_c_impl(PyObject *cb_init, PyObject *cb_fini, PyObject *cb_swap);
|
||||
wx_core_sink_c_impl(PyObject *cb_init, PyObject *cb_fini,
|
||||
PyObject *cb_swap, PyObject *cb_update);
|
||||
~wx_core_sink_c_impl();
|
||||
|
||||
void pycb_reshape(int width, int height);
|
||||
|
|
|
@ -56,7 +56,8 @@ class wx_sink_c(gr.hier_block2):
|
|||
self._gl_ctx = None
|
||||
|
||||
# Create the underlying WX sink core
|
||||
self.sink = wx_core_sink_c(self._glctx_init, self._glctx_fini, self._glctx_swap)
|
||||
self.sink = wx_core_sink_c(self._glctx_init, self._glctx_fini,
|
||||
self._glctx_swap, self._glctx_update)
|
||||
self.connect(self, self.sink)
|
||||
|
||||
def _evt_size(self, evt):
|
||||
|
@ -86,6 +87,9 @@ class wx_sink_c(gr.hier_block2):
|
|||
def _glctx_swap(self):
|
||||
self.win.SwapBuffers()
|
||||
|
||||
def _glctx_update(self):
|
||||
self.win.SetCurrent(self._gl_ctx)
|
||||
|
||||
def __getattr__(self, attr):
|
||||
try:
|
||||
return gr.hier_block2.__getattr__(self, attr)
|
||||
|
|
Loading…
Reference in New Issue